diff --git a/terraform/providers/google/go.mod b/terraform/providers/google/go.mod index 082e29c7448..241e5c3228e 100644 --- a/terraform/providers/google/go.mod +++ b/terraform/providers/google/go.mod @@ -2,7 +2,7 @@ module github.com/openshift/installer/terraform/providers/google go 1.20 -require github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c // v5.37.0 +require github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c // v5.21.0 require ( bitbucket.org/creachadair/stringset v0.0.8 // indirect @@ -76,6 +76,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.14.1 // indirect github.com/sirupsen/logrus v1.8.1 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect @@ -87,14 +88,12 @@ require ( go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - go4.org/netipx v0.0.0-20231129151722-fdeea329fbba // indirect golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect - golang.org/x/mod v0.17.0 // indirect + golang.org/x/mod v0.21.0 // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/oauth2 v0.21.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect google.golang.org/api v0.185.0 // indirect @@ -107,3 +106,6 @@ require ( ) replace bitbucket.org/creachadair/stringset => bitbucket.org/creachadair/stringset v0.0.11 + +//https://issues.redhat.com/browse/OCPBUGS-76929 +replace github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c => github.com/openshift/terraform-providers-terraform-provider-google v1.20.1-0.20260211184214-05cc74bd8b63 diff --git a/terraform/providers/google/go.sum b/terraform/providers/google/go.sum index 80587f4a457..84be0cc2960 100644 --- a/terraform/providers/google/go.sum +++ b/terraform/providers/google/go.sum @@ -167,8 +167,6 @@ github.com/hashicorp/terraform-plugin-mux v0.15.0 h1:+/+lDx0WUsIOpkAmdwBIoFU8UP9 github.com/hashicorp/terraform-plugin-mux v0.15.0/go.mod h1:9ezplb1Dyq394zQ+ldB0nvy/qbNAz3mMoHHseMTMaKo= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= -github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c h1:rTfbrGJsKJ+ciBhJkBRYcT6tCPpeI1yspoC1KpPSdYE= -github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c/go.mod h1:VHiRA994xbf2/Xi++bmSfimZHe/4rbfPM3eprIU1Oq0= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -214,13 +212,16 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/openshift/terraform-providers-terraform-provider-google v1.20.1-0.20260211184214-05cc74bd8b63 h1:8aYg9hpNfz4LYhANt9Z+giZ88TSYIothfrGEF25FThw= +github.com/openshift/terraform-providers-terraform-provider-google v1.20.1-0.20260211184214-05cc74bd8b63/go.mod h1:dK4tW004K9Bu9N9lphDxPQgfS99iSUl3l3Yc0qZIzGA= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= @@ -266,8 +267,6 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= -go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -275,16 +274,14 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 h1:ESSUROHIBHg7USnszlcdmjBEwdMj9VUvU+OPk4yl2mc= -golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= -golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -326,8 +323,8 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -348,7 +345,7 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment.go new file mode 100644 index 00000000000..972552957f4 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment.go @@ -0,0 +1,428 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package bigqueryreservation + +import ( + "context" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type Assignment struct { + Name *string `json:"name"` + Assignee *string `json:"assignee"` + JobType *AssignmentJobTypeEnum `json:"jobType"` + State *AssignmentStateEnum `json:"state"` + Project *string `json:"project"` + Location *string `json:"location"` + Reservation *string `json:"reservation"` +} + +func (r *Assignment) String() string { + return dcl.SprintResource(r) +} + +// The enum AssignmentJobTypeEnum. +type AssignmentJobTypeEnum string + +// AssignmentJobTypeEnumRef returns a *AssignmentJobTypeEnum with the value of string s +// If the empty string is provided, nil is returned. +func AssignmentJobTypeEnumRef(s string) *AssignmentJobTypeEnum { + v := AssignmentJobTypeEnum(s) + return &v +} + +func (v AssignmentJobTypeEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"JOB_TYPE_UNSPECIFIED", "PIPELINE", "QUERY"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "AssignmentJobTypeEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum AssignmentStateEnum. +type AssignmentStateEnum string + +// AssignmentStateEnumRef returns a *AssignmentStateEnum with the value of string s +// If the empty string is provided, nil is returned. +func AssignmentStateEnumRef(s string) *AssignmentStateEnum { + v := AssignmentStateEnum(s) + return &v +} + +func (v AssignmentStateEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"STATE_UNSPECIFIED", "PENDING", "ACTIVE"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "AssignmentStateEnum", + Value: string(v), + Valid: []string{}, + } +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *Assignment) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "bigquery_reservation", + Type: "Assignment", + Version: "bigqueryreservation", + } +} + +func (r *Assignment) ID() (string, error) { + if err := extractAssignmentFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "assignee": dcl.ValueOrEmptyString(nr.Assignee), + "job_type": dcl.ValueOrEmptyString(nr.JobType), + "state": dcl.ValueOrEmptyString(nr.State), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "reservation": dcl.ValueOrEmptyString(nr.Reservation), + } + return dcl.Nprintf("projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}", params), nil +} + +const AssignmentMaxPage = -1 + +type AssignmentList struct { + Items []*Assignment + + nextToken string + + pageSize int32 + + resource *Assignment +} + +func (l *AssignmentList) HasNext() bool { + return l.nextToken != "" +} + +func (l *AssignmentList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listAssignment(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListAssignment(ctx context.Context, project, location, reservation string) (*AssignmentList, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListAssignmentWithMaxResults(ctx, project, location, reservation, AssignmentMaxPage) + +} + +func (c *Client) ListAssignmentWithMaxResults(ctx context.Context, project, location, reservation string, pageSize int32) (*AssignmentList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &Assignment{ + Project: &project, + Location: &location, + Reservation: &reservation, + } + items, token, err := c.listAssignment(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &AssignmentList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetAssignment(ctx context.Context, r *Assignment) (*Assignment, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractAssignmentFields(r) + + b, err := c.getAssignmentRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalAssignment(b, c, r) + if err != nil { + return nil, err + } + result.Project = r.Project + result.Location = r.Location + result.Reservation = r.Reservation + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizeAssignmentNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractAssignmentFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeleteAssignment(ctx context.Context, r *Assignment) error { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("Assignment resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting Assignment...") + deleteOp := deleteAssignmentOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllAssignment deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllAssignment(ctx context.Context, project, location, reservation string, filter func(*Assignment) bool) error { + listObj, err := c.ListAssignment(ctx, project, location, reservation) + if err != nil { + return err + } + + err = c.deleteAllAssignment(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllAssignment(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyAssignment(ctx context.Context, rawDesired *Assignment, opts ...dcl.ApplyOption) (*Assignment, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + var resultNewState *Assignment + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyAssignmentHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyAssignmentHelper(c *Client, ctx context.Context, rawDesired *Assignment, opts ...dcl.ApplyOption) (*Assignment, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyAssignment...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractAssignmentFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.assignmentDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToAssignmentDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []assignmentApiOperation + if create { + ops = append(ops, &createAssignmentOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyAssignmentDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyAssignmentDiff(c *Client, ctx context.Context, desired *Assignment, rawDesired *Assignment, ops []assignmentApiOperation, opts ...dcl.ApplyOption) (*Assignment, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetAssignment(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createAssignmentOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapAssignment(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizeAssignmentNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizeAssignmentNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizeAssignmentDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractAssignmentFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractAssignmentFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffAssignment(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment.yaml new file mode 100644 index 00000000000..8da65ac8264 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment.yaml @@ -0,0 +1,156 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: BigqueryReservation/Assignment + description: The BigqueryReservation Assignment resource + x-dcl-struct-name: Assignment + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a Assignment + parameters: + - name: assignment + required: true + description: A full instance of a Assignment + apply: + description: The function used to apply information about a Assignment + parameters: + - name: assignment + required: true + description: A full instance of a Assignment + delete: + description: The function used to delete a Assignment + parameters: + - name: assignment + required: true + description: A full instance of a Assignment + deleteAll: + description: The function used to delete all Assignment + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + - name: reservation + required: true + schema: + type: string + list: + description: The function used to list information about many Assignment + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + - name: reservation + required: true + schema: + type: string +components: + schemas: + Assignment: + title: Assignment + x-dcl-id: projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}} + x-dcl-parent-container: project + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - assignee + - jobType + - reservation + properties: + assignee: + type: string + x-dcl-go-name: Assignee + description: The resource which will use the reservation. E.g. projects/myproject, + folders/123, organizations/456. + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + - resource: Cloudresourcemanager/Folder + field: name + - resource: Cloudresourcemanager/Organization + field: name + jobType: + type: string + x-dcl-go-name: JobType + x-dcl-go-type: AssignmentJobTypeEnum + description: 'Types of job, which could be specified when using the reservation. + Possible values: JOB_TYPE_UNSPECIFIED, PIPELINE, QUERY' + x-kubernetes-immutable: true + enum: + - JOB_TYPE_UNSPECIFIED + - PIPELINE + - QUERY + location: + type: string + x-dcl-go-name: Location + description: The location for the resource + x-kubernetes-immutable: true + x-dcl-extract-if-empty: true + x-dcl-parameter: true + name: + type: string + x-dcl-go-name: Name + description: Output only. The resource name of the assignment. + x-kubernetes-immutable: true + x-dcl-server-generated-parameter: true + project: + type: string + x-dcl-go-name: Project + description: The project for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-extract-if-empty: true + x-dcl-parameter: true + reservation: + type: string + x-dcl-go-name: Reservation + description: The reservation for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Bigqueryreservation/Reservation + field: name + parent: true + x-dcl-parameter: true + x-dcl-has-long-form: true + state: + type: string + x-dcl-go-name: State + x-dcl-go-type: AssignmentStateEnum + readOnly: true + description: 'Assignment will remain in PENDING state if no active capacity + commitment is present. It will become ACTIVE when some capacity commitment + becomes active. Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE' + x-kubernetes-immutable: true + enum: + - STATE_UNSPECIFIED + - PENDING + - ACTIVE diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_internal.go new file mode 100644 index 00000000000..a950b3179b3 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_internal.go @@ -0,0 +1,774 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package bigqueryreservation + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func (r *Assignment) validate() error { + + if err := dcl.Required(r, "assignee"); err != nil { + return err + } + if err := dcl.Required(r, "jobType"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Reservation, "Reservation"); err != nil { + return err + } + return nil +} +func (r *Assignment) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://bigqueryreservation.googleapis.com/v1/", params) +} + +func (r *Assignment) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "reservation": dcl.ValueOrEmptyString(nr.Reservation), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments", nr.basePath(), userBasePath, params), nil +} + +func (r *Assignment) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "reservation": dcl.ValueOrEmptyString(nr.Reservation), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments", nr.basePath(), userBasePath, params), nil + +} + +func (r *Assignment) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "reservation": dcl.ValueOrEmptyString(nr.Reservation), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments", nr.basePath(), userBasePath, params), nil + +} + +func (r *Assignment) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "reservation": dcl.ValueOrEmptyString(nr.Reservation), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}", nr.basePath(), userBasePath, params), nil +} + +// assignmentApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type assignmentApiOperation interface { + do(context.Context, *Assignment, *Client) error +} + +func (c *Client) listAssignmentRaw(ctx context.Context, r *Assignment, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != AssignmentMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listAssignmentOperation struct { + Assignments []map[string]interface{} `json:"assignments"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listAssignment(ctx context.Context, r *Assignment, pageToken string, pageSize int32) ([]*Assignment, string, error) { + b, err := c.listAssignmentRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listAssignmentOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*Assignment + for _, v := range m.Assignments { + res, err := unmarshalMapAssignment(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Project = r.Project + res.Location = r.Location + res.Reservation = r.Reservation + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllAssignment(ctx context.Context, f func(*Assignment) bool, resources []*Assignment) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeleteAssignment(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deleteAssignmentOperation struct{} + +func (op *deleteAssignmentOperation) do(ctx context.Context, r *Assignment, c *Client) error { + r, err := c.GetAssignment(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "Assignment not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetAssignment checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + _, err = dcl.SendRequest(ctx, c.Config, "DELETE", u, body, c.Config.RetryProvider) + if err != nil { + return fmt.Errorf("failed to delete Assignment: %w", err) + } + + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetAssignment(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil + } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createAssignmentOperation struct { + response map[string]interface{} +} + +func (op *createAssignmentOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createAssignmentOperation) do(ctx context.Context, r *Assignment, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + if r.Name != nil { + // Allowing creation to continue with Name set could result in a Assignment with the wrong Name. + return fmt.Errorf("server-generated parameter Name was specified by user as %v, should be unspecified", dcl.ValueOrEmptyString(r.Name)) + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + + o, err := dcl.ResponseBodyAsJSON(resp) + if err != nil { + return fmt.Errorf("error decoding response body into JSON: %w", err) + } + op.response = o + + // Include Name in URL substitution for initial GET request. + m := op.response + r.Name = dcl.SelfLinkToName(dcl.FlattenString(m["name"])) + + if _, err := c.GetAssignment(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + return nil +} + +func (c *Client) getAssignmentRaw(ctx context.Context, r *Assignment) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + b, err = dcl.ExtractElementFromList(b, "assignments", r.matcher(c)) + if err != nil { + return nil, err + } + return b, nil +} + +func (c *Client) assignmentDiffsForRawDesired(ctx context.Context, rawDesired *Assignment, opts ...dcl.ApplyOption) (initial, desired *Assignment, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *Assignment + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*Assignment); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected Assignment, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + if fetchState.Name == nil { + // We cannot perform a get because of lack of information. We have to assume + // that this is being created for the first time. + desired, err := canonicalizeAssignmentDesiredState(rawDesired, nil) + return nil, desired, nil, err + } + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetAssignment(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a Assignment resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve Assignment resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that Assignment resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizeAssignmentDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for Assignment: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for Assignment: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractAssignmentFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizeAssignmentInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for Assignment: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizeAssignmentDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for Assignment: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffAssignment(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizeAssignmentInitialState(rawInitial, rawDesired *Assignment) (*Assignment, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizeAssignmentDesiredState(rawDesired, rawInitial *Assignment, opts ...dcl.ApplyOption) (*Assignment, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + + return rawDesired, nil + } + canonicalDesired := &Assignment{} + if dcl.IsZeroValue(rawDesired.Name) || (dcl.IsEmptyValueIndirect(rawDesired.Name) && dcl.IsEmptyValueIndirect(rawInitial.Name)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + if dcl.IsZeroValue(rawDesired.Assignee) || (dcl.IsEmptyValueIndirect(rawDesired.Assignee) && dcl.IsEmptyValueIndirect(rawInitial.Assignee)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Assignee = rawInitial.Assignee + } else { + canonicalDesired.Assignee = rawDesired.Assignee + } + if dcl.IsZeroValue(rawDesired.JobType) || (dcl.IsEmptyValueIndirect(rawDesired.JobType) && dcl.IsEmptyValueIndirect(rawInitial.JobType)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.JobType = rawInitial.JobType + } else { + canonicalDesired.JobType = rawDesired.JobType + } + if dcl.NameToSelfLink(rawDesired.Project, rawInitial.Project) { + canonicalDesired.Project = rawInitial.Project + } else { + canonicalDesired.Project = rawDesired.Project + } + if dcl.NameToSelfLink(rawDesired.Location, rawInitial.Location) { + canonicalDesired.Location = rawInitial.Location + } else { + canonicalDesired.Location = rawDesired.Location + } + if dcl.NameToSelfLink(rawDesired.Reservation, rawInitial.Reservation) { + canonicalDesired.Reservation = rawInitial.Reservation + } else { + canonicalDesired.Reservation = rawDesired.Reservation + } + return canonicalDesired, nil +} + +func canonicalizeAssignmentNewState(c *Client, rawNew, rawDesired *Assignment) (*Assignment, error) { + + if dcl.IsEmptyValueIndirect(rawNew.Name) && dcl.IsEmptyValueIndirect(rawDesired.Name) { + rawNew.Name = rawDesired.Name + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.Assignee) && dcl.IsEmptyValueIndirect(rawDesired.Assignee) { + rawNew.Assignee = rawDesired.Assignee + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.JobType) && dcl.IsEmptyValueIndirect(rawDesired.JobType) { + rawNew.JobType = rawDesired.JobType + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.State) && dcl.IsEmptyValueIndirect(rawDesired.State) { + rawNew.State = rawDesired.State + } else { + } + + rawNew.Project = rawDesired.Project + + rawNew.Location = rawDesired.Location + + rawNew.Reservation = rawDesired.Reservation + + return rawNew, nil +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffAssignment(c *Client, desired, actual *Assignment, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Assignee, actual.Assignee, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Assignee")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.JobType, actual.JobType, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("JobType")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.State, actual.State, dcl.DiffInfo{OutputOnly: true, Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("State")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Reservation, actual.Reservation, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Reservation")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Assignment) urlNormalized() *Assignment { + normalized := dcl.Copy(*r).(Assignment) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.Assignee = dcl.SelfLinkToName(r.Assignee) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + normalized.Reservation = dcl.SelfLinkToName(r.Reservation) + return &normalized +} + +func (r *Assignment) updateURL(userBasePath, updateName string) (string, error) { + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Assignment resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Assignment) marshal(c *Client) ([]byte, error) { + m, err := expandAssignment(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Assignment: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalAssignment decodes JSON responses into the Assignment resource schema. +func unmarshalAssignment(b []byte, c *Client, res *Assignment) (*Assignment, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapAssignment(m, c, res) +} + +func unmarshalMapAssignment(m map[string]interface{}, c *Client, res *Assignment) (*Assignment, error) { + + flattened := flattenAssignment(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandAssignment expands Assignment into a JSON request object. +func expandAssignment(c *Client, f *Assignment) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v := f.Name; dcl.ValueShouldBeSent(v) { + m["name"] = v + } + if v := f.Assignee; dcl.ValueShouldBeSent(v) { + m["assignee"] = v + } + if v := f.JobType; dcl.ValueShouldBeSent(v) { + m["jobType"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Reservation into reservation: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["reservation"] = v + } + + return m, nil +} + +// flattenAssignment flattens Assignment from a JSON request object into the +// Assignment type. +func flattenAssignment(c *Client, i interface{}, res *Assignment) *Assignment { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Assignment{} + resultRes.Name = dcl.SelfLinkToName(dcl.FlattenString(m["name"])) + resultRes.Assignee = dcl.FlattenString(m["assignee"]) + resultRes.JobType = flattenAssignmentJobTypeEnum(m["jobType"]) + resultRes.State = flattenAssignmentStateEnum(m["state"]) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + resultRes.Reservation = dcl.FlattenString(m["reservation"]) + + return resultRes +} + +// flattenAssignmentJobTypeEnumMap flattens the contents of AssignmentJobTypeEnum from a JSON +// response object. +func flattenAssignmentJobTypeEnumMap(c *Client, i interface{}, res *Assignment) map[string]AssignmentJobTypeEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]AssignmentJobTypeEnum{} + } + + if len(a) == 0 { + return map[string]AssignmentJobTypeEnum{} + } + + items := make(map[string]AssignmentJobTypeEnum) + for k, item := range a { + items[k] = *flattenAssignmentJobTypeEnum(item.(interface{})) + } + + return items +} + +// flattenAssignmentJobTypeEnumSlice flattens the contents of AssignmentJobTypeEnum from a JSON +// response object. +func flattenAssignmentJobTypeEnumSlice(c *Client, i interface{}, res *Assignment) []AssignmentJobTypeEnum { + a, ok := i.([]interface{}) + if !ok { + return []AssignmentJobTypeEnum{} + } + + if len(a) == 0 { + return []AssignmentJobTypeEnum{} + } + + items := make([]AssignmentJobTypeEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenAssignmentJobTypeEnum(item.(interface{}))) + } + + return items +} + +// flattenAssignmentJobTypeEnum asserts that an interface is a string, and returns a +// pointer to a *AssignmentJobTypeEnum with the same value as that string. +func flattenAssignmentJobTypeEnum(i interface{}) *AssignmentJobTypeEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return AssignmentJobTypeEnumRef(s) +} + +// flattenAssignmentStateEnumMap flattens the contents of AssignmentStateEnum from a JSON +// response object. +func flattenAssignmentStateEnumMap(c *Client, i interface{}, res *Assignment) map[string]AssignmentStateEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]AssignmentStateEnum{} + } + + if len(a) == 0 { + return map[string]AssignmentStateEnum{} + } + + items := make(map[string]AssignmentStateEnum) + for k, item := range a { + items[k] = *flattenAssignmentStateEnum(item.(interface{})) + } + + return items +} + +// flattenAssignmentStateEnumSlice flattens the contents of AssignmentStateEnum from a JSON +// response object. +func flattenAssignmentStateEnumSlice(c *Client, i interface{}, res *Assignment) []AssignmentStateEnum { + a, ok := i.([]interface{}) + if !ok { + return []AssignmentStateEnum{} + } + + if len(a) == 0 { + return []AssignmentStateEnum{} + } + + items := make([]AssignmentStateEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenAssignmentStateEnum(item.(interface{}))) + } + + return items +} + +// flattenAssignmentStateEnum asserts that an interface is a string, and returns a +// pointer to a *AssignmentStateEnum with the same value as that string. +func flattenAssignmentStateEnum(i interface{}) *AssignmentStateEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return AssignmentStateEnumRef(s) +} + +type assignmentDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp assignmentApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToAssignmentDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]assignmentDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []assignmentDiff + // For each operation name, create a assignmentDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := assignmentDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToAssignmentApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToAssignmentApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (assignmentApiOperation, error) { + switch opName { + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractAssignmentFields(r *Assignment) error { + vProject, err := dcl.ValueFromRegexOnField("Project", r.Project, r.Reservation, "projects/([a-z0-9A-Z-]*)/locations/.*") + if err != nil { + return err + } + r.Project = vProject + vLocation, err := dcl.ValueFromRegexOnField("Location", r.Location, r.Reservation, "projects/.*/locations/([a-z0-9A-Z-]*)/reservations/.*") + if err != nil { + return err + } + r.Location = vLocation + return nil +} + +func postReadExtractAssignmentFields(r *Assignment) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_schema.go new file mode 100644 index 00000000000..2a6abdf4ad7 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_schema.go @@ -0,0 +1,222 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package bigqueryreservation + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLAssignmentSchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "BigqueryReservation/Assignment", + Description: "The BigqueryReservation Assignment resource", + StructName: "Assignment", + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a Assignment", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "assignment", + Required: true, + Description: "A full instance of a Assignment", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a Assignment", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "assignment", + Required: true, + Description: "A full instance of a Assignment", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a Assignment", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "assignment", + Required: true, + Description: "A full instance of a Assignment", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all Assignment", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "reservation", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many Assignment", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "reservation", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "Assignment": &dcl.Component{ + Title: "Assignment", + ID: "projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}", + ParentContainer: "project", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "assignee", + "jobType", + "reservation", + }, + Properties: map[string]*dcl.Property{ + "assignee": &dcl.Property{ + Type: "string", + GoName: "Assignee", + Description: "The resource which will use the reservation. E.g. projects/myproject, folders/123, organizations/456.", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + }, + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Folder", + Field: "name", + }, + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Organization", + Field: "name", + }, + }, + }, + "jobType": &dcl.Property{ + Type: "string", + GoName: "JobType", + GoType: "AssignmentJobTypeEnum", + Description: "Types of job, which could be specified when using the reservation. Possible values: JOB_TYPE_UNSPECIFIED, PIPELINE, QUERY", + Immutable: true, + Enum: []string{ + "JOB_TYPE_UNSPECIFIED", + "PIPELINE", + "QUERY", + }, + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "The location for the resource", + Immutable: true, + ExtractIfEmpty: true, + Parameter: true, + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "Output only. The resource name of the assignment.", + Immutable: true, + ServerGeneratedParameter: true, + }, + "project": &dcl.Property{ + Type: "string", + GoName: "Project", + Description: "The project for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + ExtractIfEmpty: true, + Parameter: true, + }, + "reservation": &dcl.Property{ + Type: "string", + GoName: "Reservation", + Description: "The reservation for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Bigqueryreservation/Reservation", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + HasLongForm: true, + }, + "state": &dcl.Property{ + Type: "string", + GoName: "State", + GoType: "AssignmentStateEnum", + ReadOnly: true, + Description: "Assignment will remain in PENDING state if no active capacity commitment is present. It will become ACTIVE when some capacity commitment becomes active. Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE", + Immutable: true, + Enum: []string{ + "STATE_UNSPECIFIED", + "PENDING", + "ACTIVE", + }, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_yaml_embed.go new file mode 100644 index 00000000000..6c7e5c94b6e --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/assignment_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package bigqueryreservation -var YAML_assignment blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/bigqueryreservation/assignment.yaml + +package bigqueryreservation + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/bigqueryreservation/assignment.yaml +var YAML_assignment = []byte("info:\n title: BigqueryReservation/Assignment\n description: The BigqueryReservation Assignment resource\n x-dcl-struct-name: Assignment\n x-dcl-has-iam: false\npaths:\n get:\n description: The function used to get information about a Assignment\n parameters:\n - name: assignment\n required: true\n description: A full instance of a Assignment\n apply:\n description: The function used to apply information about a Assignment\n parameters:\n - name: assignment\n required: true\n description: A full instance of a Assignment\n delete:\n description: The function used to delete a Assignment\n parameters:\n - name: assignment\n required: true\n description: A full instance of a Assignment\n deleteAll:\n description: The function used to delete all Assignment\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n - name: reservation\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Assignment\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n - name: reservation\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Assignment:\n title: Assignment\n x-dcl-id: projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - assignee\n - jobType\n - reservation\n properties:\n assignee:\n type: string\n x-dcl-go-name: Assignee\n description: The resource which will use the reservation. E.g. projects/myproject,\n folders/123, organizations/456.\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n - resource: Cloudresourcemanager/Folder\n field: name\n - resource: Cloudresourcemanager/Organization\n field: name\n jobType:\n type: string\n x-dcl-go-name: JobType\n x-dcl-go-type: AssignmentJobTypeEnum\n description: 'Types of job, which could be specified when using the reservation.\n Possible values: JOB_TYPE_UNSPECIFIED, PIPELINE, QUERY'\n x-kubernetes-immutable: true\n enum:\n - JOB_TYPE_UNSPECIFIED\n - PIPELINE\n - QUERY\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-extract-if-empty: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Output only. The resource name of the assignment.\n x-kubernetes-immutable: true\n x-dcl-server-generated-parameter: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-extract-if-empty: true\n x-dcl-parameter: true\n reservation:\n type: string\n x-dcl-go-name: Reservation\n description: The reservation for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Bigqueryreservation/Reservation\n field: name\n parent: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n state:\n type: string\n x-dcl-go-name: State\n x-dcl-go-type: AssignmentStateEnum\n readOnly: true\n description: 'Assignment will remain in PENDING state if no active capacity\n commitment is present. It will become ACTIVE when some capacity commitment\n becomes active. Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE'\n x-kubernetes-immutable: true\n enum:\n - STATE_UNSPECIFIED\n - PENDING\n - ACTIVE\n") + +// 4483 bytes +// MD5: ad173d1b9ab95f9b22aeb2bb0b36159b diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/bigqueryreservation_utils.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/bigqueryreservation_utils.go new file mode 100644 index 00000000000..35e2524800f --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/bigqueryreservation_utils.go @@ -0,0 +1,64 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// Package bigqueryreservation defines types and methods for working with bigqueryreservation GCP resources. +package bigqueryreservation + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +// This resource has a custom matcher so that either name or assignee + job_type can be used depending on which is available. +func (r *Assignment) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalAssignment(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if dcl.IsEmptyValueIndirect(nr.Name) || dcl.IsEmptyValueIndirect(ncr.Name) { + // Name field not available for matching, use job type and assignee. + if nr.Assignee == nil && ncr.Assignee == nil { + c.Config.Logger.Info("Both Assignee fields null - considering equal.") + } else if nr.Assignee == nil || ncr.Assignee == nil { + c.Config.Logger.Info("Only one Assignee field is null - considering unequal.") + return false + } else if *nr.Assignee != *ncr.Assignee { + return false + } + if nr.JobType == nil && ncr.JobType == nil { + c.Config.Logger.Info("Both JobType fields null - considering equal.") + } else if nr.JobType == nil || ncr.JobType == nil { + c.Config.Logger.Info("Only one JobType field is null - considering unequal.") + return false + } else if *nr.JobType != *ncr.JobType { + return false + } + } else { + // Name field is available. + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + } + return true + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/client.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/client.go new file mode 100644 index 00000000000..1f975b750c9 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/client.go @@ -0,0 +1,32 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// Package bigqueryreservation defines operations in the declarative SDK. +package bigqueryreservation + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +// The Client is the base struct of all operations. This will receive the +// Get, Delete, List, and Apply operations on all resources. +type Client struct { + Config *dcl.Config +} + +// NewClient creates a client that retries all operations a few times each. +func NewClient(c *dcl.Config) *Client { + return &Client{ + Config: c, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation.go new file mode 100644 index 00000000000..7c414d4d70a --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation.go @@ -0,0 +1,373 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package bigqueryreservation + +import ( + "context" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type Reservation struct { + Name *string `json:"name"` + SlotCapacity *int64 `json:"slotCapacity"` + IgnoreIdleSlots *bool `json:"ignoreIdleSlots"` + CreationTime *string `json:"creationTime"` + UpdateTime *string `json:"updateTime"` + Project *string `json:"project"` + Location *string `json:"location"` +} + +func (r *Reservation) String() string { + return dcl.SprintResource(r) +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *Reservation) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "bigquery_reservation", + Type: "Reservation", + Version: "bigqueryreservation", + } +} + +func (r *Reservation) ID() (string, error) { + if err := extractReservationFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "slot_capacity": dcl.ValueOrEmptyString(nr.SlotCapacity), + "ignore_idle_slots": dcl.ValueOrEmptyString(nr.IgnoreIdleSlots), + "creation_time": dcl.ValueOrEmptyString(nr.CreationTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + } + return dcl.Nprintf("projects/{{project}}/locations/{{location}}/reservations/{{name}}", params), nil +} + +const ReservationMaxPage = -1 + +type ReservationList struct { + Items []*Reservation + + nextToken string + + pageSize int32 + + resource *Reservation +} + +func (l *ReservationList) HasNext() bool { + return l.nextToken != "" +} + +func (l *ReservationList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listReservation(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListReservation(ctx context.Context, project, location string) (*ReservationList, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListReservationWithMaxResults(ctx, project, location, ReservationMaxPage) + +} + +func (c *Client) ListReservationWithMaxResults(ctx context.Context, project, location string, pageSize int32) (*ReservationList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &Reservation{ + Project: &project, + Location: &location, + } + items, token, err := c.listReservation(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &ReservationList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetReservation(ctx context.Context, r *Reservation) (*Reservation, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractReservationFields(r) + + b, err := c.getReservationRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalReservation(b, c, r) + if err != nil { + return nil, err + } + result.Project = r.Project + result.Location = r.Location + result.Name = r.Name + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizeReservationNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractReservationFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeleteReservation(ctx context.Context, r *Reservation) error { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("Reservation resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting Reservation...") + deleteOp := deleteReservationOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllReservation deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllReservation(ctx context.Context, project, location string, filter func(*Reservation) bool) error { + listObj, err := c.ListReservation(ctx, project, location) + if err != nil { + return err + } + + err = c.deleteAllReservation(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllReservation(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyReservation(ctx context.Context, rawDesired *Reservation, opts ...dcl.ApplyOption) (*Reservation, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + var resultNewState *Reservation + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyReservationHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyReservationHelper(c *Client, ctx context.Context, rawDesired *Reservation, opts ...dcl.ApplyOption) (*Reservation, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyReservation...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractReservationFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.reservationDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToReservationDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []reservationApiOperation + if create { + ops = append(ops, &createReservationOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyReservationDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyReservationDiff(c *Client, ctx context.Context, desired *Reservation, rawDesired *Reservation, ops []reservationApiOperation, opts ...dcl.ApplyOption) (*Reservation, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetReservation(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createReservationOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapReservation(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizeReservationNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizeReservationNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizeReservationDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractReservationFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractReservationFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffReservation(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation.yaml new file mode 100644 index 00000000000..90b52cb00ec --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation.yaml @@ -0,0 +1,131 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: BigqueryReservation/Reservation + description: The BigqueryReservation Reservation resource + x-dcl-struct-name: Reservation + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a Reservation + parameters: + - name: reservation + required: true + description: A full instance of a Reservation + apply: + description: The function used to apply information about a Reservation + parameters: + - name: reservation + required: true + description: A full instance of a Reservation + delete: + description: The function used to delete a Reservation + parameters: + - name: reservation + required: true + description: A full instance of a Reservation + deleteAll: + description: The function used to delete all Reservation + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + list: + description: The function used to list information about many Reservation + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string +components: + schemas: + Reservation: + title: Reservation + x-dcl-id: projects/{{project}}/locations/{{location}}/reservations/{{name}} + x-dcl-parent-container: project + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - name + - project + - location + properties: + creationTime: + type: string + format: date-time + x-dcl-go-name: CreationTime + readOnly: true + description: Output only. Creation time of the reservation. + x-kubernetes-immutable: true + ignoreIdleSlots: + type: boolean + x-dcl-go-name: IgnoreIdleSlots + description: If false, any query using this reservation will use idle slots + from other reservations within the same admin project. If true, a query + using this reservation will execute with the slot capacity specified above + at most. + location: + type: string + x-dcl-go-name: Location + description: The location for the resource + x-kubernetes-immutable: true + x-dcl-parameter: true + name: + type: string + x-dcl-go-name: Name + description: The resource name of the reservation. + x-kubernetes-immutable: true + x-dcl-parameter: true + x-dcl-has-long-form: true + project: + type: string + x-dcl-go-name: Project + description: The project for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-parameter: true + slotCapacity: + type: integer + format: int64 + x-dcl-go-name: SlotCapacity + description: Minimum slots available to this reservation. A slot is a unit + of computational power in BigQuery, and serves as the unit of parallelism. + Queries using this reservation might use more slots during runtime if + ignore_idle_slots is set to false. If the new reservation's slot capacity + exceed the parent's slot capacity or if total slot capacity of the new + reservation and its siblings exceeds the parent's slot capacity, the request + will fail with `google.rpc.Code.RESOURCE_EXHAUSTED`. + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. Last update time of the reservation. + x-kubernetes-immutable: true diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_internal.go new file mode 100644 index 00000000000..10c2ec2e94d --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_internal.go @@ -0,0 +1,758 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package bigqueryreservation + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func (r *Reservation) validate() error { + + if err := dcl.RequiredParameter(r.Name, "Name"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Project, "Project"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Location, "Location"); err != nil { + return err + } + return nil +} +func (r *Reservation) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://bigqueryreservation.googleapis.com/v1/", params) +} + +func (r *Reservation) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{name}}", nr.basePath(), userBasePath, params), nil +} + +func (r *Reservation) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations", nr.basePath(), userBasePath, params), nil + +} + +func (r *Reservation) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations?reservationId={{name}}", nr.basePath(), userBasePath, params), nil + +} + +func (r *Reservation) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{name}}", nr.basePath(), userBasePath, params), nil +} + +// reservationApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type reservationApiOperation interface { + do(context.Context, *Reservation, *Client) error +} + +// newUpdateReservationUpdateReservationRequest creates a request for an +// Reservation resource's UpdateReservation update type by filling in the update +// fields based on the intended state of the resource. +func newUpdateReservationUpdateReservationRequest(ctx context.Context, f *Reservation, c *Client) (map[string]interface{}, error) { + req := map[string]interface{}{} + res := f + _ = res + + if v := f.SlotCapacity; !dcl.IsEmptyValueIndirect(v) { + req["slotCapacity"] = v + } + if v := f.IgnoreIdleSlots; !dcl.IsEmptyValueIndirect(v) { + req["ignoreIdleSlots"] = v + } + return req, nil +} + +// marshalUpdateReservationUpdateReservationRequest converts the update into +// the final JSON request body. +func marshalUpdateReservationUpdateReservationRequest(c *Client, m map[string]interface{}) ([]byte, error) { + + return json.Marshal(m) +} + +type updateReservationUpdateReservationOperation struct { + // If the update operation has the REQUIRES_APPLY_OPTIONS trait, this will be populated. + // Usually it will be nil - this is to prevent us from accidentally depending on apply + // options, which should usually be unnecessary. + ApplyOptions []dcl.ApplyOption + FieldDiffs []*dcl.FieldDiff +} + +// do creates a request and sends it to the appropriate URL. In most operations, +// do will transcribe a subset of the resource into a request object and send a +// PUT request to a single URL. + +func (op *updateReservationUpdateReservationOperation) do(ctx context.Context, r *Reservation, c *Client) error { + _, err := c.GetReservation(ctx, r) + if err != nil { + return err + } + + u, err := r.updateURL(c.Config.BasePath, "UpdateReservation") + if err != nil { + return err + } + mask := dcl.UpdateMask(op.FieldDiffs) + u, err = dcl.AddQueryParams(u, map[string]string{"updateMask": mask}) + if err != nil { + return err + } + + req, err := newUpdateReservationUpdateReservationRequest(ctx, r, c) + if err != nil { + return err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created update: %#v", req) + body, err := marshalUpdateReservationUpdateReservationRequest(c, req) + if err != nil { + return err + } + _, err = dcl.SendRequest(ctx, c.Config, "PATCH", u, bytes.NewBuffer(body), c.Config.RetryProvider) + if err != nil { + return err + } + + return nil +} + +func (c *Client) listReservationRaw(ctx context.Context, r *Reservation, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != ReservationMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listReservationOperation struct { + Reservations []map[string]interface{} `json:"reservations"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listReservation(ctx context.Context, r *Reservation, pageToken string, pageSize int32) ([]*Reservation, string, error) { + b, err := c.listReservationRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listReservationOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*Reservation + for _, v := range m.Reservations { + res, err := unmarshalMapReservation(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Project = r.Project + res.Location = r.Location + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllReservation(ctx context.Context, f func(*Reservation) bool, resources []*Reservation) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeleteReservation(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deleteReservationOperation struct{} + +func (op *deleteReservationOperation) do(ctx context.Context, r *Reservation, c *Client) error { + r, err := c.GetReservation(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "Reservation not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetReservation checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + _, err = dcl.SendRequest(ctx, c.Config, "DELETE", u, body, c.Config.RetryProvider) + if err != nil { + return fmt.Errorf("failed to delete Reservation: %w", err) + } + + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetReservation(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil + } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createReservationOperation struct { + response map[string]interface{} +} + +func (op *createReservationOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createReservationOperation) do(ctx context.Context, r *Reservation, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + + o, err := dcl.ResponseBodyAsJSON(resp) + if err != nil { + return fmt.Errorf("error decoding response body into JSON: %w", err) + } + op.response = o + + if _, err := c.GetReservation(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + return nil +} + +func (c *Client) getReservationRaw(ctx context.Context, r *Reservation) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + return b, nil +} + +func (c *Client) reservationDiffsForRawDesired(ctx context.Context, rawDesired *Reservation, opts ...dcl.ApplyOption) (initial, desired *Reservation, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *Reservation + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*Reservation); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected Reservation, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetReservation(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a Reservation resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve Reservation resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that Reservation resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizeReservationDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for Reservation: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for Reservation: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractReservationFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizeReservationInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for Reservation: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizeReservationDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for Reservation: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffReservation(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizeReservationInitialState(rawInitial, rawDesired *Reservation) (*Reservation, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizeReservationDesiredState(rawDesired, rawInitial *Reservation, opts ...dcl.ApplyOption) (*Reservation, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + + return rawDesired, nil + } + canonicalDesired := &Reservation{} + if dcl.NameToSelfLink(rawDesired.Name, rawInitial.Name) { + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + if dcl.IsZeroValue(rawDesired.SlotCapacity) || (dcl.IsEmptyValueIndirect(rawDesired.SlotCapacity) && dcl.IsEmptyValueIndirect(rawInitial.SlotCapacity)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.SlotCapacity = rawInitial.SlotCapacity + } else { + canonicalDesired.SlotCapacity = rawDesired.SlotCapacity + } + if dcl.BoolCanonicalize(rawDesired.IgnoreIdleSlots, rawInitial.IgnoreIdleSlots) { + canonicalDesired.IgnoreIdleSlots = rawInitial.IgnoreIdleSlots + } else { + canonicalDesired.IgnoreIdleSlots = rawDesired.IgnoreIdleSlots + } + if dcl.NameToSelfLink(rawDesired.Project, rawInitial.Project) { + canonicalDesired.Project = rawInitial.Project + } else { + canonicalDesired.Project = rawDesired.Project + } + if dcl.NameToSelfLink(rawDesired.Location, rawInitial.Location) { + canonicalDesired.Location = rawInitial.Location + } else { + canonicalDesired.Location = rawDesired.Location + } + return canonicalDesired, nil +} + +func canonicalizeReservationNewState(c *Client, rawNew, rawDesired *Reservation) (*Reservation, error) { + + rawNew.Name = rawDesired.Name + + if dcl.IsEmptyValueIndirect(rawNew.SlotCapacity) && dcl.IsEmptyValueIndirect(rawDesired.SlotCapacity) { + rawNew.SlotCapacity = rawDesired.SlotCapacity + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.IgnoreIdleSlots) && dcl.IsEmptyValueIndirect(rawDesired.IgnoreIdleSlots) { + rawNew.IgnoreIdleSlots = rawDesired.IgnoreIdleSlots + } else { + if dcl.BoolCanonicalize(rawDesired.IgnoreIdleSlots, rawNew.IgnoreIdleSlots) { + rawNew.IgnoreIdleSlots = rawDesired.IgnoreIdleSlots + } + } + + if dcl.IsEmptyValueIndirect(rawNew.CreationTime) && dcl.IsEmptyValueIndirect(rawDesired.CreationTime) { + rawNew.CreationTime = rawDesired.CreationTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.UpdateTime) && dcl.IsEmptyValueIndirect(rawDesired.UpdateTime) { + rawNew.UpdateTime = rawDesired.UpdateTime + } else { + } + + rawNew.Project = rawDesired.Project + + rawNew.Location = rawDesired.Location + + return rawNew, nil +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffReservation(c *Client, desired, actual *Reservation, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.SlotCapacity, actual.SlotCapacity, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateReservationUpdateReservationOperation")}, fn.AddNest("SlotCapacity")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.IgnoreIdleSlots, actual.IgnoreIdleSlots, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateReservationUpdateReservationOperation")}, fn.AddNest("IgnoreIdleSlots")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CreationTime, actual.CreationTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreationTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Reservation) urlNormalized() *Reservation { + normalized := dcl.Copy(*r).(Reservation) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + return &normalized +} + +func (r *Reservation) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateReservation" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/reservations/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Reservation resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Reservation) marshal(c *Client) ([]byte, error) { + m, err := expandReservation(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Reservation: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalReservation decodes JSON responses into the Reservation resource schema. +func unmarshalReservation(b []byte, c *Client, res *Reservation) (*Reservation, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapReservation(m, c, res) +} + +func unmarshalMapReservation(m map[string]interface{}, c *Client, res *Reservation) (*Reservation, error) { + + flattened := flattenReservation(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandReservation expands Reservation into a JSON request object. +func expandReservation(c *Client, f *Reservation) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.SlotCapacity; dcl.ValueShouldBeSent(v) { + m["slotCapacity"] = v + } + if v := f.IgnoreIdleSlots; dcl.ValueShouldBeSent(v) { + m["ignoreIdleSlots"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenReservation flattens Reservation from a JSON request object into the +// Reservation type. +func flattenReservation(c *Client, i interface{}, res *Reservation) *Reservation { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Reservation{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.SlotCapacity = dcl.FlattenInteger(m["slotCapacity"]) + resultRes.IgnoreIdleSlots = dcl.FlattenBool(m["ignoreIdleSlots"]) + resultRes.CreationTime = dcl.FlattenString(m["creationTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + + return resultRes +} + +// This function returns a matcher that checks whether a serialized resource matches this resource +// in its parameters (as defined by the fields in a Get, which definitionally define resource +// identity). This is useful in extracting the element from a List call. +func (r *Reservation) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalReservation(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if nr.Project == nil && ncr.Project == nil { + c.Config.Logger.Info("Both Project fields null - considering equal.") + } else if nr.Project == nil || ncr.Project == nil { + c.Config.Logger.Info("Only one Project field is null - considering unequal.") + return false + } else if *nr.Project != *ncr.Project { + return false + } + if nr.Location == nil && ncr.Location == nil { + c.Config.Logger.Info("Both Location fields null - considering equal.") + } else if nr.Location == nil || ncr.Location == nil { + c.Config.Logger.Info("Only one Location field is null - considering unequal.") + return false + } else if *nr.Location != *ncr.Location { + return false + } + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + return true + } +} + +type reservationDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp reservationApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToReservationDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]reservationDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []reservationDiff + // For each operation name, create a reservationDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := reservationDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToReservationApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToReservationApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (reservationApiOperation, error) { + switch opName { + + case "updateReservationUpdateReservationOperation": + return &updateReservationUpdateReservationOperation{FieldDiffs: fieldDiffs}, nil + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractReservationFields(r *Reservation) error { + return nil +} + +func postReadExtractReservationFields(r *Reservation) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_schema.go new file mode 100644 index 00000000000..c72b0ed40d4 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_schema.go @@ -0,0 +1,174 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package bigqueryreservation + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLReservationSchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "BigqueryReservation/Reservation", + Description: "The BigqueryReservation Reservation resource", + StructName: "Reservation", + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a Reservation", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "reservation", + Required: true, + Description: "A full instance of a Reservation", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a Reservation", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "reservation", + Required: true, + Description: "A full instance of a Reservation", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a Reservation", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "reservation", + Required: true, + Description: "A full instance of a Reservation", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all Reservation", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many Reservation", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "Reservation": &dcl.Component{ + Title: "Reservation", + ID: "projects/{{project}}/locations/{{location}}/reservations/{{name}}", + ParentContainer: "project", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "name", + "project", + "location", + }, + Properties: map[string]*dcl.Property{ + "creationTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "CreationTime", + ReadOnly: true, + Description: "Output only. Creation time of the reservation.", + Immutable: true, + }, + "ignoreIdleSlots": &dcl.Property{ + Type: "boolean", + GoName: "IgnoreIdleSlots", + Description: "If false, any query using this reservation will use idle slots from other reservations within the same admin project. If true, a query using this reservation will execute with the slot capacity specified above at most.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "The location for the resource", + Immutable: true, + Parameter: true, + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "The resource name of the reservation.", + Immutable: true, + Parameter: true, + HasLongForm: true, + }, + "project": &dcl.Property{ + Type: "string", + GoName: "Project", + Description: "The project for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "slotCapacity": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "SlotCapacity", + Description: "Minimum slots available to this reservation. A slot is a unit of computational power in BigQuery, and serves as the unit of parallelism. Queries using this reservation might use more slots during runtime if ignore_idle_slots is set to false. If the new reservation's slot capacity exceed the parent's slot capacity or if total slot capacity of the new reservation and its siblings exceeds the parent's slot capacity, the request will fail with `google.rpc.Code.RESOURCE_EXHAUSTED`.", + }, + "updateTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "UpdateTime", + ReadOnly: true, + Description: "Output only. Last update time of the reservation.", + Immutable: true, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_yaml_embed.go new file mode 100644 index 00000000000..36414b02cf3 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation/reservation_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package bigqueryreservation -var YAML_reservation blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/bigqueryreservation/reservation.yaml + +package bigqueryreservation + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/bigqueryreservation/reservation.yaml +var YAML_reservation = []byte("info:\n title: BigqueryReservation/Reservation\n description: The BigqueryReservation Reservation resource\n x-dcl-struct-name: Reservation\n x-dcl-has-iam: false\npaths:\n get:\n description: The function used to get information about a Reservation\n parameters:\n - name: reservation\n required: true\n description: A full instance of a Reservation\n apply:\n description: The function used to apply information about a Reservation\n parameters:\n - name: reservation\n required: true\n description: A full instance of a Reservation\n delete:\n description: The function used to delete a Reservation\n parameters:\n - name: reservation\n required: true\n description: A full instance of a Reservation\n deleteAll:\n description: The function used to delete all Reservation\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Reservation\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Reservation:\n title: Reservation\n x-dcl-id: projects/{{project}}/locations/{{location}}/reservations/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n creationTime:\n type: string\n format: date-time\n x-dcl-go-name: CreationTime\n readOnly: true\n description: Output only. Creation time of the reservation.\n x-kubernetes-immutable: true\n ignoreIdleSlots:\n type: boolean\n x-dcl-go-name: IgnoreIdleSlots\n description: If false, any query using this reservation will use idle slots\n from other reservations within the same admin project. If true, a query\n using this reservation will execute with the slot capacity specified above\n at most.\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: The resource name of the reservation.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n slotCapacity:\n type: integer\n format: int64\n x-dcl-go-name: SlotCapacity\n description: Minimum slots available to this reservation. A slot is a unit\n of computational power in BigQuery, and serves as the unit of parallelism.\n Queries using this reservation might use more slots during runtime if\n ignore_idle_slots is set to false. If the new reservation's slot capacity\n exceed the parent's slot capacity or if total slot capacity of the new\n reservation and its siblings exceeds the parent's slot capacity, the request\n will fail with `google.rpc.Code.RESOURCE_EXHAUSTED`.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Last update time of the reservation.\n x-kubernetes-immutable: true\n") + +// 3969 bytes +// MD5: 5dcd0c5fcaa060ad41c6747b20b3a527 diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/client.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/client.go new file mode 100644 index 00000000000..c4c44d298db --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/client.go @@ -0,0 +1,32 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// Package orgpolicy defines operations in the declarative SDK. +package orgpolicy + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +// The Client is the base struct of all operations. This will receive the +// Get, Delete, List, and Apply operations on all resources. +type Client struct { + Config *dcl.Config +} + +// NewClient creates a client that retries all operations a few times each. +func NewClient(c *dcl.Config) *Client { + return &Client{ + Config: c, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/orgpolicy_utils.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/orgpolicy_utils.go new file mode 100644 index 00000000000..b4501a05186 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/orgpolicy_utils.go @@ -0,0 +1,125 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// Package orgpolicy defines types and methods for working with orgpolicy GCP resources. +package orgpolicy + +import ( + "bytes" + "context" + "fmt" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func expandPolicyName(_ *Client, name *string, res *Policy) (*string, error) { + nameParts := strings.Split(dcl.ValueOrEmptyString(name), "/") + if len(nameParts) == 4 { + fullName := strings.Join(nameParts, "/") + return &fullName, nil + } + shortName := nameParts[len(nameParts)-1] + fullName := fmt.Sprintf("%s/policies/%s", dcl.ValueOrEmptyString(res.Parent), shortName) + return &fullName, nil +} + +func equalsPolicyName(m, n *string) bool { + if m == nil && n == nil { + return true + } + if m == nil || n == nil { + return false + } + return *dcl.SelfLinkToName(m) == *dcl.SelfLinkToName(n) +} + +// Compares two values of policy name. Custom diff function required because API returns project numbers. +func canonicalizePolicyName(m, n interface{}) bool { + mString, ok := m.(*string) + if !ok { + return false + } + nString, ok := n.(*string) + if !ok { + return false + } + return equalsPolicyName(mString, nString) +} + +func equalsPolicyRulesConditionExpression(m, n *string) bool { + if m == nil && n == nil { + return true + } + if m == nil || n == nil { + return false + } + mReplaced := strings.ReplaceAll(strings.ReplaceAll(*m, "Labels", "TagId"), "label", "tag") + nReplaced := strings.ReplaceAll(strings.ReplaceAll(*n, "Labels", "TagId"), "label", "tag") + return mReplaced == nReplaced +} + +// Compares two values of policy rules condition expression. Custom diff function required due to API substitutions. +func canonicalizePolicyRulesConditionExpression(m, n interface{}) bool { + mString, ok := m.(*string) + if !ok { + return false + } + nString, ok := n.(*string) + if !ok { + return false + } + return equalsPolicyRulesConditionExpression(mString, nString) +} + +// Update has a custom method because the update mask needs to be in the request body. +func (op *updatePolicyUpdatePolicyOperation) do(ctx context.Context, r *Policy, c *Client) error { + _, err := c.GetPolicy(ctx, r) + if err != nil { + return err + } + + u, err := r.updateURL(c.Config.BasePath, "UpdatePolicy") + if err != nil { + return err + } + + updateMask := "*" + if (r.Spec != nil && !r.Spec.Empty()) && (r.DryRunSpec == nil || r.DryRunSpec.Empty()) { + updateMask = "policy.spec" + } + if (r.DryRunSpec != nil && !r.DryRunSpec.Empty()) && (r.Spec == nil || r.Spec.Empty()) { + updateMask = "policy.dryRunSpec" + } + u, err = dcl.AddQueryParams(u, map[string]string{"updateMask": updateMask}) + if err != nil { + return err + } + + req, err := newUpdatePolicyUpdatePolicyRequest(ctx, r, c) + if err != nil { + return err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created update: %#v", req) + body, err := marshalUpdatePolicyUpdatePolicyRequest(c, req) + if err != nil { + return err + } + _, err = dcl.SendRequest(ctx, c.Config, "PATCH", u, bytes.NewBuffer(body), c.Config.RetryProvider) + if err != nil { + return err + } + + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy.go new file mode 100644 index 00000000000..2452bcb7898 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy.go @@ -0,0 +1,837 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package orgpolicy + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type Policy struct { + Name *string `json:"name"` + Spec *PolicySpec `json:"spec"` + DryRunSpec *PolicyDryRunSpec `json:"dryRunSpec"` + Etag *string `json:"etag"` + Parent *string `json:"parent"` +} + +func (r *Policy) String() string { + return dcl.SprintResource(r) +} + +type PolicySpec struct { + empty bool `json:"-"` + Etag *string `json:"etag"` + UpdateTime *string `json:"updateTime"` + Rules []PolicySpecRules `json:"rules"` + InheritFromParent *bool `json:"inheritFromParent"` + Reset *bool `json:"reset"` +} + +type jsonPolicySpec PolicySpec + +func (r *PolicySpec) UnmarshalJSON(data []byte) error { + var res jsonPolicySpec + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicySpec + } else { + + r.Etag = res.Etag + + r.UpdateTime = res.UpdateTime + + r.Rules = res.Rules + + r.InheritFromParent = res.InheritFromParent + + r.Reset = res.Reset + + } + return nil +} + +// This object is used to assert a desired state where this PolicySpec is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicySpec *PolicySpec = &PolicySpec{empty: true} + +func (r *PolicySpec) Empty() bool { + return r.empty +} + +func (r *PolicySpec) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicySpec) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicySpecRules struct { + empty bool `json:"-"` + Values *PolicySpecRulesValues `json:"values"` + AllowAll *bool `json:"allowAll"` + DenyAll *bool `json:"denyAll"` + Enforce *bool `json:"enforce"` + Condition *PolicySpecRulesCondition `json:"condition"` +} + +type jsonPolicySpecRules PolicySpecRules + +func (r *PolicySpecRules) UnmarshalJSON(data []byte) error { + var res jsonPolicySpecRules + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicySpecRules + } else { + + r.Values = res.Values + + r.AllowAll = res.AllowAll + + r.DenyAll = res.DenyAll + + r.Enforce = res.Enforce + + r.Condition = res.Condition + + } + return nil +} + +// This object is used to assert a desired state where this PolicySpecRules is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicySpecRules *PolicySpecRules = &PolicySpecRules{empty: true} + +func (r *PolicySpecRules) Empty() bool { + return r.empty +} + +func (r *PolicySpecRules) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicySpecRules) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicySpecRulesValues struct { + empty bool `json:"-"` + AllowedValues []string `json:"allowedValues"` + DeniedValues []string `json:"deniedValues"` +} + +type jsonPolicySpecRulesValues PolicySpecRulesValues + +func (r *PolicySpecRulesValues) UnmarshalJSON(data []byte) error { + var res jsonPolicySpecRulesValues + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicySpecRulesValues + } else { + + r.AllowedValues = res.AllowedValues + + r.DeniedValues = res.DeniedValues + + } + return nil +} + +// This object is used to assert a desired state where this PolicySpecRulesValues is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicySpecRulesValues *PolicySpecRulesValues = &PolicySpecRulesValues{empty: true} + +func (r *PolicySpecRulesValues) Empty() bool { + return r.empty +} + +func (r *PolicySpecRulesValues) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicySpecRulesValues) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicySpecRulesCondition struct { + empty bool `json:"-"` + Expression *string `json:"expression"` + Title *string `json:"title"` + Description *string `json:"description"` + Location *string `json:"location"` +} + +type jsonPolicySpecRulesCondition PolicySpecRulesCondition + +func (r *PolicySpecRulesCondition) UnmarshalJSON(data []byte) error { + var res jsonPolicySpecRulesCondition + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicySpecRulesCondition + } else { + + r.Expression = res.Expression + + r.Title = res.Title + + r.Description = res.Description + + r.Location = res.Location + + } + return nil +} + +// This object is used to assert a desired state where this PolicySpecRulesCondition is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicySpecRulesCondition *PolicySpecRulesCondition = &PolicySpecRulesCondition{empty: true} + +func (r *PolicySpecRulesCondition) Empty() bool { + return r.empty +} + +func (r *PolicySpecRulesCondition) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicySpecRulesCondition) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicyDryRunSpec struct { + empty bool `json:"-"` + Etag *string `json:"etag"` + UpdateTime *string `json:"updateTime"` + Rules []PolicyDryRunSpecRules `json:"rules"` + InheritFromParent *bool `json:"inheritFromParent"` + Reset *bool `json:"reset"` +} + +type jsonPolicyDryRunSpec PolicyDryRunSpec + +func (r *PolicyDryRunSpec) UnmarshalJSON(data []byte) error { + var res jsonPolicyDryRunSpec + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicyDryRunSpec + } else { + + r.Etag = res.Etag + + r.UpdateTime = res.UpdateTime + + r.Rules = res.Rules + + r.InheritFromParent = res.InheritFromParent + + r.Reset = res.Reset + + } + return nil +} + +// This object is used to assert a desired state where this PolicyDryRunSpec is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicyDryRunSpec *PolicyDryRunSpec = &PolicyDryRunSpec{empty: true} + +func (r *PolicyDryRunSpec) Empty() bool { + return r.empty +} + +func (r *PolicyDryRunSpec) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicyDryRunSpec) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicyDryRunSpecRules struct { + empty bool `json:"-"` + Values *PolicyDryRunSpecRulesValues `json:"values"` + AllowAll *bool `json:"allowAll"` + DenyAll *bool `json:"denyAll"` + Enforce *bool `json:"enforce"` + Condition *PolicyDryRunSpecRulesCondition `json:"condition"` +} + +type jsonPolicyDryRunSpecRules PolicyDryRunSpecRules + +func (r *PolicyDryRunSpecRules) UnmarshalJSON(data []byte) error { + var res jsonPolicyDryRunSpecRules + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicyDryRunSpecRules + } else { + + r.Values = res.Values + + r.AllowAll = res.AllowAll + + r.DenyAll = res.DenyAll + + r.Enforce = res.Enforce + + r.Condition = res.Condition + + } + return nil +} + +// This object is used to assert a desired state where this PolicyDryRunSpecRules is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicyDryRunSpecRules *PolicyDryRunSpecRules = &PolicyDryRunSpecRules{empty: true} + +func (r *PolicyDryRunSpecRules) Empty() bool { + return r.empty +} + +func (r *PolicyDryRunSpecRules) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicyDryRunSpecRules) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicyDryRunSpecRulesValues struct { + empty bool `json:"-"` + AllowedValues []string `json:"allowedValues"` + DeniedValues []string `json:"deniedValues"` +} + +type jsonPolicyDryRunSpecRulesValues PolicyDryRunSpecRulesValues + +func (r *PolicyDryRunSpecRulesValues) UnmarshalJSON(data []byte) error { + var res jsonPolicyDryRunSpecRulesValues + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicyDryRunSpecRulesValues + } else { + + r.AllowedValues = res.AllowedValues + + r.DeniedValues = res.DeniedValues + + } + return nil +} + +// This object is used to assert a desired state where this PolicyDryRunSpecRulesValues is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicyDryRunSpecRulesValues *PolicyDryRunSpecRulesValues = &PolicyDryRunSpecRulesValues{empty: true} + +func (r *PolicyDryRunSpecRulesValues) Empty() bool { + return r.empty +} + +func (r *PolicyDryRunSpecRulesValues) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicyDryRunSpecRulesValues) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type PolicyDryRunSpecRulesCondition struct { + empty bool `json:"-"` + Expression *string `json:"expression"` + Title *string `json:"title"` + Description *string `json:"description"` + Location *string `json:"location"` +} + +type jsonPolicyDryRunSpecRulesCondition PolicyDryRunSpecRulesCondition + +func (r *PolicyDryRunSpecRulesCondition) UnmarshalJSON(data []byte) error { + var res jsonPolicyDryRunSpecRulesCondition + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyPolicyDryRunSpecRulesCondition + } else { + + r.Expression = res.Expression + + r.Title = res.Title + + r.Description = res.Description + + r.Location = res.Location + + } + return nil +} + +// This object is used to assert a desired state where this PolicyDryRunSpecRulesCondition is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyPolicyDryRunSpecRulesCondition *PolicyDryRunSpecRulesCondition = &PolicyDryRunSpecRulesCondition{empty: true} + +func (r *PolicyDryRunSpecRulesCondition) Empty() bool { + return r.empty +} + +func (r *PolicyDryRunSpecRulesCondition) String() string { + return dcl.SprintResource(r) +} + +func (r *PolicyDryRunSpecRulesCondition) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *Policy) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "org_policy", + Type: "Policy", + Version: "orgpolicy", + } +} + +func (r *Policy) ID() (string, error) { + if err := extractPolicyFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "spec": dcl.ValueOrEmptyString(nr.Spec), + "dry_run_spec": dcl.ValueOrEmptyString(nr.DryRunSpec), + "etag": dcl.ValueOrEmptyString(nr.Etag), + "parent": dcl.ValueOrEmptyString(nr.Parent), + } + return dcl.Nprintf("{{parent}}/policies/{{name}}", params), nil +} + +const PolicyMaxPage = -1 + +type PolicyList struct { + Items []*Policy + + nextToken string + + pageSize int32 + + resource *Policy +} + +func (l *PolicyList) HasNext() bool { + return l.nextToken != "" +} + +func (l *PolicyList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listPolicy(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListPolicy(ctx context.Context, parent string) (*PolicyList, error) { + ctx = dcl.ContextWithRequestID(ctx) + c = NewClient(c.Config.Clone(dcl.WithCodeRetryability(map[int]dcl.Retryability{ + 403: dcl.Retryability{ + Retryable: true, + Pattern: "Permission 'orgpolicy\\.policy\\.[a-z]*' denied on resource '//orgpolicy\\.googleapis\\.com/(projects|folders)/[a-z0-9-]*/policies/[a-zA-Z.]*' \\(or it may not exist\\)\\.", + Timeout: 0, + }, + }))) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListPolicyWithMaxResults(ctx, parent, PolicyMaxPage) + +} + +func (c *Client) ListPolicyWithMaxResults(ctx context.Context, parent string, pageSize int32) (*PolicyList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &Policy{ + Parent: &parent, + } + items, token, err := c.listPolicy(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &PolicyList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetPolicy(ctx context.Context, r *Policy) (*Policy, error) { + ctx = dcl.ContextWithRequestID(ctx) + c = NewClient(c.Config.Clone(dcl.WithCodeRetryability(map[int]dcl.Retryability{ + 403: dcl.Retryability{ + Retryable: true, + Pattern: "Permission 'orgpolicy\\.policy\\.[a-z]*' denied on resource '//orgpolicy\\.googleapis\\.com/(projects|folders)/[a-z0-9-]*/policies/[a-zA-Z.]*' \\(or it may not exist\\)\\.", + Timeout: 0, + }, + }))) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractPolicyFields(r) + + b, err := c.getPolicyRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalPolicy(b, c, r) + if err != nil { + return nil, err + } + result.Parent = r.Parent + result.Name = r.Name + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizePolicyNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractPolicyFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeletePolicy(ctx context.Context, r *Policy) error { + ctx = dcl.ContextWithRequestID(ctx) + c = NewClient(c.Config.Clone(dcl.WithCodeRetryability(map[int]dcl.Retryability{ + 403: dcl.Retryability{ + Retryable: true, + Pattern: "Permission 'orgpolicy\\.policy\\.[a-z]*' denied on resource '//orgpolicy\\.googleapis\\.com/(projects|folders)/[a-z0-9-]*/policies/[a-zA-Z.]*' \\(or it may not exist\\)\\.", + Timeout: 0, + }, + }))) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("Policy resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting Policy...") + deleteOp := deletePolicyOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllPolicy deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllPolicy(ctx context.Context, parent string, filter func(*Policy) bool) error { + listObj, err := c.ListPolicy(ctx, parent) + if err != nil { + return err + } + + err = c.deleteAllPolicy(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllPolicy(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyPolicy(ctx context.Context, rawDesired *Policy, opts ...dcl.ApplyOption) (*Policy, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + c = NewClient(c.Config.Clone(dcl.WithCodeRetryability(map[int]dcl.Retryability{ + 403: dcl.Retryability{ + Retryable: true, + Pattern: "Permission 'orgpolicy\\.policy\\.[a-z]*' denied on resource '//orgpolicy\\.googleapis\\.com/(projects|folders)/[a-z0-9-]*/policies/[a-zA-Z.]*' \\(or it may not exist\\)\\.", + Timeout: 0, + }, + }))) + var resultNewState *Policy + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyPolicyHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyPolicyHelper(c *Client, ctx context.Context, rawDesired *Policy, opts ...dcl.ApplyOption) (*Policy, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyPolicy...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractPolicyFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.policyDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToPolicyDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []policyApiOperation + if create { + ops = append(ops, &createPolicyOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyPolicyDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyPolicyDiff(c *Client, ctx context.Context, desired *Policy, rawDesired *Policy, ops []policyApiOperation, opts ...dcl.ApplyOption) (*Policy, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetPolicy(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createPolicyOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapPolicy(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizePolicyNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizePolicyNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizePolicyDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractPolicyFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractPolicyFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffPolicy(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy.yaml new file mode 100644 index 00000000000..0165e0ae87a --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy.yaml @@ -0,0 +1,423 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: OrgPolicy/Policy + description: An organization policy gives you programmatic control over your organization's + cloud resources. Using Organization Policies, you will be able to configure constraints + across your entire resource hierarchy. + x-dcl-struct-name: Policy + x-dcl-has-iam: false + x-dcl-ref: + text: REST API + url: https://cloud.google.com/resource-manager/docs/reference/orgpolicy/rest/v2/organizations.policies + x-dcl-guides: + - text: Understanding Org Policy concepts + url: https://cloud.google.com/resource-manager/docs/organization-policy/overview + - text: The resource hierarchy + url: https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy + - text: All valid constraints + url: https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints +paths: + get: + description: The function used to get information about a Policy + parameters: + - name: policy + required: true + description: A full instance of a Policy + apply: + description: The function used to apply information about a Policy + parameters: + - name: policy + required: true + description: A full instance of a Policy + delete: + description: The function used to delete a Policy + parameters: + - name: policy + required: true + description: A full instance of a Policy + deleteAll: + description: The function used to delete all Policy + parameters: + - name: parent + required: true + schema: + type: string + list: + description: The function used to list information about many Policy + parameters: + - name: parent + required: true + schema: + type: string +components: + schemas: + Policy: + title: Policy + x-dcl-id: '{{parent}}/policies/{{name}}' + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - name + - parent + properties: + dryRunSpec: + type: object + x-dcl-go-name: DryRunSpec + x-dcl-go-type: PolicyDryRunSpec + description: Dry-run policy. Audit-only policy, can be used to monitor how + the policy would have impacted the existing and future resources if it's + enforced. + properties: + etag: + type: string + x-dcl-go-name: Etag + readOnly: true + description: An opaque tag indicating the current version of the policy, + used for concurrency control. This field is ignored if used in a `CreatePolicy` + request. When the policy` is returned from either a `GetPolicy` or + a `ListPolicies` request, this `etag` indicates the version of the + current policy to use when executing a read-modify-write loop. When + the policy is returned from a `GetEffectivePolicy` request, the `etag` + will be unset. + inheritFromParent: + type: boolean + x-dcl-go-name: InheritFromParent + description: Determines the inheritance behavior for this policy. If + `inherit_from_parent` is true, policy rules set higher up in the hierarchy + (up to the closest root) are inherited and present in the effective + policy. If it is false, then no rules are inherited, and this policy + becomes the new root for evaluation. This field can be set only for + policies which configure list constraints. + reset: + type: boolean + x-dcl-go-name: Reset + description: Ignores policies set above this resource and restores the + `constraint_default` enforcement behavior of the specific constraint + at this resource. This field can be set in policies for either list + or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` + must be set to false. + rules: + type: array + x-dcl-go-name: Rules + description: 'In policies for boolean constraints, the following requirements + apply: - There must be one and only one policy rule where condition + is unset. - Boolean policy rules with conditions must set `enforced` + to the opposite of the policy rule without a condition. - During policy + evaluation, policy rules with conditions that are true for a target + resource take precedence.' + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: PolicyDryRunSpecRules + properties: + allowAll: + type: boolean + x-dcl-go-name: AllowAll + description: Setting this to `"TRUE"` means that all values are + allowed. This field can be set only in policies for list constraints. + x-dcl-conflicts: + - values + - denyAll + - enforce + condition: + type: object + x-dcl-go-name: Condition + x-dcl-go-type: PolicyDryRunSpecRulesCondition + description: 'A condition which determines whether this rule is + used in the evaluation of the policy. When set, the `expression` + field in the `Expr'' must include from 1 to 10 subexpressions, + joined by the "||" or "&&" operators. Each subexpression must + be of the form "resource.matchTag(''/tag_key_short_name, ''tag_value_short_name'')". + or "resource.matchTagId(''tagKeys/key_id'', ''tagValues/value_id'')". + where key_name and value_name are the resource names for Label + Keys and Values. These names are available from the Tag Manager + Service. An example expression is: "resource.matchTag(''123456789/environment, + ''prod'')". or "resource.matchTagId(''tagKeys/123'', ''tagValues/456'')".' + properties: + description: + type: string + x-dcl-go-name: Description + description: Optional. Description of the expression. This + is a longer text which describes the expression, e.g. when + hovered over it in a UI. + expression: + type: string + x-dcl-go-name: Expression + description: Textual representation of an expression in Common + Expression Language syntax. + location: + type: string + x-dcl-go-name: Location + description: Optional. String indicating the location of the + expression for error reporting, e.g. a file name and a position + in the file. + title: + type: string + x-dcl-go-name: Title + description: Optional. Title for the expression, i.e. a short + string describing its purpose. This can be used e.g. in + UIs which allow to enter the expression. + denyAll: + type: boolean + x-dcl-go-name: DenyAll + description: Setting this to `"TRUE"` means that all values are + denied. This field can be set only in policies for list constraints. + x-dcl-conflicts: + - values + - allowAll + - enforce + enforce: + type: boolean + x-dcl-go-name: Enforce + description: If `"TRUE"`, then the policy is enforced. If `"FALSE"`, + then any configuration is acceptable. This field can be set + only in policies for boolean constraints. + x-dcl-conflicts: + - values + - allowAll + - denyAll + values: + type: object + x-dcl-go-name: Values + x-dcl-go-type: PolicyDryRunSpecRulesValues + description: List of values to be used for this policy rule. This + field can be set only in policies for list constraints. + x-dcl-conflicts: + - allowAll + - denyAll + - enforce + properties: + allowedValues: + type: array + x-dcl-go-name: AllowedValues + description: List of values allowed at this resource. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + deniedValues: + type: array + x-dcl-go-name: DeniedValues + description: List of values denied at this resource. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time stamp this was previously updated. + This represents the last time a call to `CreatePolicy` or `UpdatePolicy` + was made for that policy. + etag: + type: string + x-dcl-go-name: Etag + readOnly: true + description: Optional. An opaque tag indicating the current state of the + policy, used for concurrency control. This 'etag' is computed by the server + based on the value of other fields, and may be sent on update and delete + requests to ensure the client has an up-to-date value before proceeding. + x-kubernetes-immutable: true + name: + type: string + x-dcl-go-name: Name + description: 'Immutable. The resource name of the Policy. Must be one of + the following forms, where constraint_name is the name of the constraint + which this Policy configures: * `projects/{project_number}/policies/{constraint_name}` + * `folders/{folder_id}/policies/{constraint_name}` * `organizations/{organization_id}/policies/{constraint_name}` + For example, "projects/123/policies/compute.disableSerialPortAccess". + Note: `projects/{project_id}/policies/{constraint_name}` is also an acceptable + name for API requests, but responses will return the name using the equivalent + project number.' + x-kubernetes-immutable: true + x-dcl-has-long-form: true + parent: + type: string + x-dcl-go-name: Parent + description: The parent of the resource. + x-kubernetes-immutable: true + x-dcl-forward-slash-allowed: true + x-dcl-references: + - resource: Cloudresourcemanager/Folder + field: name + parent: true + - resource: Cloudresourcemanager/Organization + field: name + parent: true + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-parameter: true + spec: + type: object + x-dcl-go-name: Spec + x-dcl-go-type: PolicySpec + description: Basic information about the Organization Policy. + properties: + etag: + type: string + x-dcl-go-name: Etag + readOnly: true + description: An opaque tag indicating the current version of the `Policy`, + used for concurrency control. This field is ignored if used in a `CreatePolicy` + request. When the `Policy` is returned from either a `GetPolicy` or + a `ListPolicies` request, this `etag` indicates the version of the + current `Policy` to use when executing a read-modify-write loop. When + the `Policy` is returned from a `GetEffectivePolicy` request, the + `etag` will be unset. + inheritFromParent: + type: boolean + x-dcl-go-name: InheritFromParent + description: Determines the inheritance behavior for this `Policy`. + If `inherit_from_parent` is true, PolicyRules set higher up in the + hierarchy (up to the closest root) are inherited and present in the + effective policy. If it is false, then no rules are inherited, and + this Policy becomes the new root for evaluation. This field can be + set only for Policies which configure list constraints. + reset: + type: boolean + x-dcl-go-name: Reset + description: Ignores policies set above this resource and restores the + `constraint_default` enforcement behavior of the specific `Constraint` + at this resource. This field can be set in policies for either list + or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` + must be set to false. + rules: + type: array + x-dcl-go-name: Rules + description: 'Up to 10 PolicyRules are allowed. In Policies for boolean + constraints, the following requirements apply: - There must be one + and only one PolicyRule where condition is unset. - BooleanPolicyRules + with conditions must set `enforced` to the opposite of the PolicyRule + without a condition. - During policy evaluation, PolicyRules with + conditions that are true for a target resource take precedence.' + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: PolicySpecRules + properties: + allowAll: + type: boolean + x-dcl-go-name: AllowAll + description: Setting this to `"TRUE"` means that all values are + allowed. This field can be set only in Policies for list constraints. + x-dcl-conflicts: + - values + - denyAll + - enforce + condition: + type: object + x-dcl-go-name: Condition + x-dcl-go-type: PolicySpecRulesCondition + description: 'A condition which determines whether this rule is + used in the evaluation of the policy. When set, the `expression` + field in the `Expr'' must include from 1 to 10 subexpressions, + joined by the "||" or "&&" operators. Each subexpression must + be of the form "resource.matchTag(''/tag_key_short_name, ''tag_value_short_name'')". + or "resource.matchTagId(''tagKeys/key_id'', ''tagValues/value_id'')". + where key_name and value_name are the resource names for Label + Keys and Values. These names are available from the Tag Manager + Service. An example expression is: "resource.matchTag(''123456789/environment, + ''prod'')". or "resource.matchTagId(''tagKeys/123'', ''tagValues/456'')".' + properties: + description: + type: string + x-dcl-go-name: Description + description: Optional. Description of the expression. This + is a longer text which describes the expression, e.g. when + hovered over it in a UI. + expression: + type: string + x-dcl-go-name: Expression + description: Textual representation of an expression in Common + Expression Language syntax. + location: + type: string + x-dcl-go-name: Location + description: Optional. String indicating the location of the + expression for error reporting, e.g. a file name and a position + in the file. + title: + type: string + x-dcl-go-name: Title + description: Optional. Title for the expression, i.e. a short + string describing its purpose. This can be used e.g. in + UIs which allow to enter the expression. + denyAll: + type: boolean + x-dcl-go-name: DenyAll + description: Setting this to `"TRUE"` means that all values are + denied. This field can be set only in Policies for list constraints. + x-dcl-conflicts: + - values + - allowAll + - enforce + enforce: + type: boolean + x-dcl-go-name: Enforce + description: If `"TRUE"`, then the `Policy` is enforced. If `"FALSE"`, + then any configuration is acceptable. This field can be set + only in Policies for boolean constraints. + x-dcl-conflicts: + - values + - allowAll + - denyAll + values: + type: object + x-dcl-go-name: Values + x-dcl-go-type: PolicySpecRulesValues + description: List of values to be used for this PolicyRule. This + field can be set only in Policies for list constraints. + x-dcl-conflicts: + - allowAll + - denyAll + - enforce + properties: + allowedValues: + type: array + x-dcl-go-name: AllowedValues + description: List of values allowed at this resource. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + deniedValues: + type: array + x-dcl-go-name: DeniedValues + description: List of values denied at this resource. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time stamp this was previously updated. + This represents the last time a call to `CreatePolicy` or `UpdatePolicy` + was made for that `Policy`. diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_internal.go new file mode 100644 index 00000000000..6bb32a1850a --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_internal.go @@ -0,0 +1,3485 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package orgpolicy + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func (r *Policy) validate() error { + + if err := dcl.Required(r, "name"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Parent, "Parent"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Spec) { + if err := r.Spec.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.DryRunSpec) { + if err := r.DryRunSpec.validate(); err != nil { + return err + } + } + return nil +} +func (r *PolicySpec) validate() error { + return nil +} +func (r *PolicySpecRules) validate() error { + if err := dcl.ValidateAtMostOneOfFieldsSet([]string{"Values", "AllowAll", "DenyAll", "Enforce"}, r.Values, r.AllowAll, r.DenyAll, r.Enforce); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Values) { + if err := r.Values.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.Condition) { + if err := r.Condition.validate(); err != nil { + return err + } + } + return nil +} +func (r *PolicySpecRulesValues) validate() error { + return nil +} +func (r *PolicySpecRulesCondition) validate() error { + return nil +} +func (r *PolicyDryRunSpec) validate() error { + return nil +} +func (r *PolicyDryRunSpecRules) validate() error { + if err := dcl.ValidateAtMostOneOfFieldsSet([]string{"Values", "AllowAll", "DenyAll", "Enforce"}, r.Values, r.AllowAll, r.DenyAll, r.Enforce); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Values) { + if err := r.Values.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.Condition) { + if err := r.Condition.validate(); err != nil { + return err + } + } + return nil +} +func (r *PolicyDryRunSpecRulesValues) validate() error { + return nil +} +func (r *PolicyDryRunSpecRulesCondition) validate() error { + return nil +} +func (r *Policy) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://orgpolicy.googleapis.com/v2/", params) +} + +func (r *Policy) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "parent": dcl.ValueOrEmptyString(nr.Parent), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("{{parent}}/policies/{{name}}", nr.basePath(), userBasePath, params), nil +} + +func (r *Policy) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "parent": dcl.ValueOrEmptyString(nr.Parent), + } + return dcl.URL("{{parent}}/policies", nr.basePath(), userBasePath, params), nil + +} + +func (r *Policy) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "parent": dcl.ValueOrEmptyString(nr.Parent), + } + return dcl.URL("{{parent}}/policies", nr.basePath(), userBasePath, params), nil + +} + +func (r *Policy) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "parent": dcl.ValueOrEmptyString(nr.Parent), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("{{parent}}/policies/{{name}}", nr.basePath(), userBasePath, params), nil +} + +// policyApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type policyApiOperation interface { + do(context.Context, *Policy, *Client) error +} + +// newUpdatePolicyUpdatePolicyRequest creates a request for an +// Policy resource's UpdatePolicy update type by filling in the update +// fields based on the intended state of the resource. +func newUpdatePolicyUpdatePolicyRequest(ctx context.Context, f *Policy, c *Client) (map[string]interface{}, error) { + req := map[string]interface{}{} + res := f + _ = res + + if v, err := expandPolicySpec(c, f.Spec, res); err != nil { + return nil, fmt.Errorf("error expanding Spec into spec: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["spec"] = v + } + if v, err := expandPolicyDryRunSpec(c, f.DryRunSpec, res); err != nil { + return nil, fmt.Errorf("error expanding DryRunSpec into dryRunSpec: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["dryRunSpec"] = v + } + b, err := c.getPolicyRaw(ctx, f) + if err != nil { + return nil, err + } + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + rawEtag, err := dcl.GetMapEntry( + m, + []string{"etag"}, + ) + if err != nil { + c.Config.Logger.WarningWithContextf(ctx, "Failed to fetch from JSON Path: %v", err) + } else { + req["etag"] = rawEtag.(string) + } + return req, nil +} + +// marshalUpdatePolicyUpdatePolicyRequest converts the update into +// the final JSON request body. +func marshalUpdatePolicyUpdatePolicyRequest(c *Client, m map[string]interface{}) ([]byte, error) { + + return json.Marshal(m) +} + +type updatePolicyUpdatePolicyOperation struct { + // If the update operation has the REQUIRES_APPLY_OPTIONS trait, this will be populated. + // Usually it will be nil - this is to prevent us from accidentally depending on apply + // options, which should usually be unnecessary. + ApplyOptions []dcl.ApplyOption + FieldDiffs []*dcl.FieldDiff +} + +// do creates a request and sends it to the appropriate URL. In most operations, +// do will transcribe a subset of the resource into a request object and send a +// PUT request to a single URL. + +func (c *Client) listPolicyRaw(ctx context.Context, r *Policy, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != PolicyMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listPolicyOperation struct { + Policies []map[string]interface{} `json:"policies"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listPolicy(ctx context.Context, r *Policy, pageToken string, pageSize int32) ([]*Policy, string, error) { + b, err := c.listPolicyRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listPolicyOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*Policy + for _, v := range m.Policies { + res, err := unmarshalMapPolicy(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Parent = r.Parent + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllPolicy(ctx context.Context, f func(*Policy) bool, resources []*Policy) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeletePolicy(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deletePolicyOperation struct{} + +func (op *deletePolicyOperation) do(ctx context.Context, r *Policy, c *Client) error { + r, err := c.GetPolicy(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "Policy not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetPolicy checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + _, err = dcl.SendRequest(ctx, c.Config, "DELETE", u, body, c.Config.RetryProvider) + if err != nil { + return fmt.Errorf("failed to delete Policy: %w", err) + } + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createPolicyOperation struct { + response map[string]interface{} +} + +func (op *createPolicyOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createPolicyOperation) do(ctx context.Context, r *Policy, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + + o, err := dcl.ResponseBodyAsJSON(resp) + if err != nil { + return fmt.Errorf("error decoding response body into JSON: %w", err) + } + op.response = o + + if _, err := c.GetPolicy(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + return nil +} + +func (c *Client) getPolicyRaw(ctx context.Context, r *Policy) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + return b, nil +} + +func (c *Client) policyDiffsForRawDesired(ctx context.Context, rawDesired *Policy, opts ...dcl.ApplyOption) (initial, desired *Policy, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *Policy + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*Policy); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected Policy, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetPolicy(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a Policy resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve Policy resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that Policy resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizePolicyDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for Policy: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for Policy: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractPolicyFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizePolicyInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for Policy: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizePolicyDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for Policy: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffPolicy(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizePolicyInitialState(rawInitial, rawDesired *Policy) (*Policy, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizePolicyDesiredState(rawDesired, rawInitial *Policy, opts ...dcl.ApplyOption) (*Policy, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + rawDesired.Spec = canonicalizePolicySpec(rawDesired.Spec, nil, opts...) + rawDesired.DryRunSpec = canonicalizePolicyDryRunSpec(rawDesired.DryRunSpec, nil, opts...) + + return rawDesired, nil + } + canonicalDesired := &Policy{} + if canonicalizePolicyName(rawDesired.Name, rawInitial.Name) { + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + canonicalDesired.Spec = canonicalizePolicySpec(rawDesired.Spec, rawInitial.Spec, opts...) + canonicalDesired.DryRunSpec = canonicalizePolicyDryRunSpec(rawDesired.DryRunSpec, rawInitial.DryRunSpec, opts...) + if dcl.NameToSelfLink(rawDesired.Parent, rawInitial.Parent) { + canonicalDesired.Parent = rawInitial.Parent + } else { + canonicalDesired.Parent = rawDesired.Parent + } + return canonicalDesired, nil +} + +func canonicalizePolicyNewState(c *Client, rawNew, rawDesired *Policy) (*Policy, error) { + + if dcl.IsEmptyValueIndirect(rawNew.Name) && dcl.IsEmptyValueIndirect(rawDesired.Name) { + rawNew.Name = rawDesired.Name + } else { + if canonicalizePolicyName(rawDesired.Name, rawNew.Name) { + rawNew.Name = rawDesired.Name + } + } + + if dcl.IsEmptyValueIndirect(rawNew.Spec) && dcl.IsEmptyValueIndirect(rawDesired.Spec) { + rawNew.Spec = rawDesired.Spec + } else { + rawNew.Spec = canonicalizeNewPolicySpec(c, rawDesired.Spec, rawNew.Spec) + } + + if dcl.IsEmptyValueIndirect(rawNew.DryRunSpec) && dcl.IsEmptyValueIndirect(rawDesired.DryRunSpec) { + rawNew.DryRunSpec = rawDesired.DryRunSpec + } else { + rawNew.DryRunSpec = canonicalizeNewPolicyDryRunSpec(c, rawDesired.DryRunSpec, rawNew.DryRunSpec) + } + + if dcl.IsEmptyValueIndirect(rawNew.Etag) && dcl.IsEmptyValueIndirect(rawDesired.Etag) { + rawNew.Etag = rawDesired.Etag + } else { + if dcl.StringCanonicalize(rawDesired.Etag, rawNew.Etag) { + rawNew.Etag = rawDesired.Etag + } + } + + rawNew.Parent = rawDesired.Parent + + return rawNew, nil +} + +func canonicalizePolicySpec(des, initial *PolicySpec, opts ...dcl.ApplyOption) *PolicySpec { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &PolicySpec{} + + cDes.Rules = canonicalizePolicySpecRulesSlice(des.Rules, initial.Rules, opts...) + if dcl.BoolCanonicalize(des.InheritFromParent, initial.InheritFromParent) || dcl.IsZeroValue(des.InheritFromParent) { + cDes.InheritFromParent = initial.InheritFromParent + } else { + cDes.InheritFromParent = des.InheritFromParent + } + if dcl.BoolCanonicalize(des.Reset, initial.Reset) || dcl.IsZeroValue(des.Reset) { + cDes.Reset = initial.Reset + } else { + cDes.Reset = des.Reset + } + + return cDes +} + +func canonicalizePolicySpecSlice(des, initial []PolicySpec, opts ...dcl.ApplyOption) []PolicySpec { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicySpec, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicySpec(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicySpec, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicySpec(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicySpec(c *Client, des, nw *PolicySpec) *PolicySpec { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicySpec while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Etag, nw.Etag) { + nw.Etag = des.Etag + } + nw.Rules = canonicalizeNewPolicySpecRulesSet(c, des.Rules, nw.Rules) + if dcl.BoolCanonicalize(des.InheritFromParent, nw.InheritFromParent) { + nw.InheritFromParent = des.InheritFromParent + } + if dcl.BoolCanonicalize(des.Reset, nw.Reset) { + nw.Reset = des.Reset + } + + return nw +} + +func canonicalizeNewPolicySpecSet(c *Client, des, nw []PolicySpec) []PolicySpec { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicySpec + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicySpecNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicySpec(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicySpecSlice(c *Client, des, nw []PolicySpec) []PolicySpec { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicySpec + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicySpec(c, &d, &n)) + } + + return items +} + +func canonicalizePolicySpecRules(des, initial *PolicySpecRules, opts ...dcl.ApplyOption) *PolicySpecRules { + if des == nil { + return initial + } + if des.empty { + return des + } + + if des.Values != nil || (initial != nil && initial.Values != nil) { + // Check if anything else is set. + if dcl.AnySet(des.AllowAll, des.DenyAll, des.Enforce) { + des.Values = nil + if initial != nil { + initial.Values = nil + } + } + } + + if des.AllowAll != nil || (initial != nil && initial.AllowAll != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Values, des.DenyAll, des.Enforce) { + des.AllowAll = nil + if initial != nil { + initial.AllowAll = nil + } + } + } + + if des.DenyAll != nil || (initial != nil && initial.DenyAll != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Values, des.AllowAll, des.Enforce) { + des.DenyAll = nil + if initial != nil { + initial.DenyAll = nil + } + } + } + + if des.Enforce != nil || (initial != nil && initial.Enforce != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Values, des.AllowAll, des.DenyAll) { + des.Enforce = nil + if initial != nil { + initial.Enforce = nil + } + } + } + + if initial == nil { + return des + } + + cDes := &PolicySpecRules{} + + cDes.Values = canonicalizePolicySpecRulesValues(des.Values, initial.Values, opts...) + if dcl.BoolCanonicalize(des.AllowAll, initial.AllowAll) || dcl.IsZeroValue(des.AllowAll) { + cDes.AllowAll = initial.AllowAll + } else { + cDes.AllowAll = des.AllowAll + } + if dcl.BoolCanonicalize(des.DenyAll, initial.DenyAll) || dcl.IsZeroValue(des.DenyAll) { + cDes.DenyAll = initial.DenyAll + } else { + cDes.DenyAll = des.DenyAll + } + if dcl.BoolCanonicalize(des.Enforce, initial.Enforce) || dcl.IsZeroValue(des.Enforce) { + cDes.Enforce = initial.Enforce + } else { + cDes.Enforce = des.Enforce + } + cDes.Condition = canonicalizePolicySpecRulesCondition(des.Condition, initial.Condition, opts...) + + return cDes +} + +func canonicalizePolicySpecRulesSlice(des, initial []PolicySpecRules, opts ...dcl.ApplyOption) []PolicySpecRules { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicySpecRules, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicySpecRules(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicySpecRules, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicySpecRules(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicySpecRules(c *Client, des, nw *PolicySpecRules) *PolicySpecRules { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicySpecRules while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Values = canonicalizeNewPolicySpecRulesValues(c, des.Values, nw.Values) + if dcl.BoolCanonicalize(des.AllowAll, nw.AllowAll) { + nw.AllowAll = des.AllowAll + } + if dcl.BoolCanonicalize(des.DenyAll, nw.DenyAll) { + nw.DenyAll = des.DenyAll + } + if dcl.BoolCanonicalize(des.Enforce, nw.Enforce) { + nw.Enforce = des.Enforce + } + nw.Condition = canonicalizeNewPolicySpecRulesCondition(c, des.Condition, nw.Condition) + + return nw +} + +func canonicalizeNewPolicySpecRulesSet(c *Client, des, nw []PolicySpecRules) []PolicySpecRules { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicySpecRules + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicySpecRulesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicySpecRules(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicySpecRulesSlice(c *Client, des, nw []PolicySpecRules) []PolicySpecRules { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicySpecRules + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicySpecRules(c, &d, &n)) + } + + return items +} + +func canonicalizePolicySpecRulesValues(des, initial *PolicySpecRulesValues, opts ...dcl.ApplyOption) *PolicySpecRulesValues { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &PolicySpecRulesValues{} + + if dcl.StringArrayCanonicalize(des.AllowedValues, initial.AllowedValues) { + cDes.AllowedValues = initial.AllowedValues + } else { + cDes.AllowedValues = des.AllowedValues + } + if dcl.StringArrayCanonicalize(des.DeniedValues, initial.DeniedValues) { + cDes.DeniedValues = initial.DeniedValues + } else { + cDes.DeniedValues = des.DeniedValues + } + + return cDes +} + +func canonicalizePolicySpecRulesValuesSlice(des, initial []PolicySpecRulesValues, opts ...dcl.ApplyOption) []PolicySpecRulesValues { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicySpecRulesValues, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicySpecRulesValues(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicySpecRulesValues, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicySpecRulesValues(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicySpecRulesValues(c *Client, des, nw *PolicySpecRulesValues) *PolicySpecRulesValues { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicySpecRulesValues while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.AllowedValues, nw.AllowedValues) { + nw.AllowedValues = des.AllowedValues + } + if dcl.StringArrayCanonicalize(des.DeniedValues, nw.DeniedValues) { + nw.DeniedValues = des.DeniedValues + } + + return nw +} + +func canonicalizeNewPolicySpecRulesValuesSet(c *Client, des, nw []PolicySpecRulesValues) []PolicySpecRulesValues { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicySpecRulesValues + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicySpecRulesValuesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicySpecRulesValues(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicySpecRulesValuesSlice(c *Client, des, nw []PolicySpecRulesValues) []PolicySpecRulesValues { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicySpecRulesValues + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicySpecRulesValues(c, &d, &n)) + } + + return items +} + +func canonicalizePolicySpecRulesCondition(des, initial *PolicySpecRulesCondition, opts ...dcl.ApplyOption) *PolicySpecRulesCondition { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &PolicySpecRulesCondition{} + + if canonicalizePolicyRulesConditionExpression(des.Expression, initial.Expression) || dcl.IsZeroValue(des.Expression) { + cDes.Expression = initial.Expression + } else { + cDes.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, initial.Title) || dcl.IsZeroValue(des.Title) { + cDes.Title = initial.Title + } else { + cDes.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, initial.Description) || dcl.IsZeroValue(des.Description) { + cDes.Description = initial.Description + } else { + cDes.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, initial.Location) || dcl.IsZeroValue(des.Location) { + cDes.Location = initial.Location + } else { + cDes.Location = des.Location + } + + return cDes +} + +func canonicalizePolicySpecRulesConditionSlice(des, initial []PolicySpecRulesCondition, opts ...dcl.ApplyOption) []PolicySpecRulesCondition { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicySpecRulesCondition, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicySpecRulesCondition(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicySpecRulesCondition, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicySpecRulesCondition(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicySpecRulesCondition(c *Client, des, nw *PolicySpecRulesCondition) *PolicySpecRulesCondition { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicySpecRulesCondition while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if canonicalizePolicyRulesConditionExpression(des.Expression, nw.Expression) { + nw.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, nw.Title) { + nw.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, nw.Description) { + nw.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, nw.Location) { + nw.Location = des.Location + } + + return nw +} + +func canonicalizeNewPolicySpecRulesConditionSet(c *Client, des, nw []PolicySpecRulesCondition) []PolicySpecRulesCondition { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicySpecRulesCondition + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicySpecRulesConditionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicySpecRulesCondition(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicySpecRulesConditionSlice(c *Client, des, nw []PolicySpecRulesCondition) []PolicySpecRulesCondition { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicySpecRulesCondition + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicySpecRulesCondition(c, &d, &n)) + } + + return items +} + +func canonicalizePolicyDryRunSpec(des, initial *PolicyDryRunSpec, opts ...dcl.ApplyOption) *PolicyDryRunSpec { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &PolicyDryRunSpec{} + + cDes.Rules = canonicalizePolicyDryRunSpecRulesSlice(des.Rules, initial.Rules, opts...) + if dcl.BoolCanonicalize(des.InheritFromParent, initial.InheritFromParent) || dcl.IsZeroValue(des.InheritFromParent) { + cDes.InheritFromParent = initial.InheritFromParent + } else { + cDes.InheritFromParent = des.InheritFromParent + } + if dcl.BoolCanonicalize(des.Reset, initial.Reset) || dcl.IsZeroValue(des.Reset) { + cDes.Reset = initial.Reset + } else { + cDes.Reset = des.Reset + } + + return cDes +} + +func canonicalizePolicyDryRunSpecSlice(des, initial []PolicyDryRunSpec, opts ...dcl.ApplyOption) []PolicyDryRunSpec { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicyDryRunSpec, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicyDryRunSpec(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicyDryRunSpec, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicyDryRunSpec(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicyDryRunSpec(c *Client, des, nw *PolicyDryRunSpec) *PolicyDryRunSpec { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicyDryRunSpec while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Etag, nw.Etag) { + nw.Etag = des.Etag + } + nw.Rules = canonicalizeNewPolicyDryRunSpecRulesSlice(c, des.Rules, nw.Rules) + if dcl.BoolCanonicalize(des.InheritFromParent, nw.InheritFromParent) { + nw.InheritFromParent = des.InheritFromParent + } + if dcl.BoolCanonicalize(des.Reset, nw.Reset) { + nw.Reset = des.Reset + } + + return nw +} + +func canonicalizeNewPolicyDryRunSpecSet(c *Client, des, nw []PolicyDryRunSpec) []PolicyDryRunSpec { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicyDryRunSpec + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicyDryRunSpecNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicyDryRunSpec(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicyDryRunSpecSlice(c *Client, des, nw []PolicyDryRunSpec) []PolicyDryRunSpec { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicyDryRunSpec + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicyDryRunSpec(c, &d, &n)) + } + + return items +} + +func canonicalizePolicyDryRunSpecRules(des, initial *PolicyDryRunSpecRules, opts ...dcl.ApplyOption) *PolicyDryRunSpecRules { + if des == nil { + return initial + } + if des.empty { + return des + } + + if des.Values != nil || (initial != nil && initial.Values != nil) { + // Check if anything else is set. + if dcl.AnySet(des.AllowAll, des.DenyAll, des.Enforce) { + des.Values = nil + if initial != nil { + initial.Values = nil + } + } + } + + if des.AllowAll != nil || (initial != nil && initial.AllowAll != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Values, des.DenyAll, des.Enforce) { + des.AllowAll = nil + if initial != nil { + initial.AllowAll = nil + } + } + } + + if des.DenyAll != nil || (initial != nil && initial.DenyAll != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Values, des.AllowAll, des.Enforce) { + des.DenyAll = nil + if initial != nil { + initial.DenyAll = nil + } + } + } + + if des.Enforce != nil || (initial != nil && initial.Enforce != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Values, des.AllowAll, des.DenyAll) { + des.Enforce = nil + if initial != nil { + initial.Enforce = nil + } + } + } + + if initial == nil { + return des + } + + cDes := &PolicyDryRunSpecRules{} + + cDes.Values = canonicalizePolicyDryRunSpecRulesValues(des.Values, initial.Values, opts...) + if dcl.BoolCanonicalize(des.AllowAll, initial.AllowAll) || dcl.IsZeroValue(des.AllowAll) { + cDes.AllowAll = initial.AllowAll + } else { + cDes.AllowAll = des.AllowAll + } + if dcl.BoolCanonicalize(des.DenyAll, initial.DenyAll) || dcl.IsZeroValue(des.DenyAll) { + cDes.DenyAll = initial.DenyAll + } else { + cDes.DenyAll = des.DenyAll + } + if dcl.BoolCanonicalize(des.Enforce, initial.Enforce) || dcl.IsZeroValue(des.Enforce) { + cDes.Enforce = initial.Enforce + } else { + cDes.Enforce = des.Enforce + } + cDes.Condition = canonicalizePolicyDryRunSpecRulesCondition(des.Condition, initial.Condition, opts...) + + return cDes +} + +func canonicalizePolicyDryRunSpecRulesSlice(des, initial []PolicyDryRunSpecRules, opts ...dcl.ApplyOption) []PolicyDryRunSpecRules { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicyDryRunSpecRules, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicyDryRunSpecRules(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicyDryRunSpecRules, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicyDryRunSpecRules(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicyDryRunSpecRules(c *Client, des, nw *PolicyDryRunSpecRules) *PolicyDryRunSpecRules { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicyDryRunSpecRules while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Values = canonicalizeNewPolicyDryRunSpecRulesValues(c, des.Values, nw.Values) + if dcl.BoolCanonicalize(des.AllowAll, nw.AllowAll) { + nw.AllowAll = des.AllowAll + } + if dcl.BoolCanonicalize(des.DenyAll, nw.DenyAll) { + nw.DenyAll = des.DenyAll + } + if dcl.BoolCanonicalize(des.Enforce, nw.Enforce) { + nw.Enforce = des.Enforce + } + nw.Condition = canonicalizeNewPolicyDryRunSpecRulesCondition(c, des.Condition, nw.Condition) + + return nw +} + +func canonicalizeNewPolicyDryRunSpecRulesSet(c *Client, des, nw []PolicyDryRunSpecRules) []PolicyDryRunSpecRules { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicyDryRunSpecRules + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicyDryRunSpecRulesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicyDryRunSpecRules(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicyDryRunSpecRulesSlice(c *Client, des, nw []PolicyDryRunSpecRules) []PolicyDryRunSpecRules { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicyDryRunSpecRules + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicyDryRunSpecRules(c, &d, &n)) + } + + return items +} + +func canonicalizePolicyDryRunSpecRulesValues(des, initial *PolicyDryRunSpecRulesValues, opts ...dcl.ApplyOption) *PolicyDryRunSpecRulesValues { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &PolicyDryRunSpecRulesValues{} + + if dcl.StringArrayCanonicalize(des.AllowedValues, initial.AllowedValues) { + cDes.AllowedValues = initial.AllowedValues + } else { + cDes.AllowedValues = des.AllowedValues + } + if dcl.StringArrayCanonicalize(des.DeniedValues, initial.DeniedValues) { + cDes.DeniedValues = initial.DeniedValues + } else { + cDes.DeniedValues = des.DeniedValues + } + + return cDes +} + +func canonicalizePolicyDryRunSpecRulesValuesSlice(des, initial []PolicyDryRunSpecRulesValues, opts ...dcl.ApplyOption) []PolicyDryRunSpecRulesValues { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicyDryRunSpecRulesValues, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicyDryRunSpecRulesValues(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicyDryRunSpecRulesValues, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicyDryRunSpecRulesValues(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicyDryRunSpecRulesValues(c *Client, des, nw *PolicyDryRunSpecRulesValues) *PolicyDryRunSpecRulesValues { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicyDryRunSpecRulesValues while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.AllowedValues, nw.AllowedValues) { + nw.AllowedValues = des.AllowedValues + } + if dcl.StringArrayCanonicalize(des.DeniedValues, nw.DeniedValues) { + nw.DeniedValues = des.DeniedValues + } + + return nw +} + +func canonicalizeNewPolicyDryRunSpecRulesValuesSet(c *Client, des, nw []PolicyDryRunSpecRulesValues) []PolicyDryRunSpecRulesValues { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicyDryRunSpecRulesValues + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicyDryRunSpecRulesValuesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicyDryRunSpecRulesValues(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicyDryRunSpecRulesValuesSlice(c *Client, des, nw []PolicyDryRunSpecRulesValues) []PolicyDryRunSpecRulesValues { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicyDryRunSpecRulesValues + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicyDryRunSpecRulesValues(c, &d, &n)) + } + + return items +} + +func canonicalizePolicyDryRunSpecRulesCondition(des, initial *PolicyDryRunSpecRulesCondition, opts ...dcl.ApplyOption) *PolicyDryRunSpecRulesCondition { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &PolicyDryRunSpecRulesCondition{} + + if dcl.StringCanonicalize(des.Expression, initial.Expression) || dcl.IsZeroValue(des.Expression) { + cDes.Expression = initial.Expression + } else { + cDes.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, initial.Title) || dcl.IsZeroValue(des.Title) { + cDes.Title = initial.Title + } else { + cDes.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, initial.Description) || dcl.IsZeroValue(des.Description) { + cDes.Description = initial.Description + } else { + cDes.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, initial.Location) || dcl.IsZeroValue(des.Location) { + cDes.Location = initial.Location + } else { + cDes.Location = des.Location + } + + return cDes +} + +func canonicalizePolicyDryRunSpecRulesConditionSlice(des, initial []PolicyDryRunSpecRulesCondition, opts ...dcl.ApplyOption) []PolicyDryRunSpecRulesCondition { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]PolicyDryRunSpecRulesCondition, 0, len(des)) + for _, d := range des { + cd := canonicalizePolicyDryRunSpecRulesCondition(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]PolicyDryRunSpecRulesCondition, 0, len(des)) + for i, d := range des { + cd := canonicalizePolicyDryRunSpecRulesCondition(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewPolicyDryRunSpecRulesCondition(c *Client, des, nw *PolicyDryRunSpecRulesCondition) *PolicyDryRunSpecRulesCondition { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for PolicyDryRunSpecRulesCondition while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Expression, nw.Expression) { + nw.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, nw.Title) { + nw.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, nw.Description) { + nw.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, nw.Location) { + nw.Location = des.Location + } + + return nw +} + +func canonicalizeNewPolicyDryRunSpecRulesConditionSet(c *Client, des, nw []PolicyDryRunSpecRulesCondition) []PolicyDryRunSpecRulesCondition { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []PolicyDryRunSpecRulesCondition + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := comparePolicyDryRunSpecRulesConditionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewPolicyDryRunSpecRulesCondition(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewPolicyDryRunSpecRulesConditionSlice(c *Client, des, nw []PolicyDryRunSpecRulesCondition) []PolicyDryRunSpecRulesCondition { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []PolicyDryRunSpecRulesCondition + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewPolicyDryRunSpecRulesCondition(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffPolicy(c *Client, desired, actual *Policy, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{CustomDiff: canonicalizePolicyName, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Spec, actual.Spec, dcl.DiffInfo{ObjectFunction: comparePolicySpecNewStyle, EmptyObject: EmptyPolicySpec, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Spec")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.DryRunSpec, actual.DryRunSpec, dcl.DiffInfo{ObjectFunction: comparePolicyDryRunSpecNewStyle, EmptyObject: EmptyPolicyDryRunSpec, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("DryRunSpec")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Parent, actual.Parent, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Parent")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func comparePolicySpecNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicySpec) + if !ok { + desiredNotPointer, ok := d.(PolicySpec) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpec or *PolicySpec", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicySpec) + if !ok { + actualNotPointer, ok := a.(PolicySpec) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpec", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Rules, actual.Rules, dcl.DiffInfo{Type: "Set", ObjectFunction: comparePolicySpecRulesNewStyle, EmptyObject: EmptyPolicySpecRules, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Rules")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InheritFromParent, actual.InheritFromParent, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("InheritFromParent")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Reset, actual.Reset, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Reset")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicySpecRulesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicySpecRules) + if !ok { + desiredNotPointer, ok := d.(PolicySpecRules) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpecRules or *PolicySpecRules", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicySpecRules) + if !ok { + actualNotPointer, ok := a.(PolicySpecRules) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpecRules", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Values, actual.Values, dcl.DiffInfo{ObjectFunction: comparePolicySpecRulesValuesNewStyle, EmptyObject: EmptyPolicySpecRulesValues, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Values")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowAll, actual.AllowAll, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("AllowAll")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DenyAll, actual.DenyAll, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("DenyAll")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Enforce, actual.Enforce, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Enforce")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Condition, actual.Condition, dcl.DiffInfo{ObjectFunction: comparePolicySpecRulesConditionNewStyle, EmptyObject: EmptyPolicySpecRulesCondition, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Condition")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicySpecRulesValuesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicySpecRulesValues) + if !ok { + desiredNotPointer, ok := d.(PolicySpecRulesValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpecRulesValues or *PolicySpecRulesValues", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicySpecRulesValues) + if !ok { + actualNotPointer, ok := a.(PolicySpecRulesValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpecRulesValues", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.AllowedValues, actual.AllowedValues, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("AllowedValues")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DeniedValues, actual.DeniedValues, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("DeniedValues")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicySpecRulesConditionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicySpecRulesCondition) + if !ok { + desiredNotPointer, ok := d.(PolicySpecRulesCondition) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpecRulesCondition or *PolicySpecRulesCondition", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicySpecRulesCondition) + if !ok { + actualNotPointer, ok := a.(PolicySpecRulesCondition) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicySpecRulesCondition", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Expression, actual.Expression, dcl.DiffInfo{CustomDiff: canonicalizePolicyRulesConditionExpression, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Expression")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Title, actual.Title, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Title")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicyDryRunSpecNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicyDryRunSpec) + if !ok { + desiredNotPointer, ok := d.(PolicyDryRunSpec) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpec or *PolicyDryRunSpec", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicyDryRunSpec) + if !ok { + actualNotPointer, ok := a.(PolicyDryRunSpec) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpec", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Rules, actual.Rules, dcl.DiffInfo{ObjectFunction: comparePolicyDryRunSpecRulesNewStyle, EmptyObject: EmptyPolicyDryRunSpecRules, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Rules")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InheritFromParent, actual.InheritFromParent, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("InheritFromParent")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Reset, actual.Reset, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Reset")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicyDryRunSpecRulesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicyDryRunSpecRules) + if !ok { + desiredNotPointer, ok := d.(PolicyDryRunSpecRules) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpecRules or *PolicyDryRunSpecRules", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicyDryRunSpecRules) + if !ok { + actualNotPointer, ok := a.(PolicyDryRunSpecRules) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpecRules", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Values, actual.Values, dcl.DiffInfo{ObjectFunction: comparePolicyDryRunSpecRulesValuesNewStyle, EmptyObject: EmptyPolicyDryRunSpecRulesValues, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Values")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowAll, actual.AllowAll, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("AllowAll")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DenyAll, actual.DenyAll, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("DenyAll")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Enforce, actual.Enforce, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Enforce")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Condition, actual.Condition, dcl.DiffInfo{ObjectFunction: comparePolicyDryRunSpecRulesConditionNewStyle, EmptyObject: EmptyPolicyDryRunSpecRulesCondition, OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Condition")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicyDryRunSpecRulesValuesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicyDryRunSpecRulesValues) + if !ok { + desiredNotPointer, ok := d.(PolicyDryRunSpecRulesValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpecRulesValues or *PolicyDryRunSpecRulesValues", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicyDryRunSpecRulesValues) + if !ok { + actualNotPointer, ok := a.(PolicyDryRunSpecRulesValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpecRulesValues", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.AllowedValues, actual.AllowedValues, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("AllowedValues")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DeniedValues, actual.DeniedValues, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("DeniedValues")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func comparePolicyDryRunSpecRulesConditionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*PolicyDryRunSpecRulesCondition) + if !ok { + desiredNotPointer, ok := d.(PolicyDryRunSpecRulesCondition) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpecRulesCondition or *PolicyDryRunSpecRulesCondition", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*PolicyDryRunSpecRulesCondition) + if !ok { + actualNotPointer, ok := a.(PolicyDryRunSpecRulesCondition) + if !ok { + return nil, fmt.Errorf("obj %v is not a PolicyDryRunSpecRulesCondition", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Expression, actual.Expression, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Expression")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Title, actual.Title, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Title")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updatePolicyUpdatePolicyOperation")}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Policy) urlNormalized() *Policy { + normalized := dcl.Copy(*r).(Policy) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.Etag = dcl.SelfLinkToName(r.Etag) + normalized.Parent = r.Parent + return &normalized +} + +func (r *Policy) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdatePolicy" { + fields := map[string]interface{}{ + "parent": dcl.ValueOrEmptyString(nr.Parent), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("{{parent}}/policies/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Policy resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Policy) marshal(c *Client) ([]byte, error) { + m, err := expandPolicy(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Policy: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalPolicy decodes JSON responses into the Policy resource schema. +func unmarshalPolicy(b []byte, c *Client, res *Policy) (*Policy, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapPolicy(m, c, res) +} + +func unmarshalMapPolicy(m map[string]interface{}, c *Client, res *Policy) (*Policy, error) { + + flattened := flattenPolicy(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandPolicy expands Policy into a JSON request object. +func expandPolicy(c *Client, f *Policy) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := expandPolicyName(c, f.Name, res); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v, err := expandPolicySpec(c, f.Spec, res); err != nil { + return nil, fmt.Errorf("error expanding Spec into spec: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["spec"] = v + } + if v, err := expandPolicyDryRunSpec(c, f.DryRunSpec, res); err != nil { + return nil, fmt.Errorf("error expanding DryRunSpec into dryRunSpec: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["dryRunSpec"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Parent into parent: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["parent"] = v + } + + return m, nil +} + +// flattenPolicy flattens Policy from a JSON request object into the +// Policy type. +func flattenPolicy(c *Client, i interface{}, res *Policy) *Policy { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Policy{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.Spec = flattenPolicySpec(c, m["spec"], res) + resultRes.DryRunSpec = flattenPolicyDryRunSpec(c, m["dryRunSpec"], res) + resultRes.Etag = dcl.FlattenString(m["etag"]) + resultRes.Parent = dcl.FlattenString(m["parent"]) + + return resultRes +} + +// expandPolicySpecMap expands the contents of PolicySpec into a JSON +// request object. +func expandPolicySpecMap(c *Client, f map[string]PolicySpec, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicySpec(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicySpecSlice expands the contents of PolicySpec into a JSON +// request object. +func expandPolicySpecSlice(c *Client, f []PolicySpec, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicySpec(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicySpecMap flattens the contents of PolicySpec from a JSON +// response object. +func flattenPolicySpecMap(c *Client, i interface{}, res *Policy) map[string]PolicySpec { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicySpec{} + } + + if len(a) == 0 { + return map[string]PolicySpec{} + } + + items := make(map[string]PolicySpec) + for k, item := range a { + items[k] = *flattenPolicySpec(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicySpecSlice flattens the contents of PolicySpec from a JSON +// response object. +func flattenPolicySpecSlice(c *Client, i interface{}, res *Policy) []PolicySpec { + a, ok := i.([]interface{}) + if !ok { + return []PolicySpec{} + } + + if len(a) == 0 { + return []PolicySpec{} + } + + items := make([]PolicySpec, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicySpec(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicySpec expands an instance of PolicySpec into a JSON +// request object. +func expandPolicySpec(c *Client, f *PolicySpec, res *Policy) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandPolicySpecRulesSlice(c, f.Rules, res); err != nil { + return nil, fmt.Errorf("error expanding Rules into rules: %w", err) + } else if v != nil { + m["rules"] = v + } + if v := f.InheritFromParent; !dcl.IsEmptyValueIndirect(v) { + m["inheritFromParent"] = v + } + if v := f.Reset; !dcl.IsEmptyValueIndirect(v) { + m["reset"] = v + } + + return m, nil +} + +// flattenPolicySpec flattens an instance of PolicySpec from a JSON +// response object. +func flattenPolicySpec(c *Client, i interface{}, res *Policy) *PolicySpec { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicySpec{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicySpec + } + r.Etag = dcl.FlattenString(m["etag"]) + r.UpdateTime = dcl.FlattenString(m["updateTime"]) + r.Rules = flattenPolicySpecRulesSlice(c, m["rules"], res) + r.InheritFromParent = dcl.FlattenBool(m["inheritFromParent"]) + r.Reset = dcl.FlattenBool(m["reset"]) + + return r +} + +// expandPolicySpecRulesMap expands the contents of PolicySpecRules into a JSON +// request object. +func expandPolicySpecRulesMap(c *Client, f map[string]PolicySpecRules, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicySpecRules(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicySpecRulesSlice expands the contents of PolicySpecRules into a JSON +// request object. +func expandPolicySpecRulesSlice(c *Client, f []PolicySpecRules, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicySpecRules(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicySpecRulesMap flattens the contents of PolicySpecRules from a JSON +// response object. +func flattenPolicySpecRulesMap(c *Client, i interface{}, res *Policy) map[string]PolicySpecRules { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicySpecRules{} + } + + if len(a) == 0 { + return map[string]PolicySpecRules{} + } + + items := make(map[string]PolicySpecRules) + for k, item := range a { + items[k] = *flattenPolicySpecRules(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicySpecRulesSlice flattens the contents of PolicySpecRules from a JSON +// response object. +func flattenPolicySpecRulesSlice(c *Client, i interface{}, res *Policy) []PolicySpecRules { + a, ok := i.([]interface{}) + if !ok { + return []PolicySpecRules{} + } + + if len(a) == 0 { + return []PolicySpecRules{} + } + + items := make([]PolicySpecRules, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicySpecRules(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicySpecRules expands an instance of PolicySpecRules into a JSON +// request object. +func expandPolicySpecRules(c *Client, f *PolicySpecRules, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandPolicySpecRulesValues(c, f.Values, res); err != nil { + return nil, fmt.Errorf("error expanding Values into values: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["values"] = v + } + if v := f.AllowAll; !dcl.IsEmptyValueIndirect(v) { + m["allowAll"] = v + } + if v := f.DenyAll; !dcl.IsEmptyValueIndirect(v) { + m["denyAll"] = v + } + if v := f.Enforce; !dcl.IsEmptyValueIndirect(v) { + m["enforce"] = v + } + if v, err := expandPolicySpecRulesCondition(c, f.Condition, res); err != nil { + return nil, fmt.Errorf("error expanding Condition into condition: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["condition"] = v + } + + return m, nil +} + +// flattenPolicySpecRules flattens an instance of PolicySpecRules from a JSON +// response object. +func flattenPolicySpecRules(c *Client, i interface{}, res *Policy) *PolicySpecRules { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicySpecRules{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicySpecRules + } + r.Values = flattenPolicySpecRulesValues(c, m["values"], res) + r.AllowAll = dcl.FlattenBool(m["allowAll"]) + r.DenyAll = dcl.FlattenBool(m["denyAll"]) + r.Enforce = dcl.FlattenBool(m["enforce"]) + r.Condition = flattenPolicySpecRulesCondition(c, m["condition"], res) + + return r +} + +// expandPolicySpecRulesValuesMap expands the contents of PolicySpecRulesValues into a JSON +// request object. +func expandPolicySpecRulesValuesMap(c *Client, f map[string]PolicySpecRulesValues, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicySpecRulesValues(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicySpecRulesValuesSlice expands the contents of PolicySpecRulesValues into a JSON +// request object. +func expandPolicySpecRulesValuesSlice(c *Client, f []PolicySpecRulesValues, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicySpecRulesValues(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicySpecRulesValuesMap flattens the contents of PolicySpecRulesValues from a JSON +// response object. +func flattenPolicySpecRulesValuesMap(c *Client, i interface{}, res *Policy) map[string]PolicySpecRulesValues { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicySpecRulesValues{} + } + + if len(a) == 0 { + return map[string]PolicySpecRulesValues{} + } + + items := make(map[string]PolicySpecRulesValues) + for k, item := range a { + items[k] = *flattenPolicySpecRulesValues(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicySpecRulesValuesSlice flattens the contents of PolicySpecRulesValues from a JSON +// response object. +func flattenPolicySpecRulesValuesSlice(c *Client, i interface{}, res *Policy) []PolicySpecRulesValues { + a, ok := i.([]interface{}) + if !ok { + return []PolicySpecRulesValues{} + } + + if len(a) == 0 { + return []PolicySpecRulesValues{} + } + + items := make([]PolicySpecRulesValues, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicySpecRulesValues(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicySpecRulesValues expands an instance of PolicySpecRulesValues into a JSON +// request object. +func expandPolicySpecRulesValues(c *Client, f *PolicySpecRulesValues, res *Policy) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.AllowedValues; v != nil { + m["allowedValues"] = v + } + if v := f.DeniedValues; v != nil { + m["deniedValues"] = v + } + + return m, nil +} + +// flattenPolicySpecRulesValues flattens an instance of PolicySpecRulesValues from a JSON +// response object. +func flattenPolicySpecRulesValues(c *Client, i interface{}, res *Policy) *PolicySpecRulesValues { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicySpecRulesValues{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicySpecRulesValues + } + r.AllowedValues = dcl.FlattenStringSlice(m["allowedValues"]) + r.DeniedValues = dcl.FlattenStringSlice(m["deniedValues"]) + + return r +} + +// expandPolicySpecRulesConditionMap expands the contents of PolicySpecRulesCondition into a JSON +// request object. +func expandPolicySpecRulesConditionMap(c *Client, f map[string]PolicySpecRulesCondition, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicySpecRulesCondition(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicySpecRulesConditionSlice expands the contents of PolicySpecRulesCondition into a JSON +// request object. +func expandPolicySpecRulesConditionSlice(c *Client, f []PolicySpecRulesCondition, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicySpecRulesCondition(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicySpecRulesConditionMap flattens the contents of PolicySpecRulesCondition from a JSON +// response object. +func flattenPolicySpecRulesConditionMap(c *Client, i interface{}, res *Policy) map[string]PolicySpecRulesCondition { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicySpecRulesCondition{} + } + + if len(a) == 0 { + return map[string]PolicySpecRulesCondition{} + } + + items := make(map[string]PolicySpecRulesCondition) + for k, item := range a { + items[k] = *flattenPolicySpecRulesCondition(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicySpecRulesConditionSlice flattens the contents of PolicySpecRulesCondition from a JSON +// response object. +func flattenPolicySpecRulesConditionSlice(c *Client, i interface{}, res *Policy) []PolicySpecRulesCondition { + a, ok := i.([]interface{}) + if !ok { + return []PolicySpecRulesCondition{} + } + + if len(a) == 0 { + return []PolicySpecRulesCondition{} + } + + items := make([]PolicySpecRulesCondition, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicySpecRulesCondition(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicySpecRulesCondition expands an instance of PolicySpecRulesCondition into a JSON +// request object. +func expandPolicySpecRulesCondition(c *Client, f *PolicySpecRulesCondition, res *Policy) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Expression; !dcl.IsEmptyValueIndirect(v) { + m["expression"] = v + } + if v := f.Title; !dcl.IsEmptyValueIndirect(v) { + m["title"] = v + } + if v := f.Description; !dcl.IsEmptyValueIndirect(v) { + m["description"] = v + } + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenPolicySpecRulesCondition flattens an instance of PolicySpecRulesCondition from a JSON +// response object. +func flattenPolicySpecRulesCondition(c *Client, i interface{}, res *Policy) *PolicySpecRulesCondition { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicySpecRulesCondition{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicySpecRulesCondition + } + r.Expression = dcl.FlattenString(m["expression"]) + r.Title = dcl.FlattenString(m["title"]) + r.Description = dcl.FlattenString(m["description"]) + r.Location = dcl.FlattenString(m["location"]) + + return r +} + +// expandPolicyDryRunSpecMap expands the contents of PolicyDryRunSpec into a JSON +// request object. +func expandPolicyDryRunSpecMap(c *Client, f map[string]PolicyDryRunSpec, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicyDryRunSpec(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicyDryRunSpecSlice expands the contents of PolicyDryRunSpec into a JSON +// request object. +func expandPolicyDryRunSpecSlice(c *Client, f []PolicyDryRunSpec, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicyDryRunSpec(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicyDryRunSpecMap flattens the contents of PolicyDryRunSpec from a JSON +// response object. +func flattenPolicyDryRunSpecMap(c *Client, i interface{}, res *Policy) map[string]PolicyDryRunSpec { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicyDryRunSpec{} + } + + if len(a) == 0 { + return map[string]PolicyDryRunSpec{} + } + + items := make(map[string]PolicyDryRunSpec) + for k, item := range a { + items[k] = *flattenPolicyDryRunSpec(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicyDryRunSpecSlice flattens the contents of PolicyDryRunSpec from a JSON +// response object. +func flattenPolicyDryRunSpecSlice(c *Client, i interface{}, res *Policy) []PolicyDryRunSpec { + a, ok := i.([]interface{}) + if !ok { + return []PolicyDryRunSpec{} + } + + if len(a) == 0 { + return []PolicyDryRunSpec{} + } + + items := make([]PolicyDryRunSpec, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicyDryRunSpec(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicyDryRunSpec expands an instance of PolicyDryRunSpec into a JSON +// request object. +func expandPolicyDryRunSpec(c *Client, f *PolicyDryRunSpec, res *Policy) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandPolicyDryRunSpecRulesSlice(c, f.Rules, res); err != nil { + return nil, fmt.Errorf("error expanding Rules into rules: %w", err) + } else if v != nil { + m["rules"] = v + } + if v := f.InheritFromParent; !dcl.IsEmptyValueIndirect(v) { + m["inheritFromParent"] = v + } + if v := f.Reset; !dcl.IsEmptyValueIndirect(v) { + m["reset"] = v + } + + return m, nil +} + +// flattenPolicyDryRunSpec flattens an instance of PolicyDryRunSpec from a JSON +// response object. +func flattenPolicyDryRunSpec(c *Client, i interface{}, res *Policy) *PolicyDryRunSpec { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicyDryRunSpec{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicyDryRunSpec + } + r.Etag = dcl.FlattenString(m["etag"]) + r.UpdateTime = dcl.FlattenString(m["updateTime"]) + r.Rules = flattenPolicyDryRunSpecRulesSlice(c, m["rules"], res) + r.InheritFromParent = dcl.FlattenBool(m["inheritFromParent"]) + r.Reset = dcl.FlattenBool(m["reset"]) + + return r +} + +// expandPolicyDryRunSpecRulesMap expands the contents of PolicyDryRunSpecRules into a JSON +// request object. +func expandPolicyDryRunSpecRulesMap(c *Client, f map[string]PolicyDryRunSpecRules, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicyDryRunSpecRules(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicyDryRunSpecRulesSlice expands the contents of PolicyDryRunSpecRules into a JSON +// request object. +func expandPolicyDryRunSpecRulesSlice(c *Client, f []PolicyDryRunSpecRules, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicyDryRunSpecRules(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicyDryRunSpecRulesMap flattens the contents of PolicyDryRunSpecRules from a JSON +// response object. +func flattenPolicyDryRunSpecRulesMap(c *Client, i interface{}, res *Policy) map[string]PolicyDryRunSpecRules { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicyDryRunSpecRules{} + } + + if len(a) == 0 { + return map[string]PolicyDryRunSpecRules{} + } + + items := make(map[string]PolicyDryRunSpecRules) + for k, item := range a { + items[k] = *flattenPolicyDryRunSpecRules(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicyDryRunSpecRulesSlice flattens the contents of PolicyDryRunSpecRules from a JSON +// response object. +func flattenPolicyDryRunSpecRulesSlice(c *Client, i interface{}, res *Policy) []PolicyDryRunSpecRules { + a, ok := i.([]interface{}) + if !ok { + return []PolicyDryRunSpecRules{} + } + + if len(a) == 0 { + return []PolicyDryRunSpecRules{} + } + + items := make([]PolicyDryRunSpecRules, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicyDryRunSpecRules(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicyDryRunSpecRules expands an instance of PolicyDryRunSpecRules into a JSON +// request object. +func expandPolicyDryRunSpecRules(c *Client, f *PolicyDryRunSpecRules, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandPolicyDryRunSpecRulesValues(c, f.Values, res); err != nil { + return nil, fmt.Errorf("error expanding Values into values: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["values"] = v + } + if v := f.AllowAll; !dcl.IsEmptyValueIndirect(v) { + m["allowAll"] = v + } + if v := f.DenyAll; !dcl.IsEmptyValueIndirect(v) { + m["denyAll"] = v + } + if v := f.Enforce; !dcl.IsEmptyValueIndirect(v) { + m["enforce"] = v + } + if v, err := expandPolicyDryRunSpecRulesCondition(c, f.Condition, res); err != nil { + return nil, fmt.Errorf("error expanding Condition into condition: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["condition"] = v + } + + return m, nil +} + +// flattenPolicyDryRunSpecRules flattens an instance of PolicyDryRunSpecRules from a JSON +// response object. +func flattenPolicyDryRunSpecRules(c *Client, i interface{}, res *Policy) *PolicyDryRunSpecRules { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicyDryRunSpecRules{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicyDryRunSpecRules + } + r.Values = flattenPolicyDryRunSpecRulesValues(c, m["values"], res) + r.AllowAll = dcl.FlattenBool(m["allowAll"]) + r.DenyAll = dcl.FlattenBool(m["denyAll"]) + r.Enforce = dcl.FlattenBool(m["enforce"]) + r.Condition = flattenPolicyDryRunSpecRulesCondition(c, m["condition"], res) + + return r +} + +// expandPolicyDryRunSpecRulesValuesMap expands the contents of PolicyDryRunSpecRulesValues into a JSON +// request object. +func expandPolicyDryRunSpecRulesValuesMap(c *Client, f map[string]PolicyDryRunSpecRulesValues, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicyDryRunSpecRulesValues(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicyDryRunSpecRulesValuesSlice expands the contents of PolicyDryRunSpecRulesValues into a JSON +// request object. +func expandPolicyDryRunSpecRulesValuesSlice(c *Client, f []PolicyDryRunSpecRulesValues, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicyDryRunSpecRulesValues(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicyDryRunSpecRulesValuesMap flattens the contents of PolicyDryRunSpecRulesValues from a JSON +// response object. +func flattenPolicyDryRunSpecRulesValuesMap(c *Client, i interface{}, res *Policy) map[string]PolicyDryRunSpecRulesValues { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicyDryRunSpecRulesValues{} + } + + if len(a) == 0 { + return map[string]PolicyDryRunSpecRulesValues{} + } + + items := make(map[string]PolicyDryRunSpecRulesValues) + for k, item := range a { + items[k] = *flattenPolicyDryRunSpecRulesValues(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicyDryRunSpecRulesValuesSlice flattens the contents of PolicyDryRunSpecRulesValues from a JSON +// response object. +func flattenPolicyDryRunSpecRulesValuesSlice(c *Client, i interface{}, res *Policy) []PolicyDryRunSpecRulesValues { + a, ok := i.([]interface{}) + if !ok { + return []PolicyDryRunSpecRulesValues{} + } + + if len(a) == 0 { + return []PolicyDryRunSpecRulesValues{} + } + + items := make([]PolicyDryRunSpecRulesValues, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicyDryRunSpecRulesValues(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicyDryRunSpecRulesValues expands an instance of PolicyDryRunSpecRulesValues into a JSON +// request object. +func expandPolicyDryRunSpecRulesValues(c *Client, f *PolicyDryRunSpecRulesValues, res *Policy) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.AllowedValues; v != nil { + m["allowedValues"] = v + } + if v := f.DeniedValues; v != nil { + m["deniedValues"] = v + } + + return m, nil +} + +// flattenPolicyDryRunSpecRulesValues flattens an instance of PolicyDryRunSpecRulesValues from a JSON +// response object. +func flattenPolicyDryRunSpecRulesValues(c *Client, i interface{}, res *Policy) *PolicyDryRunSpecRulesValues { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicyDryRunSpecRulesValues{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicyDryRunSpecRulesValues + } + r.AllowedValues = dcl.FlattenStringSlice(m["allowedValues"]) + r.DeniedValues = dcl.FlattenStringSlice(m["deniedValues"]) + + return r +} + +// expandPolicyDryRunSpecRulesConditionMap expands the contents of PolicyDryRunSpecRulesCondition into a JSON +// request object. +func expandPolicyDryRunSpecRulesConditionMap(c *Client, f map[string]PolicyDryRunSpecRulesCondition, res *Policy) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandPolicyDryRunSpecRulesCondition(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandPolicyDryRunSpecRulesConditionSlice expands the contents of PolicyDryRunSpecRulesCondition into a JSON +// request object. +func expandPolicyDryRunSpecRulesConditionSlice(c *Client, f []PolicyDryRunSpecRulesCondition, res *Policy) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandPolicyDryRunSpecRulesCondition(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenPolicyDryRunSpecRulesConditionMap flattens the contents of PolicyDryRunSpecRulesCondition from a JSON +// response object. +func flattenPolicyDryRunSpecRulesConditionMap(c *Client, i interface{}, res *Policy) map[string]PolicyDryRunSpecRulesCondition { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]PolicyDryRunSpecRulesCondition{} + } + + if len(a) == 0 { + return map[string]PolicyDryRunSpecRulesCondition{} + } + + items := make(map[string]PolicyDryRunSpecRulesCondition) + for k, item := range a { + items[k] = *flattenPolicyDryRunSpecRulesCondition(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenPolicyDryRunSpecRulesConditionSlice flattens the contents of PolicyDryRunSpecRulesCondition from a JSON +// response object. +func flattenPolicyDryRunSpecRulesConditionSlice(c *Client, i interface{}, res *Policy) []PolicyDryRunSpecRulesCondition { + a, ok := i.([]interface{}) + if !ok { + return []PolicyDryRunSpecRulesCondition{} + } + + if len(a) == 0 { + return []PolicyDryRunSpecRulesCondition{} + } + + items := make([]PolicyDryRunSpecRulesCondition, 0, len(a)) + for _, item := range a { + items = append(items, *flattenPolicyDryRunSpecRulesCondition(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandPolicyDryRunSpecRulesCondition expands an instance of PolicyDryRunSpecRulesCondition into a JSON +// request object. +func expandPolicyDryRunSpecRulesCondition(c *Client, f *PolicyDryRunSpecRulesCondition, res *Policy) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Expression; !dcl.IsEmptyValueIndirect(v) { + m["expression"] = v + } + if v := f.Title; !dcl.IsEmptyValueIndirect(v) { + m["title"] = v + } + if v := f.Description; !dcl.IsEmptyValueIndirect(v) { + m["description"] = v + } + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenPolicyDryRunSpecRulesCondition flattens an instance of PolicyDryRunSpecRulesCondition from a JSON +// response object. +func flattenPolicyDryRunSpecRulesCondition(c *Client, i interface{}, res *Policy) *PolicyDryRunSpecRulesCondition { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &PolicyDryRunSpecRulesCondition{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyPolicyDryRunSpecRulesCondition + } + r.Expression = dcl.FlattenString(m["expression"]) + r.Title = dcl.FlattenString(m["title"]) + r.Description = dcl.FlattenString(m["description"]) + r.Location = dcl.FlattenString(m["location"]) + + return r +} + +// This function returns a matcher that checks whether a serialized resource matches this resource +// in its parameters (as defined by the fields in a Get, which definitionally define resource +// identity). This is useful in extracting the element from a List call. +func (r *Policy) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalPolicy(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if nr.Parent == nil && ncr.Parent == nil { + c.Config.Logger.Info("Both Parent fields null - considering equal.") + } else if nr.Parent == nil || ncr.Parent == nil { + c.Config.Logger.Info("Only one Parent field is null - considering unequal.") + return false + } else if *nr.Parent != *ncr.Parent { + return false + } + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + return true + } +} + +type policyDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp policyApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToPolicyDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]policyDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []policyDiff + // For each operation name, create a policyDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := policyDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToPolicyApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToPolicyApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (policyApiOperation, error) { + switch opName { + + case "updatePolicyUpdatePolicyOperation": + return &updatePolicyUpdatePolicyOperation{FieldDiffs: fieldDiffs}, nil + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractPolicyFields(r *Policy) error { + vSpec := r.Spec + if vSpec == nil { + // note: explicitly not the empty object. + vSpec = &PolicySpec{} + } + if err := extractPolicySpecFields(r, vSpec); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSpec) { + r.Spec = vSpec + } + vDryRunSpec := r.DryRunSpec + if vDryRunSpec == nil { + // note: explicitly not the empty object. + vDryRunSpec = &PolicyDryRunSpec{} + } + if err := extractPolicyDryRunSpecFields(r, vDryRunSpec); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vDryRunSpec) { + r.DryRunSpec = vDryRunSpec + } + return nil +} +func extractPolicySpecFields(r *Policy, o *PolicySpec) error { + return nil +} +func extractPolicySpecRulesFields(r *Policy, o *PolicySpecRules) error { + vValues := o.Values + if vValues == nil { + // note: explicitly not the empty object. + vValues = &PolicySpecRulesValues{} + } + if err := extractPolicySpecRulesValuesFields(r, vValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vValues) { + o.Values = vValues + } + vCondition := o.Condition + if vCondition == nil { + // note: explicitly not the empty object. + vCondition = &PolicySpecRulesCondition{} + } + if err := extractPolicySpecRulesConditionFields(r, vCondition); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCondition) { + o.Condition = vCondition + } + return nil +} +func extractPolicySpecRulesValuesFields(r *Policy, o *PolicySpecRulesValues) error { + return nil +} +func extractPolicySpecRulesConditionFields(r *Policy, o *PolicySpecRulesCondition) error { + return nil +} +func extractPolicyDryRunSpecFields(r *Policy, o *PolicyDryRunSpec) error { + return nil +} +func extractPolicyDryRunSpecRulesFields(r *Policy, o *PolicyDryRunSpecRules) error { + vValues := o.Values + if vValues == nil { + // note: explicitly not the empty object. + vValues = &PolicyDryRunSpecRulesValues{} + } + if err := extractPolicyDryRunSpecRulesValuesFields(r, vValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vValues) { + o.Values = vValues + } + vCondition := o.Condition + if vCondition == nil { + // note: explicitly not the empty object. + vCondition = &PolicyDryRunSpecRulesCondition{} + } + if err := extractPolicyDryRunSpecRulesConditionFields(r, vCondition); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCondition) { + o.Condition = vCondition + } + return nil +} +func extractPolicyDryRunSpecRulesValuesFields(r *Policy, o *PolicyDryRunSpecRulesValues) error { + return nil +} +func extractPolicyDryRunSpecRulesConditionFields(r *Policy, o *PolicyDryRunSpecRulesCondition) error { + return nil +} + +func postReadExtractPolicyFields(r *Policy) error { + vSpec := r.Spec + if vSpec == nil { + // note: explicitly not the empty object. + vSpec = &PolicySpec{} + } + if err := postReadExtractPolicySpecFields(r, vSpec); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSpec) { + r.Spec = vSpec + } + vDryRunSpec := r.DryRunSpec + if vDryRunSpec == nil { + // note: explicitly not the empty object. + vDryRunSpec = &PolicyDryRunSpec{} + } + if err := postReadExtractPolicyDryRunSpecFields(r, vDryRunSpec); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vDryRunSpec) { + r.DryRunSpec = vDryRunSpec + } + return nil +} +func postReadExtractPolicySpecFields(r *Policy, o *PolicySpec) error { + return nil +} +func postReadExtractPolicySpecRulesFields(r *Policy, o *PolicySpecRules) error { + vValues := o.Values + if vValues == nil { + // note: explicitly not the empty object. + vValues = &PolicySpecRulesValues{} + } + if err := extractPolicySpecRulesValuesFields(r, vValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vValues) { + o.Values = vValues + } + vCondition := o.Condition + if vCondition == nil { + // note: explicitly not the empty object. + vCondition = &PolicySpecRulesCondition{} + } + if err := extractPolicySpecRulesConditionFields(r, vCondition); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCondition) { + o.Condition = vCondition + } + return nil +} +func postReadExtractPolicySpecRulesValuesFields(r *Policy, o *PolicySpecRulesValues) error { + return nil +} +func postReadExtractPolicySpecRulesConditionFields(r *Policy, o *PolicySpecRulesCondition) error { + return nil +} +func postReadExtractPolicyDryRunSpecFields(r *Policy, o *PolicyDryRunSpec) error { + return nil +} +func postReadExtractPolicyDryRunSpecRulesFields(r *Policy, o *PolicyDryRunSpecRules) error { + vValues := o.Values + if vValues == nil { + // note: explicitly not the empty object. + vValues = &PolicyDryRunSpecRulesValues{} + } + if err := extractPolicyDryRunSpecRulesValuesFields(r, vValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vValues) { + o.Values = vValues + } + vCondition := o.Condition + if vCondition == nil { + // note: explicitly not the empty object. + vCondition = &PolicyDryRunSpecRulesCondition{} + } + if err := extractPolicyDryRunSpecRulesConditionFields(r, vCondition); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCondition) { + o.Condition = vCondition + } + return nil +} +func postReadExtractPolicyDryRunSpecRulesValuesFields(r *Policy, o *PolicyDryRunSpecRulesValues) error { + return nil +} +func postReadExtractPolicyDryRunSpecRulesConditionFields(r *Policy, o *PolicyDryRunSpecRulesCondition) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_schema.go new file mode 100644 index 00000000000..5fab9f8a080 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_schema.go @@ -0,0 +1,433 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package orgpolicy + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLPolicySchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "OrgPolicy/Policy", + Description: "An organization policy gives you programmatic control over your organization's cloud resources. Using Organization Policies, you will be able to configure constraints across your entire resource hierarchy.", + StructName: "Policy", + Reference: &dcl.Link{ + Text: "REST API", + URL: "https://cloud.google.com/resource-manager/docs/reference/orgpolicy/rest/v2/organizations.policies", + }, + Guides: []*dcl.Link{ + &dcl.Link{ + Text: "Understanding Org Policy concepts", + URL: "https://cloud.google.com/resource-manager/docs/organization-policy/overview", + }, + &dcl.Link{ + Text: "The resource hierarchy", + URL: "https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy", + }, + &dcl.Link{ + Text: "All valid constraints", + URL: "https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints", + }, + }, + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a Policy", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "policy", + Required: true, + Description: "A full instance of a Policy", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a Policy", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "policy", + Required: true, + Description: "A full instance of a Policy", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a Policy", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "policy", + Required: true, + Description: "A full instance of a Policy", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all Policy", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "parent", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many Policy", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "parent", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "Policy": &dcl.Component{ + Title: "Policy", + ID: "{{parent}}/policies/{{name}}", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "name", + "parent", + }, + Properties: map[string]*dcl.Property{ + "dryRunSpec": &dcl.Property{ + Type: "object", + GoName: "DryRunSpec", + GoType: "PolicyDryRunSpec", + Description: "Dry-run policy. Audit-only policy, can be used to monitor how the policy would have impacted the existing and future resources if it's enforced.", + Properties: map[string]*dcl.Property{ + "etag": &dcl.Property{ + Type: "string", + GoName: "Etag", + ReadOnly: true, + Description: "An opaque tag indicating the current version of the policy, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the policy` is returned from either a `GetPolicy` or a `ListPolicies` request, this `etag` indicates the version of the current policy to use when executing a read-modify-write loop. When the policy is returned from a `GetEffectivePolicy` request, the `etag` will be unset.", + }, + "inheritFromParent": &dcl.Property{ + Type: "boolean", + GoName: "InheritFromParent", + Description: "Determines the inheritance behavior for this policy. If `inherit_from_parent` is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies which configure list constraints.", + }, + "reset": &dcl.Property{ + Type: "boolean", + GoName: "Reset", + Description: "Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.", + }, + "rules": &dcl.Property{ + Type: "array", + GoName: "Rules", + Description: "In policies for boolean constraints, the following requirements apply: - There must be one and only one policy rule where condition is unset. - Boolean policy rules with conditions must set `enforced` to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "PolicyDryRunSpecRules", + Properties: map[string]*dcl.Property{ + "allowAll": &dcl.Property{ + Type: "boolean", + GoName: "AllowAll", + Description: "Setting this to `\"TRUE\"` means that all values are allowed. This field can be set only in policies for list constraints.", + Conflicts: []string{ + "values", + "denyAll", + "enforce", + }, + }, + "condition": &dcl.Property{ + Type: "object", + GoName: "Condition", + GoType: "PolicyDryRunSpecRulesCondition", + Description: "A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr' must include from 1 to 10 subexpressions, joined by the \"||\" or \"&&\" operators. Each subexpression must be of the form \"resource.matchTag('/tag_key_short_name, 'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')\". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: \"resource.matchTag('123456789/environment, 'prod')\". or \"resource.matchTagId('tagKeys/123', 'tagValues/456')\".", + Properties: map[string]*dcl.Property{ + "description": &dcl.Property{ + Type: "string", + GoName: "Description", + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, + "expression": &dcl.Property{ + Type: "string", + GoName: "Expression", + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, + "title": &dcl.Property{ + Type: "string", + GoName: "Title", + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, + }, + "denyAll": &dcl.Property{ + Type: "boolean", + GoName: "DenyAll", + Description: "Setting this to `\"TRUE\"` means that all values are denied. This field can be set only in policies for list constraints.", + Conflicts: []string{ + "values", + "allowAll", + "enforce", + }, + }, + "enforce": &dcl.Property{ + Type: "boolean", + GoName: "Enforce", + Description: "If `\"TRUE\"`, then the policy is enforced. If `\"FALSE\"`, then any configuration is acceptable. This field can be set only in policies for boolean constraints.", + Conflicts: []string{ + "values", + "allowAll", + "denyAll", + }, + }, + "values": &dcl.Property{ + Type: "object", + GoName: "Values", + GoType: "PolicyDryRunSpecRulesValues", + Description: "List of values to be used for this policy rule. This field can be set only in policies for list constraints.", + Conflicts: []string{ + "allowAll", + "denyAll", + "enforce", + }, + Properties: map[string]*dcl.Property{ + "allowedValues": &dcl.Property{ + Type: "array", + GoName: "AllowedValues", + Description: "List of values allowed at this resource.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "deniedValues": &dcl.Property{ + Type: "array", + GoName: "DeniedValues", + Description: "List of values denied at this resource.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + }, + "updateTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "UpdateTime", + ReadOnly: true, + Description: "Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that policy.", + }, + }, + }, + "etag": &dcl.Property{ + Type: "string", + GoName: "Etag", + ReadOnly: true, + Description: "Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.", + Immutable: true, + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * `projects/{project_number}/policies/{constraint_name}` * `folders/{folder_id}/policies/{constraint_name}` * `organizations/{organization_id}/policies/{constraint_name}` For example, \"projects/123/policies/compute.disableSerialPortAccess\". Note: `projects/{project_id}/policies/{constraint_name}` is also an acceptable name for API requests, but responses will return the name using the equivalent project number.", + Immutable: true, + HasLongForm: true, + }, + "parent": &dcl.Property{ + Type: "string", + GoName: "Parent", + Description: "The parent of the resource.", + Immutable: true, + ForwardSlashAllowed: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Folder", + Field: "name", + Parent: true, + }, + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Organization", + Field: "name", + Parent: true, + }, + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "spec": &dcl.Property{ + Type: "object", + GoName: "Spec", + GoType: "PolicySpec", + Description: "Basic information about the Organization Policy.", + Properties: map[string]*dcl.Property{ + "etag": &dcl.Property{ + Type: "string", + GoName: "Etag", + ReadOnly: true, + Description: "An opaque tag indicating the current version of the `Policy`, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the `Policy` is returned from either a `GetPolicy` or a `ListPolicies` request, this `etag` indicates the version of the current `Policy` to use when executing a read-modify-write loop. When the `Policy` is returned from a `GetEffectivePolicy` request, the `etag` will be unset.", + }, + "inheritFromParent": &dcl.Property{ + Type: "boolean", + GoName: "InheritFromParent", + Description: "Determines the inheritance behavior for this `Policy`. If `inherit_from_parent` is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.", + }, + "reset": &dcl.Property{ + Type: "boolean", + GoName: "Reset", + Description: "Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific `Constraint` at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.", + }, + "rules": &dcl.Property{ + Type: "array", + GoName: "Rules", + Description: "Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set `enforced` to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "PolicySpecRules", + Properties: map[string]*dcl.Property{ + "allowAll": &dcl.Property{ + Type: "boolean", + GoName: "AllowAll", + Description: "Setting this to `\"TRUE\"` means that all values are allowed. This field can be set only in Policies for list constraints.", + Conflicts: []string{ + "values", + "denyAll", + "enforce", + }, + }, + "condition": &dcl.Property{ + Type: "object", + GoName: "Condition", + GoType: "PolicySpecRulesCondition", + Description: "A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr' must include from 1 to 10 subexpressions, joined by the \"||\" or \"&&\" operators. Each subexpression must be of the form \"resource.matchTag('/tag_key_short_name, 'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')\". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: \"resource.matchTag('123456789/environment, 'prod')\". or \"resource.matchTagId('tagKeys/123', 'tagValues/456')\".", + Properties: map[string]*dcl.Property{ + "description": &dcl.Property{ + Type: "string", + GoName: "Description", + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, + "expression": &dcl.Property{ + Type: "string", + GoName: "Expression", + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, + "title": &dcl.Property{ + Type: "string", + GoName: "Title", + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, + }, + "denyAll": &dcl.Property{ + Type: "boolean", + GoName: "DenyAll", + Description: "Setting this to `\"TRUE\"` means that all values are denied. This field can be set only in Policies for list constraints.", + Conflicts: []string{ + "values", + "allowAll", + "enforce", + }, + }, + "enforce": &dcl.Property{ + Type: "boolean", + GoName: "Enforce", + Description: "If `\"TRUE\"`, then the `Policy` is enforced. If `\"FALSE\"`, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.", + Conflicts: []string{ + "values", + "allowAll", + "denyAll", + }, + }, + "values": &dcl.Property{ + Type: "object", + GoName: "Values", + GoType: "PolicySpecRulesValues", + Description: "List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.", + Conflicts: []string{ + "allowAll", + "denyAll", + "enforce", + }, + Properties: map[string]*dcl.Property{ + "allowedValues": &dcl.Property{ + Type: "array", + GoName: "AllowedValues", + Description: "List of values allowed at this resource.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "deniedValues": &dcl.Property{ + Type: "array", + GoName: "DeniedValues", + Description: "List of values denied at this resource.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + }, + "updateTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "UpdateTime", + ReadOnly: true, + Description: "Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that `Policy`.", + }, + }, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_yaml_embed.go new file mode 100644 index 00000000000..fb14dbfd12f --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/policy_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package orgpolicy -var YAML_policy blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/orgpolicy/policy.yaml + +package orgpolicy + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/orgpolicy/policy.yaml +var YAML_policy = []byte("info:\n title: OrgPolicy/Policy\n description: An organization policy gives you programmatic control over your organization's\n cloud resources. Using Organization Policies, you will be able to configure constraints\n across your entire resource hierarchy.\n x-dcl-struct-name: Policy\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/resource-manager/docs/reference/orgpolicy/rest/v2/organizations.policies\n x-dcl-guides:\n - text: Understanding Org Policy concepts\n url: https://cloud.google.com/resource-manager/docs/organization-policy/overview\n - text: The resource hierarchy\n url: https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy\n - text: All valid constraints\n url: https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints\npaths:\n get:\n description: The function used to get information about a Policy\n parameters:\n - name: policy\n required: true\n description: A full instance of a Policy\n apply:\n description: The function used to apply information about a Policy\n parameters:\n - name: policy\n required: true\n description: A full instance of a Policy\n delete:\n description: The function used to delete a Policy\n parameters:\n - name: policy\n required: true\n description: A full instance of a Policy\n deleteAll:\n description: The function used to delete all Policy\n parameters:\n - name: parent\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Policy\n parameters:\n - name: parent\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Policy:\n title: Policy\n x-dcl-id: '{{parent}}/policies/{{name}}'\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - parent\n properties:\n dryRunSpec:\n type: object\n x-dcl-go-name: DryRunSpec\n x-dcl-go-type: PolicyDryRunSpec\n description: Dry-run policy. Audit-only policy, can be used to monitor how\n the policy would have impacted the existing and future resources if it's\n enforced.\n properties:\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: An opaque tag indicating the current version of the policy,\n used for concurrency control. This field is ignored if used in a `CreatePolicy`\n request. When the policy` is returned from either a `GetPolicy` or\n a `ListPolicies` request, this `etag` indicates the version of the\n current policy to use when executing a read-modify-write loop. When\n the policy is returned from a `GetEffectivePolicy` request, the `etag`\n will be unset.\n inheritFromParent:\n type: boolean\n x-dcl-go-name: InheritFromParent\n description: Determines the inheritance behavior for this policy. If\n `inherit_from_parent` is true, policy rules set higher up in the hierarchy\n (up to the closest root) are inherited and present in the effective\n policy. If it is false, then no rules are inherited, and this policy\n becomes the new root for evaluation. This field can be set only for\n policies which configure list constraints.\n reset:\n type: boolean\n x-dcl-go-name: Reset\n description: Ignores policies set above this resource and restores the\n `constraint_default` enforcement behavior of the specific constraint\n at this resource. This field can be set in policies for either list\n or boolean constraints. If set, `rules` must be empty and `inherit_from_parent`\n must be set to false.\n rules:\n type: array\n x-dcl-go-name: Rules\n description: 'In policies for boolean constraints, the following requirements\n apply: - There must be one and only one policy rule where condition\n is unset. - Boolean policy rules with conditions must set `enforced`\n to the opposite of the policy rule without a condition. - During policy\n evaluation, policy rules with conditions that are true for a target\n resource take precedence.'\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: PolicyDryRunSpecRules\n properties:\n allowAll:\n type: boolean\n x-dcl-go-name: AllowAll\n description: Setting this to `\"TRUE\"` means that all values are\n allowed. This field can be set only in policies for list constraints.\n x-dcl-conflicts:\n - values\n - denyAll\n - enforce\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: PolicyDryRunSpecRulesCondition\n description: 'A condition which determines whether this rule is\n used in the evaluation of the policy. When set, the `expression`\n field in the `Expr'' must include from 1 to 10 subexpressions,\n joined by the \"||\" or \"&&\" operators. Each subexpression must\n be of the form \"resource.matchTag(''/tag_key_short_name, ''tag_value_short_name'')\".\n or \"resource.matchTagId(''tagKeys/key_id'', ''tagValues/value_id'')\".\n where key_name and value_name are the resource names for Label\n Keys and Values. These names are available from the Tag Manager\n Service. An example expression is: \"resource.matchTag(''123456789/environment,\n ''prod'')\". or \"resource.matchTagId(''tagKeys/123'', ''tagValues/456'')\".'\n properties:\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the expression. This\n is a longer text which describes the expression, e.g. when\n hovered over it in a UI.\n expression:\n type: string\n x-dcl-go-name: Expression\n description: Textual representation of an expression in Common\n Expression Language syntax.\n location:\n type: string\n x-dcl-go-name: Location\n description: Optional. String indicating the location of the\n expression for error reporting, e.g. a file name and a position\n in the file.\n title:\n type: string\n x-dcl-go-name: Title\n description: Optional. Title for the expression, i.e. a short\n string describing its purpose. This can be used e.g. in\n UIs which allow to enter the expression.\n denyAll:\n type: boolean\n x-dcl-go-name: DenyAll\n description: Setting this to `\"TRUE\"` means that all values are\n denied. This field can be set only in policies for list constraints.\n x-dcl-conflicts:\n - values\n - allowAll\n - enforce\n enforce:\n type: boolean\n x-dcl-go-name: Enforce\n description: If `\"TRUE\"`, then the policy is enforced. If `\"FALSE\"`,\n then any configuration is acceptable. This field can be set\n only in policies for boolean constraints.\n x-dcl-conflicts:\n - values\n - allowAll\n - denyAll\n values:\n type: object\n x-dcl-go-name: Values\n x-dcl-go-type: PolicyDryRunSpecRulesValues\n description: List of values to be used for this policy rule. This\n field can be set only in policies for list constraints.\n x-dcl-conflicts:\n - allowAll\n - denyAll\n - enforce\n properties:\n allowedValues:\n type: array\n x-dcl-go-name: AllowedValues\n description: List of values allowed at this resource.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n deniedValues:\n type: array\n x-dcl-go-name: DeniedValues\n description: List of values denied at this resource.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. The time stamp this was previously updated.\n This represents the last time a call to `CreatePolicy` or `UpdatePolicy`\n was made for that policy.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. An opaque tag indicating the current state of the\n policy, used for concurrency control. This 'etag' is computed by the server\n based on the value of other fields, and may be sent on update and delete\n requests to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n name:\n type: string\n x-dcl-go-name: Name\n description: 'Immutable. The resource name of the Policy. Must be one of\n the following forms, where constraint_name is the name of the constraint\n which this Policy configures: * `projects/{project_number}/policies/{constraint_name}`\n * `folders/{folder_id}/policies/{constraint_name}` * `organizations/{organization_id}/policies/{constraint_name}`\n For example, \"projects/123/policies/compute.disableSerialPortAccess\".\n Note: `projects/{project_id}/policies/{constraint_name}` is also an acceptable\n name for API requests, but responses will return the name using the equivalent\n project number.'\n x-kubernetes-immutable: true\n x-dcl-has-long-form: true\n parent:\n type: string\n x-dcl-go-name: Parent\n description: The parent of the resource.\n x-kubernetes-immutable: true\n x-dcl-forward-slash-allowed: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Folder\n field: name\n parent: true\n - resource: Cloudresourcemanager/Organization\n field: name\n parent: true\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n spec:\n type: object\n x-dcl-go-name: Spec\n x-dcl-go-type: PolicySpec\n description: Basic information about the Organization Policy.\n properties:\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: An opaque tag indicating the current version of the `Policy`,\n used for concurrency control. This field is ignored if used in a `CreatePolicy`\n request. When the `Policy` is returned from either a `GetPolicy` or\n a `ListPolicies` request, this `etag` indicates the version of the\n current `Policy` to use when executing a read-modify-write loop. When\n the `Policy` is returned from a `GetEffectivePolicy` request, the\n `etag` will be unset.\n inheritFromParent:\n type: boolean\n x-dcl-go-name: InheritFromParent\n description: Determines the inheritance behavior for this `Policy`.\n If `inherit_from_parent` is true, PolicyRules set higher up in the\n hierarchy (up to the closest root) are inherited and present in the\n effective policy. If it is false, then no rules are inherited, and\n this Policy becomes the new root for evaluation. This field can be\n set only for Policies which configure list constraints.\n reset:\n type: boolean\n x-dcl-go-name: Reset\n description: Ignores policies set above this resource and restores the\n `constraint_default` enforcement behavior of the specific `Constraint`\n at this resource. This field can be set in policies for either list\n or boolean constraints. If set, `rules` must be empty and `inherit_from_parent`\n must be set to false.\n rules:\n type: array\n x-dcl-go-name: Rules\n description: 'Up to 10 PolicyRules are allowed. In Policies for boolean\n constraints, the following requirements apply: - There must be one\n and only one PolicyRule where condition is unset. - BooleanPolicyRules\n with conditions must set `enforced` to the opposite of the PolicyRule\n without a condition. - During policy evaluation, PolicyRules with\n conditions that are true for a target resource take precedence.'\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: PolicySpecRules\n properties:\n allowAll:\n type: boolean\n x-dcl-go-name: AllowAll\n description: Setting this to `\"TRUE\"` means that all values are\n allowed. This field can be set only in Policies for list constraints.\n x-dcl-conflicts:\n - values\n - denyAll\n - enforce\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: PolicySpecRulesCondition\n description: 'A condition which determines whether this rule is\n used in the evaluation of the policy. When set, the `expression`\n field in the `Expr'' must include from 1 to 10 subexpressions,\n joined by the \"||\" or \"&&\" operators. Each subexpression must\n be of the form \"resource.matchTag(''/tag_key_short_name, ''tag_value_short_name'')\".\n or \"resource.matchTagId(''tagKeys/key_id'', ''tagValues/value_id'')\".\n where key_name and value_name are the resource names for Label\n Keys and Values. These names are available from the Tag Manager\n Service. An example expression is: \"resource.matchTag(''123456789/environment,\n ''prod'')\". or \"resource.matchTagId(''tagKeys/123'', ''tagValues/456'')\".'\n properties:\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the expression. This\n is a longer text which describes the expression, e.g. when\n hovered over it in a UI.\n expression:\n type: string\n x-dcl-go-name: Expression\n description: Textual representation of an expression in Common\n Expression Language syntax.\n location:\n type: string\n x-dcl-go-name: Location\n description: Optional. String indicating the location of the\n expression for error reporting, e.g. a file name and a position\n in the file.\n title:\n type: string\n x-dcl-go-name: Title\n description: Optional. Title for the expression, i.e. a short\n string describing its purpose. This can be used e.g. in\n UIs which allow to enter the expression.\n denyAll:\n type: boolean\n x-dcl-go-name: DenyAll\n description: Setting this to `\"TRUE\"` means that all values are\n denied. This field can be set only in Policies for list constraints.\n x-dcl-conflicts:\n - values\n - allowAll\n - enforce\n enforce:\n type: boolean\n x-dcl-go-name: Enforce\n description: If `\"TRUE\"`, then the `Policy` is enforced. If `\"FALSE\"`,\n then any configuration is acceptable. This field can be set\n only in Policies for boolean constraints.\n x-dcl-conflicts:\n - values\n - allowAll\n - denyAll\n values:\n type: object\n x-dcl-go-name: Values\n x-dcl-go-type: PolicySpecRulesValues\n description: List of values to be used for this PolicyRule. This\n field can be set only in Policies for list constraints.\n x-dcl-conflicts:\n - allowAll\n - denyAll\n - enforce\n properties:\n allowedValues:\n type: array\n x-dcl-go-name: AllowedValues\n description: List of values allowed at this resource.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n deniedValues:\n type: array\n x-dcl-go-name: DeniedValues\n description: List of values denied at this resource.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. The time stamp this was previously updated.\n This represents the last time a call to `CreatePolicy` or `UpdatePolicy`\n was made for that `Policy`.\n") + +// 20144 bytes +// MD5: 90c4c3b56e0ac3a655cc54d7b202325f diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool.go new file mode 100644 index 00000000000..2c8d9644411 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool.go @@ -0,0 +1,1444 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type CaPool struct { + Name *string `json:"name"` + Tier *CaPoolTierEnum `json:"tier"` + IssuancePolicy *CaPoolIssuancePolicy `json:"issuancePolicy"` + PublishingOptions *CaPoolPublishingOptions `json:"publishingOptions"` + Labels map[string]string `json:"labels"` + Project *string `json:"project"` + Location *string `json:"location"` +} + +func (r *CaPool) String() string { + return dcl.SprintResource(r) +} + +// The enum CaPoolTierEnum. +type CaPoolTierEnum string + +// CaPoolTierEnumRef returns a *CaPoolTierEnum with the value of string s +// If the empty string is provided, nil is returned. +func CaPoolTierEnumRef(s string) *CaPoolTierEnum { + v := CaPoolTierEnum(s) + return &v +} + +func (v CaPoolTierEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"TIER_UNSPECIFIED", "ENTERPRISE", "DEVOPS"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CaPoolTierEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum. +type CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum string + +// CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumRef returns a *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum with the value of string s +// If the empty string is provided, nil is returned. +func CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumRef(s string) *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum { + v := CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum(s) + return &v +} + +func (v CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"EC_SIGNATURE_ALGORITHM_UNSPECIFIED", "ECDSA_P256", "ECDSA_P384", "EDDSA_25519"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum. +type CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum string + +// CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumRef returns a *CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum with the value of string s +// If the empty string is provided, nil is returned. +func CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumRef(s string) *CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum { + v := CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum(s) + return &v +} + +func (v CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED", "BASE_KEY_USAGE", "EXTENDED_KEY_USAGE", "CA_OPTIONS", "POLICY_IDS", "AIA_OCSP_SERVERS"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum", + Value: string(v), + Valid: []string{}, + } +} + +type CaPoolIssuancePolicy struct { + empty bool `json:"-"` + AllowedKeyTypes []CaPoolIssuancePolicyAllowedKeyTypes `json:"allowedKeyTypes"` + MaximumLifetime *string `json:"maximumLifetime"` + AllowedIssuanceModes *CaPoolIssuancePolicyAllowedIssuanceModes `json:"allowedIssuanceModes"` + BaselineValues *CaPoolIssuancePolicyBaselineValues `json:"baselineValues"` + IdentityConstraints *CaPoolIssuancePolicyIdentityConstraints `json:"identityConstraints"` + PassthroughExtensions *CaPoolIssuancePolicyPassthroughExtensions `json:"passthroughExtensions"` +} + +type jsonCaPoolIssuancePolicy CaPoolIssuancePolicy + +func (r *CaPoolIssuancePolicy) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicy + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicy + } else { + + r.AllowedKeyTypes = res.AllowedKeyTypes + + r.MaximumLifetime = res.MaximumLifetime + + r.AllowedIssuanceModes = res.AllowedIssuanceModes + + r.BaselineValues = res.BaselineValues + + r.IdentityConstraints = res.IdentityConstraints + + r.PassthroughExtensions = res.PassthroughExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicy is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicy *CaPoolIssuancePolicy = &CaPoolIssuancePolicy{empty: true} + +func (r *CaPoolIssuancePolicy) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicy) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicy) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyAllowedKeyTypes struct { + empty bool `json:"-"` + Rsa *CaPoolIssuancePolicyAllowedKeyTypesRsa `json:"rsa"` + EllipticCurve *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve `json:"ellipticCurve"` +} + +type jsonCaPoolIssuancePolicyAllowedKeyTypes CaPoolIssuancePolicyAllowedKeyTypes + +func (r *CaPoolIssuancePolicyAllowedKeyTypes) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyAllowedKeyTypes + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyAllowedKeyTypes + } else { + + r.Rsa = res.Rsa + + r.EllipticCurve = res.EllipticCurve + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyAllowedKeyTypes is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyAllowedKeyTypes *CaPoolIssuancePolicyAllowedKeyTypes = &CaPoolIssuancePolicyAllowedKeyTypes{empty: true} + +func (r *CaPoolIssuancePolicyAllowedKeyTypes) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyAllowedKeyTypes) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyAllowedKeyTypes) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyAllowedKeyTypesRsa struct { + empty bool `json:"-"` + MinModulusSize *int64 `json:"minModulusSize"` + MaxModulusSize *int64 `json:"maxModulusSize"` +} + +type jsonCaPoolIssuancePolicyAllowedKeyTypesRsa CaPoolIssuancePolicyAllowedKeyTypesRsa + +func (r *CaPoolIssuancePolicyAllowedKeyTypesRsa) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyAllowedKeyTypesRsa + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyAllowedKeyTypesRsa + } else { + + r.MinModulusSize = res.MinModulusSize + + r.MaxModulusSize = res.MaxModulusSize + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyAllowedKeyTypesRsa is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyAllowedKeyTypesRsa *CaPoolIssuancePolicyAllowedKeyTypesRsa = &CaPoolIssuancePolicyAllowedKeyTypesRsa{empty: true} + +func (r *CaPoolIssuancePolicyAllowedKeyTypesRsa) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyAllowedKeyTypesRsa) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyAllowedKeyTypesRsa) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve struct { + empty bool `json:"-"` + SignatureAlgorithm *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum `json:"signatureAlgorithm"` +} + +type jsonCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + +func (r *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + } else { + + r.SignatureAlgorithm = res.SignatureAlgorithm + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve = &CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{empty: true} + +func (r *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyAllowedIssuanceModes struct { + empty bool `json:"-"` + AllowCsrBasedIssuance *bool `json:"allowCsrBasedIssuance"` + AllowConfigBasedIssuance *bool `json:"allowConfigBasedIssuance"` +} + +type jsonCaPoolIssuancePolicyAllowedIssuanceModes CaPoolIssuancePolicyAllowedIssuanceModes + +func (r *CaPoolIssuancePolicyAllowedIssuanceModes) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyAllowedIssuanceModes + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyAllowedIssuanceModes + } else { + + r.AllowCsrBasedIssuance = res.AllowCsrBasedIssuance + + r.AllowConfigBasedIssuance = res.AllowConfigBasedIssuance + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyAllowedIssuanceModes is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyAllowedIssuanceModes *CaPoolIssuancePolicyAllowedIssuanceModes = &CaPoolIssuancePolicyAllowedIssuanceModes{empty: true} + +func (r *CaPoolIssuancePolicyAllowedIssuanceModes) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyAllowedIssuanceModes) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyAllowedIssuanceModes) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValues struct { + empty bool `json:"-"` + KeyUsage *CaPoolIssuancePolicyBaselineValuesKeyUsage `json:"keyUsage"` + CaOptions *CaPoolIssuancePolicyBaselineValuesCaOptions `json:"caOptions"` + PolicyIds []CaPoolIssuancePolicyBaselineValuesPolicyIds `json:"policyIds"` + AiaOcspServers []string `json:"aiaOcspServers"` + AdditionalExtensions []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCaPoolIssuancePolicyBaselineValues CaPoolIssuancePolicyBaselineValues + +func (r *CaPoolIssuancePolicyBaselineValues) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValues + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValues + } else { + + r.KeyUsage = res.KeyUsage + + r.CaOptions = res.CaOptions + + r.PolicyIds = res.PolicyIds + + r.AiaOcspServers = res.AiaOcspServers + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValues is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValues *CaPoolIssuancePolicyBaselineValues = &CaPoolIssuancePolicyBaselineValues{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValues) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValues) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValues) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesKeyUsage struct { + empty bool `json:"-"` + BaseKeyUsage *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage `json:"baseKeyUsage"` + ExtendedKeyUsage *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage `json:"extendedKeyUsage"` + UnknownExtendedKeyUsages []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages `json:"unknownExtendedKeyUsages"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesKeyUsage CaPoolIssuancePolicyBaselineValuesKeyUsage + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesKeyUsage + } else { + + r.BaseKeyUsage = res.BaseKeyUsage + + r.ExtendedKeyUsage = res.ExtendedKeyUsage + + r.UnknownExtendedKeyUsages = res.UnknownExtendedKeyUsages + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesKeyUsage *CaPoolIssuancePolicyBaselineValuesKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsage{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsage) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage struct { + empty bool `json:"-"` + DigitalSignature *bool `json:"digitalSignature"` + ContentCommitment *bool `json:"contentCommitment"` + KeyEncipherment *bool `json:"keyEncipherment"` + DataEncipherment *bool `json:"dataEncipherment"` + KeyAgreement *bool `json:"keyAgreement"` + CertSign *bool `json:"certSign"` + CrlSign *bool `json:"crlSign"` + EncipherOnly *bool `json:"encipherOnly"` + DecipherOnly *bool `json:"decipherOnly"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + } else { + + r.DigitalSignature = res.DigitalSignature + + r.ContentCommitment = res.ContentCommitment + + r.KeyEncipherment = res.KeyEncipherment + + r.DataEncipherment = res.DataEncipherment + + r.KeyAgreement = res.KeyAgreement + + r.CertSign = res.CertSign + + r.CrlSign = res.CrlSign + + r.EncipherOnly = res.EncipherOnly + + r.DecipherOnly = res.DecipherOnly + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage struct { + empty bool `json:"-"` + ServerAuth *bool `json:"serverAuth"` + ClientAuth *bool `json:"clientAuth"` + CodeSigning *bool `json:"codeSigning"` + EmailProtection *bool `json:"emailProtection"` + TimeStamping *bool `json:"timeStamping"` + OcspSigning *bool `json:"ocspSigning"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + } else { + + r.ServerAuth = res.ServerAuth + + r.ClientAuth = res.ClientAuth + + r.CodeSigning = res.CodeSigning + + r.EmailProtection = res.EmailProtection + + r.TimeStamping = res.TimeStamping + + r.OcspSigning = res.OcspSigning + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages = &CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesCaOptions struct { + empty bool `json:"-"` + IsCa *bool `json:"isCa"` + MaxIssuerPathLength *int64 `json:"maxIssuerPathLength"` + ZeroMaxIssuerPathLength *bool `json:"zeroMaxIssuerPathLength"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesCaOptions CaPoolIssuancePolicyBaselineValuesCaOptions + +func (r *CaPoolIssuancePolicyBaselineValuesCaOptions) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesCaOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesCaOptions + } else { + + r.IsCa = res.IsCa + + r.MaxIssuerPathLength = res.MaxIssuerPathLength + + r.ZeroMaxIssuerPathLength = res.ZeroMaxIssuerPathLength + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesCaOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesCaOptions *CaPoolIssuancePolicyBaselineValuesCaOptions = &CaPoolIssuancePolicyBaselineValuesCaOptions{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesCaOptions) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesCaOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesCaOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesPolicyIds struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesPolicyIds CaPoolIssuancePolicyBaselineValuesPolicyIds + +func (r *CaPoolIssuancePolicyBaselineValuesPolicyIds) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesPolicyIds + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesPolicyIds + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesPolicyIds is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesPolicyIds *CaPoolIssuancePolicyBaselineValuesPolicyIds = &CaPoolIssuancePolicyBaselineValuesPolicyIds{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesPolicyIds) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesPolicyIds) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesPolicyIds) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesAdditionalExtensions struct { + empty bool `json:"-"` + ObjectId *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesAdditionalExtensions CaPoolIssuancePolicyBaselineValuesAdditionalExtensions + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensions + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensions *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions = &CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId = &CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{empty: true} + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyIdentityConstraints struct { + empty bool `json:"-"` + CelExpression *CaPoolIssuancePolicyIdentityConstraintsCelExpression `json:"celExpression"` + AllowSubjectPassthrough *bool `json:"allowSubjectPassthrough"` + AllowSubjectAltNamesPassthrough *bool `json:"allowSubjectAltNamesPassthrough"` +} + +type jsonCaPoolIssuancePolicyIdentityConstraints CaPoolIssuancePolicyIdentityConstraints + +func (r *CaPoolIssuancePolicyIdentityConstraints) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyIdentityConstraints + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyIdentityConstraints + } else { + + r.CelExpression = res.CelExpression + + r.AllowSubjectPassthrough = res.AllowSubjectPassthrough + + r.AllowSubjectAltNamesPassthrough = res.AllowSubjectAltNamesPassthrough + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyIdentityConstraints is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyIdentityConstraints *CaPoolIssuancePolicyIdentityConstraints = &CaPoolIssuancePolicyIdentityConstraints{empty: true} + +func (r *CaPoolIssuancePolicyIdentityConstraints) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyIdentityConstraints) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyIdentityConstraints) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyIdentityConstraintsCelExpression struct { + empty bool `json:"-"` + Expression *string `json:"expression"` + Title *string `json:"title"` + Description *string `json:"description"` + Location *string `json:"location"` +} + +type jsonCaPoolIssuancePolicyIdentityConstraintsCelExpression CaPoolIssuancePolicyIdentityConstraintsCelExpression + +func (r *CaPoolIssuancePolicyIdentityConstraintsCelExpression) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyIdentityConstraintsCelExpression + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyIdentityConstraintsCelExpression + } else { + + r.Expression = res.Expression + + r.Title = res.Title + + r.Description = res.Description + + r.Location = res.Location + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyIdentityConstraintsCelExpression is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyIdentityConstraintsCelExpression *CaPoolIssuancePolicyIdentityConstraintsCelExpression = &CaPoolIssuancePolicyIdentityConstraintsCelExpression{empty: true} + +func (r *CaPoolIssuancePolicyIdentityConstraintsCelExpression) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyIdentityConstraintsCelExpression) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyIdentityConstraintsCelExpression) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyPassthroughExtensions struct { + empty bool `json:"-"` + KnownExtensions []CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum `json:"knownExtensions"` + AdditionalExtensions []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCaPoolIssuancePolicyPassthroughExtensions CaPoolIssuancePolicyPassthroughExtensions + +func (r *CaPoolIssuancePolicyPassthroughExtensions) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyPassthroughExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyPassthroughExtensions + } else { + + r.KnownExtensions = res.KnownExtensions + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyPassthroughExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyPassthroughExtensions *CaPoolIssuancePolicyPassthroughExtensions = &CaPoolIssuancePolicyPassthroughExtensions{empty: true} + +func (r *CaPoolIssuancePolicyPassthroughExtensions) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyPassthroughExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyPassthroughExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + +func (r *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions = &CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{empty: true} + +func (r *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CaPoolPublishingOptions struct { + empty bool `json:"-"` + PublishCaCert *bool `json:"publishCaCert"` + PublishCrl *bool `json:"publishCrl"` +} + +type jsonCaPoolPublishingOptions CaPoolPublishingOptions + +func (r *CaPoolPublishingOptions) UnmarshalJSON(data []byte) error { + var res jsonCaPoolPublishingOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCaPoolPublishingOptions + } else { + + r.PublishCaCert = res.PublishCaCert + + r.PublishCrl = res.PublishCrl + + } + return nil +} + +// This object is used to assert a desired state where this CaPoolPublishingOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCaPoolPublishingOptions *CaPoolPublishingOptions = &CaPoolPublishingOptions{empty: true} + +func (r *CaPoolPublishingOptions) Empty() bool { + return r.empty +} + +func (r *CaPoolPublishingOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CaPoolPublishingOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *CaPool) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "privateca", + Type: "CaPool", + Version: "privateca", + } +} + +func (r *CaPool) ID() (string, error) { + if err := extractCaPoolFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "tier": dcl.ValueOrEmptyString(nr.Tier), + "issuance_policy": dcl.ValueOrEmptyString(nr.IssuancePolicy), + "publishing_options": dcl.ValueOrEmptyString(nr.PublishingOptions), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + } + return dcl.Nprintf("projects/{{project}}/locations/{{location}}/caPools/{{name}}", params), nil +} + +const CaPoolMaxPage = -1 + +type CaPoolList struct { + Items []*CaPool + + nextToken string + + pageSize int32 + + resource *CaPool +} + +func (l *CaPoolList) HasNext() bool { + return l.nextToken != "" +} + +func (l *CaPoolList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listCaPool(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListCaPool(ctx context.Context, project, location string) (*CaPoolList, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListCaPoolWithMaxResults(ctx, project, location, CaPoolMaxPage) + +} + +func (c *Client) ListCaPoolWithMaxResults(ctx context.Context, project, location string, pageSize int32) (*CaPoolList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &CaPool{ + Project: &project, + Location: &location, + } + items, token, err := c.listCaPool(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &CaPoolList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetCaPool(ctx context.Context, r *CaPool) (*CaPool, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractCaPoolFields(r) + + b, err := c.getCaPoolRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalCaPool(b, c, r) + if err != nil { + return nil, err + } + result.Project = r.Project + result.Location = r.Location + result.Name = r.Name + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizeCaPoolNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractCaPoolFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeleteCaPool(ctx context.Context, r *CaPool) error { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("CaPool resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting CaPool...") + deleteOp := deleteCaPoolOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllCaPool deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllCaPool(ctx context.Context, project, location string, filter func(*CaPool) bool) error { + listObj, err := c.ListCaPool(ctx, project, location) + if err != nil { + return err + } + + err = c.deleteAllCaPool(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllCaPool(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyCaPool(ctx context.Context, rawDesired *CaPool, opts ...dcl.ApplyOption) (*CaPool, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + var resultNewState *CaPool + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyCaPoolHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyCaPoolHelper(c *Client, ctx context.Context, rawDesired *CaPool, opts ...dcl.ApplyOption) (*CaPool, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyCaPool...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractCaPoolFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.caPoolDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToCaPoolDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []caPoolApiOperation + if create { + ops = append(ops, &createCaPoolOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyCaPoolDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyCaPoolDiff(c *Client, ctx context.Context, desired *CaPool, rawDesired *CaPool, ops []caPoolApiOperation, opts ...dcl.ApplyOption) (*CaPool, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetCaPool(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createCaPoolOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapCaPool(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizeCaPoolNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizeCaPoolNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizeCaPoolDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractCaPoolFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractCaPoolFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffCaPool(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool.yaml new file mode 100644 index 00000000000..96ce466d64c --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool.yaml @@ -0,0 +1,575 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Privateca/CaPool + description: The Privateca CaPool resource + x-dcl-struct-name: CaPool + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a CaPool + parameters: + - name: caPool + required: true + description: A full instance of a CaPool + apply: + description: The function used to apply information about a CaPool + parameters: + - name: caPool + required: true + description: A full instance of a CaPool + delete: + description: The function used to delete a CaPool + parameters: + - name: caPool + required: true + description: A full instance of a CaPool + deleteAll: + description: The function used to delete all CaPool + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + list: + description: The function used to list information about many CaPool + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string +components: + schemas: + CaPool: + title: CaPool + x-dcl-id: projects/{{project}}/locations/{{location}}/caPools/{{name}} + x-dcl-parent-container: project + x-dcl-labels: labels + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - name + - tier + - project + - location + properties: + issuancePolicy: + type: object + x-dcl-go-name: IssuancePolicy + x-dcl-go-type: CaPoolIssuancePolicy + description: Optional. The IssuancePolicy to control how Certificates will + be issued from this CaPool. + properties: + allowedIssuanceModes: + type: object + x-dcl-go-name: AllowedIssuanceModes + x-dcl-go-type: CaPoolIssuancePolicyAllowedIssuanceModes + description: Optional. If specified, then only methods allowed in the + IssuanceModes may be used to issue Certificates. + properties: + allowConfigBasedIssuance: + type: boolean + x-dcl-go-name: AllowConfigBasedIssuance + description: Optional. When true, allows callers to create Certificates + by specifying a CertificateConfig. + allowCsrBasedIssuance: + type: boolean + x-dcl-go-name: AllowCsrBasedIssuance + description: Optional. When true, allows callers to create Certificates + by specifying a CSR. + allowedKeyTypes: + type: array + x-dcl-go-name: AllowedKeyTypes + description: Optional. If any AllowedKeyType is specified, then the + certificate request's public key must match one of the key types listed + here. Otherwise, any key may be used. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypes + properties: + ellipticCurve: + type: object + x-dcl-go-name: EllipticCurve + x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + description: Represents an allowed Elliptic Curve key type. + x-dcl-conflicts: + - rsa + properties: + signatureAlgorithm: + type: string + x-dcl-go-name: SignatureAlgorithm + x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum + description: 'Optional. A signature algorithm that must be + used. If this is omitted, any EC-based signature algorithm + will be allowed. Possible values: EC_SIGNATURE_ALGORITHM_UNSPECIFIED, + ECDSA_P256, ECDSA_P384, EDDSA_25519' + enum: + - EC_SIGNATURE_ALGORITHM_UNSPECIFIED + - ECDSA_P256 + - ECDSA_P384 + - EDDSA_25519 + rsa: + type: object + x-dcl-go-name: Rsa + x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypesRsa + description: Represents an allowed RSA key type. + x-dcl-conflicts: + - ellipticCurve + properties: + maxModulusSize: + type: integer + format: int64 + x-dcl-go-name: MaxModulusSize + description: Optional. The maximum allowed RSA modulus size, + in bits. If this is not set, or if set to zero, the service + will not enforce an explicit upper bound on RSA modulus + sizes. + minModulusSize: + type: integer + format: int64 + x-dcl-go-name: MinModulusSize + description: Optional. The minimum allowed RSA modulus size, + in bits. If this is not set, or if set to zero, the service-level + min RSA modulus size will continue to apply. + baselineValues: + type: object + x-dcl-go-name: BaselineValues + x-dcl-go-type: CaPoolIssuancePolicyBaselineValues + description: Optional. A set of X.509 values that will be applied to + all certificates issued through this CaPool. If a certificate request + includes conflicting values for the same properties, they will be + overwritten by the values defined here. If a certificate request uses + a CertificateTemplate that defines conflicting predefined_values for + the same properties, the certificate issuance request will fail. + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. Describes custom X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesAdditionalExtensions + required: + - objectId + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to handle + this extension, the client should consider this to be an + error). + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + description: Required. The OID for this X.509 extension. + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + aiaOcspServers: + type: array + x-dcl-go-name: AiaOcspServers + description: Optional. Describes Online Certificate Status Protocol + (OCSP) endpoint addresses that appear in the "Authority Information + Access" extension in the certificate. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caOptions: + type: object + x-dcl-go-name: CaOptions + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesCaOptions + description: Optional. Describes options in this X509Parameters + that are relevant in a CA certificate. + properties: + isCa: + type: boolean + x-dcl-go-name: IsCa + description: Optional. Refers to the "CA" X.509 extension, which + is a boolean value. When this value is missing, the extension + will be omitted from the CA certificate. + maxIssuerPathLength: + type: integer + format: int64 + x-dcl-go-name: MaxIssuerPathLength + description: Optional. Refers to the path length restriction + X.509 extension. For a CA certificate, this value describes + the depth of subordinate CA certificates that are allowed. + If this value is less than 0, the request will fail. If this + value is missing, the max path length will be omitted from + the CA certificate. + zeroMaxIssuerPathLength: + type: boolean + x-dcl-go-name: ZeroMaxIssuerPathLength + description: Optional. When true, the "path length constraint" + in Basic Constraints extension will be set to 0. if both max_issuer_path_length + and zero_max_issuer_path_length are unset, the max path length + will be omitted from the CA certificate. + keyUsage: + type: object + x-dcl-go-name: KeyUsage + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsage + description: Optional. Indicates the intended use for keys that + correspond to a certificate. + properties: + baseKeyUsage: + type: object + x-dcl-go-name: BaseKeyUsage + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + description: Describes high-level ways in which a key may be + used. + properties: + certSign: + type: boolean + x-dcl-go-name: CertSign + description: The key may be used to sign certificates. + contentCommitment: + type: boolean + x-dcl-go-name: ContentCommitment + description: The key may be used for cryptographic commitments. + Note that this may also be referred to as "non-repudiation". + crlSign: + type: boolean + x-dcl-go-name: CrlSign + description: The key may be used sign certificate revocation + lists. + dataEncipherment: + type: boolean + x-dcl-go-name: DataEncipherment + description: The key may be used to encipher data. + decipherOnly: + type: boolean + x-dcl-go-name: DecipherOnly + description: The key may be used to decipher only. + digitalSignature: + type: boolean + x-dcl-go-name: DigitalSignature + description: The key may be used for digital signatures. + encipherOnly: + type: boolean + x-dcl-go-name: EncipherOnly + description: The key may be used to encipher only. + keyAgreement: + type: boolean + x-dcl-go-name: KeyAgreement + description: The key may be used in a key agreement protocol. + keyEncipherment: + type: boolean + x-dcl-go-name: KeyEncipherment + description: The key may be used to encipher other keys. + extendedKeyUsage: + type: object + x-dcl-go-name: ExtendedKeyUsage + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + description: Detailed scenarios in which a key may be used. + properties: + clientAuth: + type: boolean + x-dcl-go-name: ClientAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially + described as "TLS WWW client authentication", though regularly + used for non-WWW TLS. + codeSigning: + type: boolean + x-dcl-go-name: CodeSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially + described as "Signing of downloadable executable code + client authentication". + emailProtection: + type: boolean + x-dcl-go-name: EmailProtection + description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially + described as "Email protection". + ocspSigning: + type: boolean + x-dcl-go-name: OcspSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially + described as "Signing OCSP responses". + serverAuth: + type: boolean + x-dcl-go-name: ServerAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially + described as "TLS WWW server authentication", though regularly + used for non-WWW TLS. + timeStamping: + type: boolean + x-dcl-go-name: TimeStamping + description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially + described as "Binding the hash of an object to a time". + unknownExtendedKeyUsages: + type: array + x-dcl-go-name: UnknownExtendedKeyUsages + description: Used to describe extended key usages that are not + listed in the KeyUsage.ExtendedKeyUsageOptions message. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + policyIds: + type: array + x-dcl-go-name: PolicyIds + description: Optional. Describes the X.509 certificate policy object + identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesPolicyIds + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + identityConstraints: + type: object + x-dcl-go-name: IdentityConstraints + x-dcl-go-type: CaPoolIssuancePolicyIdentityConstraints + description: Optional. Describes constraints on identities that may + appear in Certificates issued through this CaPool. If this is omitted, + then this CaPool will not add restrictions on a certificate's identity. + required: + - allowSubjectPassthrough + - allowSubjectAltNamesPassthrough + properties: + allowSubjectAltNamesPassthrough: + type: boolean + x-dcl-go-name: AllowSubjectAltNamesPassthrough + description: Required. If this is true, the SubjectAltNames extension + may be copied from a certificate request into the signed certificate. + Otherwise, the requested SubjectAltNames will be discarded. + allowSubjectPassthrough: + type: boolean + x-dcl-go-name: AllowSubjectPassthrough + description: Required. If this is true, the Subject field may be + copied from a certificate request into the signed certificate. + Otherwise, the requested Subject will be discarded. + celExpression: + type: object + x-dcl-go-name: CelExpression + x-dcl-go-type: CaPoolIssuancePolicyIdentityConstraintsCelExpression + description: Optional. A CEL expression that may be used to validate + the resolved X.509 Subject and/or Subject Alternative Name before + a certificate is signed. To see the full allowed syntax and some + examples, see https://cloud.google.com/certificate-authority-service/docs/using-cel + properties: + description: + type: string + x-dcl-go-name: Description + description: Optional. Description of the expression. This is + a longer text which describes the expression, e.g. when hovered + over it in a UI. + expression: + type: string + x-dcl-go-name: Expression + description: Textual representation of an expression in Common + Expression Language syntax. + location: + type: string + x-dcl-go-name: Location + description: Optional. String indicating the location of the + expression for error reporting, e.g. a file name and a position + in the file. + title: + type: string + x-dcl-go-name: Title + description: Optional. Title for the expression, i.e. a short + string describing its purpose. This can be used e.g. in UIs + which allow to enter the expression. + maximumLifetime: + type: string + x-dcl-go-name: MaximumLifetime + description: Optional. The maximum lifetime allowed for issued Certificates. + Note that if the issuing CertificateAuthority expires before a Certificate's + requested maximum_lifetime, the effective lifetime will be explicitly + truncated to match it. + passthroughExtensions: + type: object + x-dcl-go-name: PassthroughExtensions + x-dcl-go-type: CaPoolIssuancePolicyPassthroughExtensions + description: Optional. Describes the set of X.509 extensions that may + appear in a Certificate issued through this CaPool. If a certificate + request sets extensions that don't appear in the passthrough_extensions, + those extensions will be dropped. If a certificate request uses a + CertificateTemplate with predefined_values that don't appear here, + the certificate issuance request will fail. If this is omitted, then + this CaPool will not add restrictions on a certificate's X.509 extensions. + These constraints do not apply to X.509 extensions set in this CaPool's + baseline_values. + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. A set of ObjectIds identifying custom X.509 + extensions. Will be combined with known_extensions to determine + the full set of X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + knownExtensions: + type: array + x-dcl-go-name: KnownExtensions + description: Optional. A set of named X.509 extensions. Will be + combined with additional_extensions to determine the full set + of X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum + enum: + - KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED + - BASE_KEY_USAGE + - EXTENDED_KEY_USAGE + - CA_OPTIONS + - POLICY_IDS + - AIA_OCSP_SERVERS + labels: + type: object + additionalProperties: + type: string + x-dcl-go-name: Labels + description: Optional. Labels with user-defined metadata. + location: + type: string + x-dcl-go-name: Location + description: The location for the resource + x-kubernetes-immutable: true + x-dcl-parameter: true + name: + type: string + x-dcl-go-name: Name + description: The resource name for this CaPool in the format `projects/*/locations/*/caPools/*`. + x-kubernetes-immutable: true + x-dcl-has-long-form: true + project: + type: string + x-dcl-go-name: Project + description: The project for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-parameter: true + publishingOptions: + type: object + x-dcl-go-name: PublishingOptions + x-dcl-go-type: CaPoolPublishingOptions + description: Optional. The PublishingOptions to follow when issuing Certificates + from any CertificateAuthority in this CaPool. + properties: + publishCaCert: + type: boolean + x-dcl-go-name: PublishCaCert + description: Optional. When true, publishes each CertificateAuthority's + CA certificate and includes its URL in the "Authority Information + Access" X.509 extension in all issued Certificates. If this is false, + the CA certificate will not be published and the corresponding X.509 + extension will not be written in issued certificates. + publishCrl: + type: boolean + x-dcl-go-name: PublishCrl + description: Optional. When true, publishes each CertificateAuthority's + CRL and includes its URL in the "CRL Distribution Points" X.509 extension + in all issued Certificates. If this is false, CRLs will not be published + and the corresponding X.509 extension will not be written in issued + certificates. CRLs will expire 7 days from their creation. However, + we will rebuild daily. CRLs are also rebuilt shortly after a certificate + is revoked. + tier: + type: string + x-dcl-go-name: Tier + x-dcl-go-type: CaPoolTierEnum + description: 'Required. Immutable. The Tier of this CaPool. Possible values: + TIER_UNSPECIFIED, ENTERPRISE, DEVOPS' + x-kubernetes-immutable: true + enum: + - TIER_UNSPECIFIED + - ENTERPRISE + - DEVOPS diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_internal.go new file mode 100644 index 00000000000..6e763e726ea --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_internal.go @@ -0,0 +1,7152 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" +) + +func (r *CaPool) validate() error { + + if err := dcl.Required(r, "name"); err != nil { + return err + } + if err := dcl.Required(r, "tier"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Project, "Project"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Location, "Location"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.IssuancePolicy) { + if err := r.IssuancePolicy.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PublishingOptions) { + if err := r.PublishingOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicy) validate() error { + if !dcl.IsEmptyValueIndirect(r.AllowedIssuanceModes) { + if err := r.AllowedIssuanceModes.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.BaselineValues) { + if err := r.BaselineValues.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.IdentityConstraints) { + if err := r.IdentityConstraints.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PassthroughExtensions) { + if err := r.PassthroughExtensions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicyAllowedKeyTypes) validate() error { + if err := dcl.ValidateAtMostOneOfFieldsSet([]string{"Rsa", "EllipticCurve"}, r.Rsa, r.EllipticCurve); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Rsa) { + if err := r.Rsa.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.EllipticCurve) { + if err := r.EllipticCurve.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicyAllowedKeyTypesRsa) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyAllowedIssuanceModes) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyBaselineValues) validate() error { + if !dcl.IsEmptyValueIndirect(r.KeyUsage) { + if err := r.KeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CaOptions) { + if err := r.CaOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsage) validate() error { + if !dcl.IsEmptyValueIndirect(r.BaseKeyUsage) { + if err := r.BaseKeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.ExtendedKeyUsage) { + if err := r.ExtendedKeyUsage.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesCaOptions) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesPolicyIds) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CaPoolIssuancePolicyIdentityConstraints) validate() error { + if err := dcl.Required(r, "allowSubjectPassthrough"); err != nil { + return err + } + if err := dcl.Required(r, "allowSubjectAltNamesPassthrough"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.CelExpression) { + if err := r.CelExpression.validate(); err != nil { + return err + } + } + return nil +} +func (r *CaPoolIssuancePolicyIdentityConstraintsCelExpression) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyPassthroughExtensions) validate() error { + return nil +} +func (r *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CaPoolPublishingOptions) validate() error { + return nil +} +func (r *CaPool) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://privateca.googleapis.com/v1/", params) +} + +func (r *CaPool) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{name}}", nr.basePath(), userBasePath, params), nil +} + +func (r *CaPool) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools", nr.basePath(), userBasePath, params), nil + +} + +func (r *CaPool) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools?caPoolId={{name}}", nr.basePath(), userBasePath, params), nil + +} + +func (r *CaPool) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{name}}", nr.basePath(), userBasePath, params), nil +} + +// caPoolApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type caPoolApiOperation interface { + do(context.Context, *CaPool, *Client) error +} + +// newUpdateCaPoolUpdateCaPoolRequest creates a request for an +// CaPool resource's UpdateCaPool update type by filling in the update +// fields based on the intended state of the resource. +func newUpdateCaPoolUpdateCaPoolRequest(ctx context.Context, f *CaPool, c *Client) (map[string]interface{}, error) { + req := map[string]interface{}{} + res := f + _ = res + + if v, err := expandCaPoolIssuancePolicy(c, f.IssuancePolicy, res); err != nil { + return nil, fmt.Errorf("error expanding IssuancePolicy into issuancePolicy: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["issuancePolicy"] = v + } + if v, err := expandCaPoolPublishingOptions(c, f.PublishingOptions, res); err != nil { + return nil, fmt.Errorf("error expanding PublishingOptions into publishingOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["publishingOptions"] = v + } + if v := f.Labels; !dcl.IsEmptyValueIndirect(v) { + req["labels"] = v + } + req["name"] = fmt.Sprintf("projects/%s/locations/%s/caPools/%s", *f.Project, *f.Location, *f.Name) + + return req, nil +} + +// marshalUpdateCaPoolUpdateCaPoolRequest converts the update into +// the final JSON request body. +func marshalUpdateCaPoolUpdateCaPoolRequest(c *Client, m map[string]interface{}) ([]byte, error) { + + return json.Marshal(m) +} + +type updateCaPoolUpdateCaPoolOperation struct { + // If the update operation has the REQUIRES_APPLY_OPTIONS trait, this will be populated. + // Usually it will be nil - this is to prevent us from accidentally depending on apply + // options, which should usually be unnecessary. + ApplyOptions []dcl.ApplyOption + FieldDiffs []*dcl.FieldDiff +} + +// do creates a request and sends it to the appropriate URL. In most operations, +// do will transcribe a subset of the resource into a request object and send a +// PUT request to a single URL. + +func (op *updateCaPoolUpdateCaPoolOperation) do(ctx context.Context, r *CaPool, c *Client) error { + _, err := c.GetCaPool(ctx, r) + if err != nil { + return err + } + + u, err := r.updateURL(c.Config.BasePath, "UpdateCaPool") + if err != nil { + return err + } + mask := dcl.TopLevelUpdateMask(op.FieldDiffs) + u, err = dcl.AddQueryParams(u, map[string]string{"updateMask": mask}) + if err != nil { + return err + } + + req, err := newUpdateCaPoolUpdateCaPoolRequest(ctx, r, c) + if err != nil { + return err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created update: %#v", req) + body, err := marshalUpdateCaPoolUpdateCaPoolRequest(c, req) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "PATCH", u, bytes.NewBuffer(body), c.Config.RetryProvider) + if err != nil { + return err + } + + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + err = o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET") + + if err != nil { + return err + } + + return nil +} + +func (c *Client) listCaPoolRaw(ctx context.Context, r *CaPool, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != CaPoolMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listCaPoolOperation struct { + CaPools []map[string]interface{} `json:"caPools"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listCaPool(ctx context.Context, r *CaPool, pageToken string, pageSize int32) ([]*CaPool, string, error) { + b, err := c.listCaPoolRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listCaPoolOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*CaPool + for _, v := range m.CaPools { + res, err := unmarshalMapCaPool(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Project = r.Project + res.Location = r.Location + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllCaPool(ctx context.Context, f func(*CaPool) bool, resources []*CaPool) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeleteCaPool(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deleteCaPoolOperation struct{} + +func (op *deleteCaPoolOperation) do(ctx context.Context, r *CaPool, c *Client) error { + r, err := c.GetCaPool(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "CaPool not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetCaPool checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + resp, err := dcl.SendRequest(ctx, c.Config, "DELETE", u, body, c.Config.RetryProvider) + if err != nil { + return err + } + + // wait for object to be deleted. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET"); err != nil { + return err + } + + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCaPool(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil + } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createCaPoolOperation struct { + response map[string]interface{} +} + +func (op *createCaPoolOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createCaPoolOperation) do(ctx context.Context, r *CaPool, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + // wait for object to be created. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET"); err != nil { + c.Config.Logger.Warningf("Creation failed after waiting for operation: %v", err) + return err + } + c.Config.Logger.InfoWithContextf(ctx, "Successfully waited for operation") + op.response, _ = o.FirstResponse() + + if _, err := c.GetCaPool(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + return nil +} + +func (c *Client) getCaPoolRaw(ctx context.Context, r *CaPool) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + return b, nil +} + +func (c *Client) caPoolDiffsForRawDesired(ctx context.Context, rawDesired *CaPool, opts ...dcl.ApplyOption) (initial, desired *CaPool, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *CaPool + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*CaPool); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected CaPool, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetCaPool(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a CaPool resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve CaPool resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that CaPool resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizeCaPoolDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for CaPool: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for CaPool: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractCaPoolFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizeCaPoolInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for CaPool: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizeCaPoolDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for CaPool: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffCaPool(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizeCaPoolInitialState(rawInitial, rawDesired *CaPool) (*CaPool, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizeCaPoolDesiredState(rawDesired, rawInitial *CaPool, opts ...dcl.ApplyOption) (*CaPool, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + rawDesired.IssuancePolicy = canonicalizeCaPoolIssuancePolicy(rawDesired.IssuancePolicy, nil, opts...) + rawDesired.PublishingOptions = canonicalizeCaPoolPublishingOptions(rawDesired.PublishingOptions, nil, opts...) + + return rawDesired, nil + } + canonicalDesired := &CaPool{} + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawInitial.Name) { + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + if dcl.IsZeroValue(rawDesired.Tier) || (dcl.IsEmptyValueIndirect(rawDesired.Tier) && dcl.IsEmptyValueIndirect(rawInitial.Tier)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Tier = rawInitial.Tier + } else { + canonicalDesired.Tier = rawDesired.Tier + } + canonicalDesired.IssuancePolicy = canonicalizeCaPoolIssuancePolicy(rawDesired.IssuancePolicy, rawInitial.IssuancePolicy, opts...) + canonicalDesired.PublishingOptions = canonicalizeCaPoolPublishingOptions(rawDesired.PublishingOptions, rawInitial.PublishingOptions, opts...) + if dcl.IsZeroValue(rawDesired.Labels) || (dcl.IsEmptyValueIndirect(rawDesired.Labels) && dcl.IsEmptyValueIndirect(rawInitial.Labels)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Labels = rawInitial.Labels + } else { + canonicalDesired.Labels = rawDesired.Labels + } + if dcl.NameToSelfLink(rawDesired.Project, rawInitial.Project) { + canonicalDesired.Project = rawInitial.Project + } else { + canonicalDesired.Project = rawDesired.Project + } + if dcl.NameToSelfLink(rawDesired.Location, rawInitial.Location) { + canonicalDesired.Location = rawInitial.Location + } else { + canonicalDesired.Location = rawDesired.Location + } + return canonicalDesired, nil +} + +func canonicalizeCaPoolNewState(c *Client, rawNew, rawDesired *CaPool) (*CaPool, error) { + + if dcl.IsEmptyValueIndirect(rawNew.Name) && dcl.IsEmptyValueIndirect(rawDesired.Name) { + rawNew.Name = rawDesired.Name + } else { + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawNew.Name) { + rawNew.Name = rawDesired.Name + } + } + + if dcl.IsEmptyValueIndirect(rawNew.Tier) && dcl.IsEmptyValueIndirect(rawDesired.Tier) { + rawNew.Tier = rawDesired.Tier + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.IssuancePolicy) && dcl.IsEmptyValueIndirect(rawDesired.IssuancePolicy) { + rawNew.IssuancePolicy = rawDesired.IssuancePolicy + } else { + rawNew.IssuancePolicy = canonicalizeNewCaPoolIssuancePolicy(c, rawDesired.IssuancePolicy, rawNew.IssuancePolicy) + } + + if dcl.IsEmptyValueIndirect(rawNew.PublishingOptions) && dcl.IsEmptyValueIndirect(rawDesired.PublishingOptions) { + rawNew.PublishingOptions = rawDesired.PublishingOptions + } else { + rawNew.PublishingOptions = canonicalizeNewCaPoolPublishingOptions(c, rawDesired.PublishingOptions, rawNew.PublishingOptions) + } + + if dcl.IsEmptyValueIndirect(rawNew.Labels) && dcl.IsEmptyValueIndirect(rawDesired.Labels) { + rawNew.Labels = rawDesired.Labels + } else { + } + + rawNew.Project = rawDesired.Project + + rawNew.Location = rawDesired.Location + + return rawNew, nil +} + +func canonicalizeCaPoolIssuancePolicy(des, initial *CaPoolIssuancePolicy, opts ...dcl.ApplyOption) *CaPoolIssuancePolicy { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicy{} + + cDes.AllowedKeyTypes = canonicalizeCaPoolIssuancePolicyAllowedKeyTypesSlice(des.AllowedKeyTypes, initial.AllowedKeyTypes, opts...) + if dcl.StringCanonicalize(des.MaximumLifetime, initial.MaximumLifetime) || dcl.IsZeroValue(des.MaximumLifetime) { + cDes.MaximumLifetime = initial.MaximumLifetime + } else { + cDes.MaximumLifetime = des.MaximumLifetime + } + cDes.AllowedIssuanceModes = canonicalizeCaPoolIssuancePolicyAllowedIssuanceModes(des.AllowedIssuanceModes, initial.AllowedIssuanceModes, opts...) + cDes.BaselineValues = canonicalizeCaPoolIssuancePolicyBaselineValues(des.BaselineValues, initial.BaselineValues, opts...) + cDes.IdentityConstraints = canonicalizeCaPoolIssuancePolicyIdentityConstraints(des.IdentityConstraints, initial.IdentityConstraints, opts...) + cDes.PassthroughExtensions = canonicalizeCaPoolIssuancePolicyPassthroughExtensions(des.PassthroughExtensions, initial.PassthroughExtensions, opts...) + + return cDes +} + +func canonicalizeCaPoolIssuancePolicySlice(des, initial []CaPoolIssuancePolicy, opts ...dcl.ApplyOption) []CaPoolIssuancePolicy { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicy, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicy(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicy, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicy(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicy(c *Client, des, nw *CaPoolIssuancePolicy) *CaPoolIssuancePolicy { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicy while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.AllowedKeyTypes = canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesSlice(c, des.AllowedKeyTypes, nw.AllowedKeyTypes) + if dcl.StringCanonicalize(des.MaximumLifetime, nw.MaximumLifetime) { + nw.MaximumLifetime = des.MaximumLifetime + } + nw.AllowedIssuanceModes = canonicalizeNewCaPoolIssuancePolicyAllowedIssuanceModes(c, des.AllowedIssuanceModes, nw.AllowedIssuanceModes) + nw.BaselineValues = canonicalizeNewCaPoolIssuancePolicyBaselineValues(c, des.BaselineValues, nw.BaselineValues) + nw.IdentityConstraints = canonicalizeNewCaPoolIssuancePolicyIdentityConstraints(c, des.IdentityConstraints, nw.IdentityConstraints) + nw.PassthroughExtensions = canonicalizeNewCaPoolIssuancePolicyPassthroughExtensions(c, des.PassthroughExtensions, nw.PassthroughExtensions) + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicySet(c *Client, des, nw []CaPoolIssuancePolicy) []CaPoolIssuancePolicy { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicy + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicy(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicySlice(c *Client, des, nw []CaPoolIssuancePolicy) []CaPoolIssuancePolicy { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicy + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicy(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyAllowedKeyTypes(des, initial *CaPoolIssuancePolicyAllowedKeyTypes, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyAllowedKeyTypes { + if des == nil { + return initial + } + if des.empty { + return des + } + + if des.Rsa != nil || (initial != nil && initial.Rsa != nil) { + // Check if anything else is set. + if dcl.AnySet(des.EllipticCurve) { + des.Rsa = nil + if initial != nil { + initial.Rsa = nil + } + } + } + + if des.EllipticCurve != nil || (initial != nil && initial.EllipticCurve != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Rsa) { + des.EllipticCurve = nil + if initial != nil { + initial.EllipticCurve = nil + } + } + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyAllowedKeyTypes{} + + cDes.Rsa = canonicalizeCaPoolIssuancePolicyAllowedKeyTypesRsa(des.Rsa, initial.Rsa, opts...) + cDes.EllipticCurve = canonicalizeCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(des.EllipticCurve, initial.EllipticCurve, opts...) + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyAllowedKeyTypesSlice(des, initial []CaPoolIssuancePolicyAllowedKeyTypes, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyAllowedKeyTypes { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyAllowedKeyTypes, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedKeyTypes(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypes, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedKeyTypes(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypes(c *Client, des, nw *CaPoolIssuancePolicyAllowedKeyTypes) *CaPoolIssuancePolicyAllowedKeyTypes { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyAllowedKeyTypes while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Rsa = canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesRsa(c, des.Rsa, nw.Rsa) + nw.EllipticCurve = canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, des.EllipticCurve, nw.EllipticCurve) + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesSet(c *Client, des, nw []CaPoolIssuancePolicyAllowedKeyTypes) []CaPoolIssuancePolicyAllowedKeyTypes { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyAllowedKeyTypes + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyAllowedKeyTypesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypes(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesSlice(c *Client, des, nw []CaPoolIssuancePolicyAllowedKeyTypes) []CaPoolIssuancePolicyAllowedKeyTypes { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyAllowedKeyTypes + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypes(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyAllowedKeyTypesRsa(des, initial *CaPoolIssuancePolicyAllowedKeyTypesRsa, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyAllowedKeyTypesRsa { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyAllowedKeyTypesRsa{} + + if dcl.IsZeroValue(des.MinModulusSize) || (dcl.IsEmptyValueIndirect(des.MinModulusSize) && dcl.IsEmptyValueIndirect(initial.MinModulusSize)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MinModulusSize = initial.MinModulusSize + } else { + cDes.MinModulusSize = des.MinModulusSize + } + if dcl.IsZeroValue(des.MaxModulusSize) || (dcl.IsEmptyValueIndirect(des.MaxModulusSize) && dcl.IsEmptyValueIndirect(initial.MaxModulusSize)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxModulusSize = initial.MaxModulusSize + } else { + cDes.MaxModulusSize = des.MaxModulusSize + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyAllowedKeyTypesRsaSlice(des, initial []CaPoolIssuancePolicyAllowedKeyTypesRsa, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyAllowedKeyTypesRsa { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesRsa, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedKeyTypesRsa(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesRsa, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedKeyTypesRsa(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesRsa(c *Client, des, nw *CaPoolIssuancePolicyAllowedKeyTypesRsa) *CaPoolIssuancePolicyAllowedKeyTypesRsa { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyAllowedKeyTypesRsa while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesRsaSet(c *Client, des, nw []CaPoolIssuancePolicyAllowedKeyTypesRsa) []CaPoolIssuancePolicyAllowedKeyTypesRsa { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyAllowedKeyTypesRsa + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyAllowedKeyTypesRsaNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesRsa(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesRsaSlice(c *Client, des, nw []CaPoolIssuancePolicyAllowedKeyTypesRsa) []CaPoolIssuancePolicyAllowedKeyTypesRsa { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyAllowedKeyTypesRsa + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesRsa(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(des, initial *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + + if dcl.IsZeroValue(des.SignatureAlgorithm) || (dcl.IsEmptyValueIndirect(des.SignatureAlgorithm) && dcl.IsEmptyValueIndirect(initial.SignatureAlgorithm)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.SignatureAlgorithm = initial.SignatureAlgorithm + } else { + cDes.SignatureAlgorithm = des.SignatureAlgorithm + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSlice(des, initial []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c *Client, des, nw *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSet(c *Client, des, nw []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSlice(c *Client, des, nw []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyAllowedIssuanceModes(des, initial *CaPoolIssuancePolicyAllowedIssuanceModes, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyAllowedIssuanceModes { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyAllowedIssuanceModes{} + + if dcl.BoolCanonicalize(des.AllowCsrBasedIssuance, initial.AllowCsrBasedIssuance) || dcl.IsZeroValue(des.AllowCsrBasedIssuance) { + cDes.AllowCsrBasedIssuance = initial.AllowCsrBasedIssuance + } else { + cDes.AllowCsrBasedIssuance = des.AllowCsrBasedIssuance + } + if dcl.BoolCanonicalize(des.AllowConfigBasedIssuance, initial.AllowConfigBasedIssuance) || dcl.IsZeroValue(des.AllowConfigBasedIssuance) { + cDes.AllowConfigBasedIssuance = initial.AllowConfigBasedIssuance + } else { + cDes.AllowConfigBasedIssuance = des.AllowConfigBasedIssuance + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyAllowedIssuanceModesSlice(des, initial []CaPoolIssuancePolicyAllowedIssuanceModes, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyAllowedIssuanceModes { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyAllowedIssuanceModes, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedIssuanceModes(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyAllowedIssuanceModes, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyAllowedIssuanceModes(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedIssuanceModes(c *Client, des, nw *CaPoolIssuancePolicyAllowedIssuanceModes) *CaPoolIssuancePolicyAllowedIssuanceModes { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyAllowedIssuanceModes while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.AllowCsrBasedIssuance, nw.AllowCsrBasedIssuance) { + nw.AllowCsrBasedIssuance = des.AllowCsrBasedIssuance + } + if dcl.BoolCanonicalize(des.AllowConfigBasedIssuance, nw.AllowConfigBasedIssuance) { + nw.AllowConfigBasedIssuance = des.AllowConfigBasedIssuance + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedIssuanceModesSet(c *Client, des, nw []CaPoolIssuancePolicyAllowedIssuanceModes) []CaPoolIssuancePolicyAllowedIssuanceModes { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyAllowedIssuanceModes + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyAllowedIssuanceModesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedIssuanceModes(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyAllowedIssuanceModesSlice(c *Client, des, nw []CaPoolIssuancePolicyAllowedIssuanceModes) []CaPoolIssuancePolicyAllowedIssuanceModes { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyAllowedIssuanceModes + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyAllowedIssuanceModes(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValues(des, initial *CaPoolIssuancePolicyBaselineValues, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValues { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValues{} + + cDes.KeyUsage = canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsage(des.KeyUsage, initial.KeyUsage, opts...) + cDes.CaOptions = canonicalizeCaPoolIssuancePolicyBaselineValuesCaOptions(des.CaOptions, initial.CaOptions, opts...) + cDes.PolicyIds = canonicalizeCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(des.PolicyIds, initial.PolicyIds, opts...) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, initial.AiaOcspServers) { + cDes.AiaOcspServers = initial.AiaOcspServers + } else { + cDes.AiaOcspServers = des.AiaOcspServers + } + cDes.AdditionalExtensions = canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesSlice(des, initial []CaPoolIssuancePolicyBaselineValues, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValues { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValues, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValues(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValues, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValues(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValues(c *Client, des, nw *CaPoolIssuancePolicyBaselineValues) *CaPoolIssuancePolicyBaselineValues { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValues while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.KeyUsage = canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsage(c, des.KeyUsage, nw.KeyUsage) + nw.CaOptions = canonicalizeNewCaPoolIssuancePolicyBaselineValuesCaOptions(c, des.CaOptions, nw.CaOptions) + nw.PolicyIds = canonicalizeNewCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(c, des.PolicyIds, nw.PolicyIds) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, nw.AiaOcspServers) { + nw.AiaOcspServers = des.AiaOcspServers + } + nw.AdditionalExtensions = canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValues) []CaPoolIssuancePolicyBaselineValues { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValues + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValues(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValues) []CaPoolIssuancePolicyBaselineValues { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValues + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValues(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsage(des, initial *CaPoolIssuancePolicyBaselineValuesKeyUsage, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesKeyUsage{} + + cDes.BaseKeyUsage = canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(des.BaseKeyUsage, initial.BaseKeyUsage, opts...) + cDes.ExtendedKeyUsage = canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(des.ExtendedKeyUsage, initial.ExtendedKeyUsage, opts...) + cDes.UnknownExtendedKeyUsages = canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(des.UnknownExtendedKeyUsages, initial.UnknownExtendedKeyUsages, opts...) + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageSlice(des, initial []CaPoolIssuancePolicyBaselineValuesKeyUsage, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsage(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesKeyUsage) *CaPoolIssuancePolicyBaselineValuesKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.BaseKeyUsage = canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, des.BaseKeyUsage, nw.BaseKeyUsage) + nw.ExtendedKeyUsage = canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, des.ExtendedKeyUsage, nw.ExtendedKeyUsage) + nw.UnknownExtendedKeyUsages = canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(c, des.UnknownExtendedKeyUsages, nw.UnknownExtendedKeyUsages) + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsage) []CaPoolIssuancePolicyBaselineValuesKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsage) []CaPoolIssuancePolicyBaselineValuesKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(des, initial *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + + if dcl.BoolCanonicalize(des.DigitalSignature, initial.DigitalSignature) || dcl.IsZeroValue(des.DigitalSignature) { + cDes.DigitalSignature = initial.DigitalSignature + } else { + cDes.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, initial.ContentCommitment) || dcl.IsZeroValue(des.ContentCommitment) { + cDes.ContentCommitment = initial.ContentCommitment + } else { + cDes.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, initial.KeyEncipherment) || dcl.IsZeroValue(des.KeyEncipherment) { + cDes.KeyEncipherment = initial.KeyEncipherment + } else { + cDes.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, initial.DataEncipherment) || dcl.IsZeroValue(des.DataEncipherment) { + cDes.DataEncipherment = initial.DataEncipherment + } else { + cDes.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, initial.KeyAgreement) || dcl.IsZeroValue(des.KeyAgreement) { + cDes.KeyAgreement = initial.KeyAgreement + } else { + cDes.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, initial.CertSign) || dcl.IsZeroValue(des.CertSign) { + cDes.CertSign = initial.CertSign + } else { + cDes.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, initial.CrlSign) || dcl.IsZeroValue(des.CrlSign) { + cDes.CrlSign = initial.CrlSign + } else { + cDes.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, initial.EncipherOnly) || dcl.IsZeroValue(des.EncipherOnly) { + cDes.EncipherOnly = initial.EncipherOnly + } else { + cDes.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, initial.DecipherOnly) || dcl.IsZeroValue(des.DecipherOnly) { + cDes.DecipherOnly = initial.DecipherOnly + } else { + cDes.DecipherOnly = des.DecipherOnly + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSlice(des, initial []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.DigitalSignature, nw.DigitalSignature) { + nw.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, nw.ContentCommitment) { + nw.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, nw.KeyEncipherment) { + nw.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, nw.DataEncipherment) { + nw.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, nw.KeyAgreement) { + nw.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, nw.CertSign) { + nw.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, nw.CrlSign) { + nw.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, nw.EncipherOnly) { + nw.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, nw.DecipherOnly) { + nw.DecipherOnly = des.DecipherOnly + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(des, initial *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + + if dcl.BoolCanonicalize(des.ServerAuth, initial.ServerAuth) || dcl.IsZeroValue(des.ServerAuth) { + cDes.ServerAuth = initial.ServerAuth + } else { + cDes.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, initial.ClientAuth) || dcl.IsZeroValue(des.ClientAuth) { + cDes.ClientAuth = initial.ClientAuth + } else { + cDes.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, initial.CodeSigning) || dcl.IsZeroValue(des.CodeSigning) { + cDes.CodeSigning = initial.CodeSigning + } else { + cDes.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, initial.EmailProtection) || dcl.IsZeroValue(des.EmailProtection) { + cDes.EmailProtection = initial.EmailProtection + } else { + cDes.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, initial.TimeStamping) || dcl.IsZeroValue(des.TimeStamping) { + cDes.TimeStamping = initial.TimeStamping + } else { + cDes.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, initial.OcspSigning) || dcl.IsZeroValue(des.OcspSigning) { + cDes.OcspSigning = initial.OcspSigning + } else { + cDes.OcspSigning = des.OcspSigning + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSlice(des, initial []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.ServerAuth, nw.ServerAuth) { + nw.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, nw.ClientAuth) { + nw.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, nw.CodeSigning) { + nw.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, nw.EmailProtection) { + nw.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, nw.TimeStamping) { + nw.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, nw.OcspSigning) { + nw.OcspSigning = des.OcspSigning + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(des, initial *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(des, initial []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesCaOptions(des, initial *CaPoolIssuancePolicyBaselineValuesCaOptions, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesCaOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesCaOptions{} + + if dcl.BoolCanonicalize(des.IsCa, initial.IsCa) || dcl.IsZeroValue(des.IsCa) { + cDes.IsCa = initial.IsCa + } else { + cDes.IsCa = des.IsCa + } + if dcl.IsZeroValue(des.MaxIssuerPathLength) || (dcl.IsEmptyValueIndirect(des.MaxIssuerPathLength) && dcl.IsEmptyValueIndirect(initial.MaxIssuerPathLength)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxIssuerPathLength = initial.MaxIssuerPathLength + } else { + cDes.MaxIssuerPathLength = des.MaxIssuerPathLength + } + if dcl.BoolCanonicalize(des.ZeroMaxIssuerPathLength, initial.ZeroMaxIssuerPathLength) || dcl.IsZeroValue(des.ZeroMaxIssuerPathLength) { + cDes.ZeroMaxIssuerPathLength = initial.ZeroMaxIssuerPathLength + } else { + cDes.ZeroMaxIssuerPathLength = des.ZeroMaxIssuerPathLength + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesCaOptionsSlice(des, initial []CaPoolIssuancePolicyBaselineValuesCaOptions, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesCaOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesCaOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesCaOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesCaOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesCaOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesCaOptions(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesCaOptions) *CaPoolIssuancePolicyBaselineValuesCaOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesCaOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.IsCa, nw.IsCa) { + nw.IsCa = des.IsCa + } + if dcl.BoolCanonicalize(des.ZeroMaxIssuerPathLength, nw.ZeroMaxIssuerPathLength) { + nw.ZeroMaxIssuerPathLength = des.ZeroMaxIssuerPathLength + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesCaOptionsSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesCaOptions) []CaPoolIssuancePolicyBaselineValuesCaOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesCaOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesCaOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesCaOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesCaOptionsSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesCaOptions) []CaPoolIssuancePolicyBaselineValuesCaOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesCaOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesCaOptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesPolicyIds(des, initial *CaPoolIssuancePolicyBaselineValuesPolicyIds, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesPolicyIds { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesPolicyIds{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(des, initial []CaPoolIssuancePolicyBaselineValuesPolicyIds, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesPolicyIds { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesPolicyIds, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesPolicyIds(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesPolicyIds, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesPolicyIds(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesPolicyIds(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesPolicyIds) *CaPoolIssuancePolicyBaselineValuesPolicyIds { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesPolicyIds while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesPolicyIdsSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesPolicyIds) []CaPoolIssuancePolicyBaselineValuesPolicyIds { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesPolicyIds + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesPolicyIdsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesPolicyIds(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesPolicyIds) []CaPoolIssuancePolicyBaselineValuesPolicyIds { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesPolicyIds + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesPolicyIds(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(des, initial *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{} + + cDes.ObjectId = canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(des, initial []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(des, initial *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSlice(des, initial []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c *Client, des, nw *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSet(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSlice(c *Client, des, nw []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyIdentityConstraints(des, initial *CaPoolIssuancePolicyIdentityConstraints, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyIdentityConstraints { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyIdentityConstraints{} + + cDes.CelExpression = canonicalizeCaPoolIssuancePolicyIdentityConstraintsCelExpression(des.CelExpression, initial.CelExpression, opts...) + if dcl.BoolCanonicalize(des.AllowSubjectPassthrough, initial.AllowSubjectPassthrough) || dcl.IsZeroValue(des.AllowSubjectPassthrough) { + cDes.AllowSubjectPassthrough = initial.AllowSubjectPassthrough + } else { + cDes.AllowSubjectPassthrough = des.AllowSubjectPassthrough + } + if dcl.BoolCanonicalize(des.AllowSubjectAltNamesPassthrough, initial.AllowSubjectAltNamesPassthrough) || dcl.IsZeroValue(des.AllowSubjectAltNamesPassthrough) { + cDes.AllowSubjectAltNamesPassthrough = initial.AllowSubjectAltNamesPassthrough + } else { + cDes.AllowSubjectAltNamesPassthrough = des.AllowSubjectAltNamesPassthrough + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyIdentityConstraintsSlice(des, initial []CaPoolIssuancePolicyIdentityConstraints, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyIdentityConstraints { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyIdentityConstraints, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyIdentityConstraints(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyIdentityConstraints, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyIdentityConstraints(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyIdentityConstraints(c *Client, des, nw *CaPoolIssuancePolicyIdentityConstraints) *CaPoolIssuancePolicyIdentityConstraints { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyIdentityConstraints while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.CelExpression = canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, des.CelExpression, nw.CelExpression) + if dcl.BoolCanonicalize(des.AllowSubjectPassthrough, nw.AllowSubjectPassthrough) { + nw.AllowSubjectPassthrough = des.AllowSubjectPassthrough + } + if dcl.BoolCanonicalize(des.AllowSubjectAltNamesPassthrough, nw.AllowSubjectAltNamesPassthrough) { + nw.AllowSubjectAltNamesPassthrough = des.AllowSubjectAltNamesPassthrough + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsSet(c *Client, des, nw []CaPoolIssuancePolicyIdentityConstraints) []CaPoolIssuancePolicyIdentityConstraints { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyIdentityConstraints + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyIdentityConstraintsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyIdentityConstraints(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsSlice(c *Client, des, nw []CaPoolIssuancePolicyIdentityConstraints) []CaPoolIssuancePolicyIdentityConstraints { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyIdentityConstraints + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyIdentityConstraints(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyIdentityConstraintsCelExpression(des, initial *CaPoolIssuancePolicyIdentityConstraintsCelExpression, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyIdentityConstraintsCelExpression { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + + if dcl.StringCanonicalize(des.Expression, initial.Expression) || dcl.IsZeroValue(des.Expression) { + cDes.Expression = initial.Expression + } else { + cDes.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, initial.Title) || dcl.IsZeroValue(des.Title) { + cDes.Title = initial.Title + } else { + cDes.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, initial.Description) || dcl.IsZeroValue(des.Description) { + cDes.Description = initial.Description + } else { + cDes.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, initial.Location) || dcl.IsZeroValue(des.Location) { + cDes.Location = initial.Location + } else { + cDes.Location = des.Location + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyIdentityConstraintsCelExpressionSlice(des, initial []CaPoolIssuancePolicyIdentityConstraintsCelExpression, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyIdentityConstraintsCelExpression { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyIdentityConstraintsCelExpression, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyIdentityConstraintsCelExpression(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyIdentityConstraintsCelExpression, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyIdentityConstraintsCelExpression(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsCelExpression(c *Client, des, nw *CaPoolIssuancePolicyIdentityConstraintsCelExpression) *CaPoolIssuancePolicyIdentityConstraintsCelExpression { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyIdentityConstraintsCelExpression while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Expression, nw.Expression) { + nw.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, nw.Title) { + nw.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, nw.Description) { + nw.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, nw.Location) { + nw.Location = des.Location + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsCelExpressionSet(c *Client, des, nw []CaPoolIssuancePolicyIdentityConstraintsCelExpression) []CaPoolIssuancePolicyIdentityConstraintsCelExpression { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyIdentityConstraintsCelExpression + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyIdentityConstraintsCelExpressionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsCelExpressionSlice(c *Client, des, nw []CaPoolIssuancePolicyIdentityConstraintsCelExpression) []CaPoolIssuancePolicyIdentityConstraintsCelExpression { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyIdentityConstraintsCelExpression + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyPassthroughExtensions(des, initial *CaPoolIssuancePolicyPassthroughExtensions, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyPassthroughExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyPassthroughExtensions{} + + if dcl.IsZeroValue(des.KnownExtensions) || (dcl.IsEmptyValueIndirect(des.KnownExtensions) && dcl.IsEmptyValueIndirect(initial.KnownExtensions)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.KnownExtensions = initial.KnownExtensions + } else { + cDes.KnownExtensions = des.KnownExtensions + } + cDes.AdditionalExtensions = canonicalizeCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyPassthroughExtensionsSlice(des, initial []CaPoolIssuancePolicyPassthroughExtensions, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyPassthroughExtensions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyPassthroughExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyPassthroughExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyPassthroughExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyPassthroughExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyPassthroughExtensions(c *Client, des, nw *CaPoolIssuancePolicyPassthroughExtensions) *CaPoolIssuancePolicyPassthroughExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyPassthroughExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.AdditionalExtensions = canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsSet(c *Client, des, nw []CaPoolIssuancePolicyPassthroughExtensions) []CaPoolIssuancePolicyPassthroughExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyPassthroughExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyPassthroughExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyPassthroughExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsSlice(c *Client, des, nw []CaPoolIssuancePolicyPassthroughExtensions) []CaPoolIssuancePolicyPassthroughExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyPassthroughExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyPassthroughExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(des, initial *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, opts ...dcl.ApplyOption) *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(des, initial []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, opts ...dcl.ApplyOption) []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c *Client, des, nw *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSet(c *Client, des, nw []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(c *Client, des, nw []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCaPoolPublishingOptions(des, initial *CaPoolPublishingOptions, opts ...dcl.ApplyOption) *CaPoolPublishingOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CaPoolPublishingOptions{} + + if dcl.BoolCanonicalize(des.PublishCaCert, initial.PublishCaCert) || dcl.IsZeroValue(des.PublishCaCert) { + cDes.PublishCaCert = initial.PublishCaCert + } else { + cDes.PublishCaCert = des.PublishCaCert + } + if dcl.BoolCanonicalize(des.PublishCrl, initial.PublishCrl) || dcl.IsZeroValue(des.PublishCrl) { + cDes.PublishCrl = initial.PublishCrl + } else { + cDes.PublishCrl = des.PublishCrl + } + + return cDes +} + +func canonicalizeCaPoolPublishingOptionsSlice(des, initial []CaPoolPublishingOptions, opts ...dcl.ApplyOption) []CaPoolPublishingOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CaPoolPublishingOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCaPoolPublishingOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CaPoolPublishingOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCaPoolPublishingOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCaPoolPublishingOptions(c *Client, des, nw *CaPoolPublishingOptions) *CaPoolPublishingOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CaPoolPublishingOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.PublishCaCert, nw.PublishCaCert) { + nw.PublishCaCert = des.PublishCaCert + } + if dcl.BoolCanonicalize(des.PublishCrl, nw.PublishCrl) { + nw.PublishCrl = des.PublishCrl + } + + return nw +} + +func canonicalizeNewCaPoolPublishingOptionsSet(c *Client, des, nw []CaPoolPublishingOptions) []CaPoolPublishingOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CaPoolPublishingOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCaPoolPublishingOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCaPoolPublishingOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCaPoolPublishingOptionsSlice(c *Client, des, nw []CaPoolPublishingOptions) []CaPoolPublishingOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CaPoolPublishingOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCaPoolPublishingOptions(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffCaPool(c *Client, desired, actual *CaPool, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Tier, actual.Tier, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Tier")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.IssuancePolicy, actual.IssuancePolicy, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyNewStyle, EmptyObject: EmptyCaPoolIssuancePolicy, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("IssuancePolicy")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PublishingOptions, actual.PublishingOptions, dcl.DiffInfo{ObjectFunction: compareCaPoolPublishingOptionsNewStyle, EmptyObject: EmptyCaPoolPublishingOptions, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("PublishingOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareCaPoolIssuancePolicyNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicy) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicy) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicy or *CaPoolIssuancePolicy", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicy) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicy) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicy", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.AllowedKeyTypes, actual.AllowedKeyTypes, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyAllowedKeyTypesNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyAllowedKeyTypes, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AllowedKeyTypes")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaximumLifetime, actual.MaximumLifetime, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("MaximumLifetime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowedIssuanceModes, actual.AllowedIssuanceModes, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyAllowedIssuanceModesNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyAllowedIssuanceModes, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AllowedIssuanceModes")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.BaselineValues, actual.BaselineValues, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValues, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("BaselineValues")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.IdentityConstraints, actual.IdentityConstraints, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyIdentityConstraintsNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyIdentityConstraints, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("IdentityConstraints")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PassthroughExtensions, actual.PassthroughExtensions, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyPassthroughExtensionsNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyPassthroughExtensions, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("PassthroughExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyAllowedKeyTypesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyAllowedKeyTypes) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyAllowedKeyTypes) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedKeyTypes or *CaPoolIssuancePolicyAllowedKeyTypes", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyAllowedKeyTypes) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyAllowedKeyTypes) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedKeyTypes", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Rsa, actual.Rsa, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyAllowedKeyTypesRsaNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyAllowedKeyTypesRsa, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Rsa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EllipticCurve, actual.EllipticCurve, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("EllipticCurve")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyAllowedKeyTypesRsaNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyAllowedKeyTypesRsa) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyAllowedKeyTypesRsa) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedKeyTypesRsa or *CaPoolIssuancePolicyAllowedKeyTypesRsa", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyAllowedKeyTypesRsa) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyAllowedKeyTypesRsa) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedKeyTypesRsa", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.MinModulusSize, actual.MinModulusSize, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("MinModulusSize")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxModulusSize, actual.MaxModulusSize, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("MaxModulusSize")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve or *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.SignatureAlgorithm, actual.SignatureAlgorithm, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("SignatureAlgorithm")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyAllowedIssuanceModesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyAllowedIssuanceModes) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyAllowedIssuanceModes) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedIssuanceModes or *CaPoolIssuancePolicyAllowedIssuanceModes", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyAllowedIssuanceModes) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyAllowedIssuanceModes) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyAllowedIssuanceModes", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.AllowCsrBasedIssuance, actual.AllowCsrBasedIssuance, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AllowCsrBasedIssuance")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowConfigBasedIssuance, actual.AllowConfigBasedIssuance, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AllowConfigBasedIssuance")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValues) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValues or *CaPoolIssuancePolicyBaselineValues", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValues) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValues", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyUsage, actual.KeyUsage, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesKeyUsageNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesKeyUsage, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("KeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaOptions, actual.CaOptions, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesCaOptionsNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesCaOptions, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("CaOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PolicyIds, actual.PolicyIds, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesPolicyIdsNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesPolicyIds, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("PolicyIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaOcspServers, actual.AiaOcspServers, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AiaOcspServers")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensions, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsage or *CaPoolIssuancePolicyBaselineValuesKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesKeyUsage) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.BaseKeyUsage, actual.BaseKeyUsage, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("BaseKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExtendedKeyUsage, actual.ExtendedKeyUsage, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ExtendedKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UnknownExtendedKeyUsages, actual.UnknownExtendedKeyUsages, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("UnknownExtendedKeyUsages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage or *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DigitalSignature, actual.DigitalSignature, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("DigitalSignature")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ContentCommitment, actual.ContentCommitment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ContentCommitment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyEncipherment, actual.KeyEncipherment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("KeyEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DataEncipherment, actual.DataEncipherment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("DataEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyAgreement, actual.KeyAgreement, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("KeyAgreement")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertSign, actual.CertSign, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("CertSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlSign, actual.CrlSign, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("CrlSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EncipherOnly, actual.EncipherOnly, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("EncipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DecipherOnly, actual.DecipherOnly, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("DecipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage or *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ServerAuth, actual.ServerAuth, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ServerAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ClientAuth, actual.ClientAuth, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ClientAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CodeSigning, actual.CodeSigning, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("CodeSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailProtection, actual.EmailProtection, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("EmailProtection")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.TimeStamping, actual.TimeStamping, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("TimeStamping")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OcspSigning, actual.OcspSigning, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("OcspSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages or *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesCaOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesCaOptions) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesCaOptions or *CaPoolIssuancePolicyBaselineValuesCaOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesCaOptions) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesCaOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.IsCa, actual.IsCa, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("IsCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxIssuerPathLength, actual.MaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("MaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ZeroMaxIssuerPathLength, actual.ZeroMaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ZeroMaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesPolicyIdsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesPolicyIds) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesPolicyIds or *CaPoolIssuancePolicyBaselineValuesPolicyIds", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesPolicyIds) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesPolicyIds", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesAdditionalExtensions or *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId or *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyIdentityConstraintsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyIdentityConstraints) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyIdentityConstraints) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyIdentityConstraints or *CaPoolIssuancePolicyIdentityConstraints", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyIdentityConstraints) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyIdentityConstraints) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyIdentityConstraints", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CelExpression, actual.CelExpression, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyIdentityConstraintsCelExpressionNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyIdentityConstraintsCelExpression, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("CelExpression")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowSubjectPassthrough, actual.AllowSubjectPassthrough, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AllowSubjectPassthrough")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowSubjectAltNamesPassthrough, actual.AllowSubjectAltNamesPassthrough, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AllowSubjectAltNamesPassthrough")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyIdentityConstraintsCelExpressionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyIdentityConstraintsCelExpression) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyIdentityConstraintsCelExpression) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyIdentityConstraintsCelExpression or *CaPoolIssuancePolicyIdentityConstraintsCelExpression", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyIdentityConstraintsCelExpression) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyIdentityConstraintsCelExpression) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyIdentityConstraintsCelExpression", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Expression, actual.Expression, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Expression")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Title, actual.Title, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Title")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyPassthroughExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyPassthroughExtensions) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyPassthroughExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyPassthroughExtensions or *CaPoolIssuancePolicyPassthroughExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyPassthroughExtensions) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyPassthroughExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyPassthroughExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KnownExtensions, actual.KnownExtensions, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("KnownExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsNewStyle, EmptyObject: EmptyCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions or *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCaPoolPublishingOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CaPoolPublishingOptions) + if !ok { + desiredNotPointer, ok := d.(CaPoolPublishingOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolPublishingOptions or *CaPoolPublishingOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CaPoolPublishingOptions) + if !ok { + actualNotPointer, ok := a.(CaPoolPublishingOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CaPoolPublishingOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.PublishCaCert, actual.PublishCaCert, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("PublishCaCert")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PublishCrl, actual.PublishCrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCaPoolUpdateCaPoolOperation")}, fn.AddNest("PublishCrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *CaPool) urlNormalized() *CaPool { + normalized := dcl.Copy(*r).(CaPool) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + return &normalized +} + +func (r *CaPool) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateCaPool" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the CaPool resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *CaPool) marshal(c *Client) ([]byte, error) { + m, err := expandCaPool(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling CaPool: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalCaPool decodes JSON responses into the CaPool resource schema. +func unmarshalCaPool(b []byte, c *Client, res *CaPool) (*CaPool, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapCaPool(m, c, res) +} + +func unmarshalMapCaPool(m map[string]interface{}, c *Client, res *CaPool) (*CaPool, error) { + + flattened := flattenCaPool(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandCaPool expands CaPool into a JSON request object. +func expandCaPool(c *Client, f *CaPool) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.DeriveField("projects/%s/locations/%s/caPools/%s", f.Name, dcl.SelfLinkToName(f.Project), dcl.SelfLinkToName(f.Location), dcl.SelfLinkToName(f.Name)); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.Tier; dcl.ValueShouldBeSent(v) { + m["tier"] = v + } + if v, err := expandCaPoolIssuancePolicy(c, f.IssuancePolicy, res); err != nil { + return nil, fmt.Errorf("error expanding IssuancePolicy into issuancePolicy: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["issuancePolicy"] = v + } + if v, err := expandCaPoolPublishingOptions(c, f.PublishingOptions, res); err != nil { + return nil, fmt.Errorf("error expanding PublishingOptions into publishingOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["publishingOptions"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenCaPool flattens CaPool from a JSON request object into the +// CaPool type. +func flattenCaPool(c *Client, i interface{}, res *CaPool) *CaPool { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &CaPool{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.Tier = flattenCaPoolTierEnum(m["tier"]) + resultRes.IssuancePolicy = flattenCaPoolIssuancePolicy(c, m["issuancePolicy"], res) + resultRes.PublishingOptions = flattenCaPoolPublishingOptions(c, m["publishingOptions"], res) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + + return resultRes +} + +// expandCaPoolIssuancePolicyMap expands the contents of CaPoolIssuancePolicy into a JSON +// request object. +func expandCaPoolIssuancePolicyMap(c *Client, f map[string]CaPoolIssuancePolicy, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicy(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicySlice expands the contents of CaPoolIssuancePolicy into a JSON +// request object. +func expandCaPoolIssuancePolicySlice(c *Client, f []CaPoolIssuancePolicy, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicy(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyMap flattens the contents of CaPoolIssuancePolicy from a JSON +// response object. +func flattenCaPoolIssuancePolicyMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicy { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicy{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicy{} + } + + items := make(map[string]CaPoolIssuancePolicy) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicy(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicySlice flattens the contents of CaPoolIssuancePolicy from a JSON +// response object. +func flattenCaPoolIssuancePolicySlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicy { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicy{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicy{} + } + + items := make([]CaPoolIssuancePolicy, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicy(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicy expands an instance of CaPoolIssuancePolicy into a JSON +// request object. +func expandCaPoolIssuancePolicy(c *Client, f *CaPoolIssuancePolicy, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCaPoolIssuancePolicyAllowedKeyTypesSlice(c, f.AllowedKeyTypes, res); err != nil { + return nil, fmt.Errorf("error expanding AllowedKeyTypes into allowedKeyTypes: %w", err) + } else if v != nil { + m["allowedKeyTypes"] = v + } + if v := f.MaximumLifetime; !dcl.IsEmptyValueIndirect(v) { + m["maximumLifetime"] = v + } + if v, err := expandCaPoolIssuancePolicyAllowedIssuanceModes(c, f.AllowedIssuanceModes, res); err != nil { + return nil, fmt.Errorf("error expanding AllowedIssuanceModes into allowedIssuanceModes: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["allowedIssuanceModes"] = v + } + if v, err := expandCaPoolIssuancePolicyBaselineValues(c, f.BaselineValues, res); err != nil { + return nil, fmt.Errorf("error expanding BaselineValues into baselineValues: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baselineValues"] = v + } + if v, err := expandCaPoolIssuancePolicyIdentityConstraints(c, f.IdentityConstraints, res); err != nil { + return nil, fmt.Errorf("error expanding IdentityConstraints into identityConstraints: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["identityConstraints"] = v + } + if v, err := expandCaPoolIssuancePolicyPassthroughExtensions(c, f.PassthroughExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding PassthroughExtensions into passthroughExtensions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["passthroughExtensions"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicy flattens an instance of CaPoolIssuancePolicy from a JSON +// response object. +func flattenCaPoolIssuancePolicy(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicy { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicy{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicy + } + r.AllowedKeyTypes = flattenCaPoolIssuancePolicyAllowedKeyTypesSlice(c, m["allowedKeyTypes"], res) + r.MaximumLifetime = dcl.FlattenString(m["maximumLifetime"]) + r.AllowedIssuanceModes = flattenCaPoolIssuancePolicyAllowedIssuanceModes(c, m["allowedIssuanceModes"], res) + r.BaselineValues = flattenCaPoolIssuancePolicyBaselineValues(c, m["baselineValues"], res) + r.IdentityConstraints = flattenCaPoolIssuancePolicyIdentityConstraints(c, m["identityConstraints"], res) + r.PassthroughExtensions = flattenCaPoolIssuancePolicyPassthroughExtensions(c, m["passthroughExtensions"], res) + + return r +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesMap expands the contents of CaPoolIssuancePolicyAllowedKeyTypes into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesMap(c *Client, f map[string]CaPoolIssuancePolicyAllowedKeyTypes, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedKeyTypes(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesSlice expands the contents of CaPoolIssuancePolicyAllowedKeyTypes into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesSlice(c *Client, f []CaPoolIssuancePolicyAllowedKeyTypes, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedKeyTypes(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesMap flattens the contents of CaPoolIssuancePolicyAllowedKeyTypes from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyAllowedKeyTypes { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyAllowedKeyTypes{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyAllowedKeyTypes{} + } + + items := make(map[string]CaPoolIssuancePolicyAllowedKeyTypes) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyAllowedKeyTypes(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesSlice flattens the contents of CaPoolIssuancePolicyAllowedKeyTypes from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyAllowedKeyTypes { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyAllowedKeyTypes{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyAllowedKeyTypes{} + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypes, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyAllowedKeyTypes(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyAllowedKeyTypes expands an instance of CaPoolIssuancePolicyAllowedKeyTypes into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypes(c *Client, f *CaPoolIssuancePolicyAllowedKeyTypes, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCaPoolIssuancePolicyAllowedKeyTypesRsa(c, f.Rsa, res); err != nil { + return nil, fmt.Errorf("error expanding Rsa into rsa: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["rsa"] = v + } + if v, err := expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, f.EllipticCurve, res); err != nil { + return nil, fmt.Errorf("error expanding EllipticCurve into ellipticCurve: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["ellipticCurve"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypes flattens an instance of CaPoolIssuancePolicyAllowedKeyTypes from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypes(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyAllowedKeyTypes { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyAllowedKeyTypes{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyAllowedKeyTypes + } + r.Rsa = flattenCaPoolIssuancePolicyAllowedKeyTypesRsa(c, m["rsa"], res) + r.EllipticCurve = flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, m["ellipticCurve"], res) + + return r +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesRsaMap expands the contents of CaPoolIssuancePolicyAllowedKeyTypesRsa into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesRsaMap(c *Client, f map[string]CaPoolIssuancePolicyAllowedKeyTypesRsa, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedKeyTypesRsa(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesRsaSlice expands the contents of CaPoolIssuancePolicyAllowedKeyTypesRsa into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesRsaSlice(c *Client, f []CaPoolIssuancePolicyAllowedKeyTypesRsa, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedKeyTypesRsa(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesRsaMap flattens the contents of CaPoolIssuancePolicyAllowedKeyTypesRsa from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesRsaMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyAllowedKeyTypesRsa { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyAllowedKeyTypesRsa{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyAllowedKeyTypesRsa{} + } + + items := make(map[string]CaPoolIssuancePolicyAllowedKeyTypesRsa) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyAllowedKeyTypesRsa(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesRsaSlice flattens the contents of CaPoolIssuancePolicyAllowedKeyTypesRsa from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesRsaSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyAllowedKeyTypesRsa { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyAllowedKeyTypesRsa{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyAllowedKeyTypesRsa{} + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesRsa, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyAllowedKeyTypesRsa(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesRsa expands an instance of CaPoolIssuancePolicyAllowedKeyTypesRsa into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesRsa(c *Client, f *CaPoolIssuancePolicyAllowedKeyTypesRsa, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.MinModulusSize; !dcl.IsEmptyValueIndirect(v) { + m["minModulusSize"] = v + } + if v := f.MaxModulusSize; !dcl.IsEmptyValueIndirect(v) { + m["maxModulusSize"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesRsa flattens an instance of CaPoolIssuancePolicyAllowedKeyTypesRsa from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesRsa(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyAllowedKeyTypesRsa { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyAllowedKeyTypesRsa{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyAllowedKeyTypesRsa + } + r.MinModulusSize = dcl.FlattenInteger(m["minModulusSize"]) + r.MaxModulusSize = dcl.FlattenInteger(m["maxModulusSize"]) + + return r +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveMap expands the contents of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveMap(c *Client, f map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSlice expands the contents of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSlice(c *Client, f []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveMap flattens the contents of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + } + + items := make(map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSlice flattens the contents of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve expands an instance of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c *Client, f *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.SignatureAlgorithm; !dcl.IsEmptyValueIndirect(v) { + m["signatureAlgorithm"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve flattens an instance of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyAllowedKeyTypesEllipticCurve + } + r.SignatureAlgorithm = flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum(m["signatureAlgorithm"]) + + return r +} + +// expandCaPoolIssuancePolicyAllowedIssuanceModesMap expands the contents of CaPoolIssuancePolicyAllowedIssuanceModes into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedIssuanceModesMap(c *Client, f map[string]CaPoolIssuancePolicyAllowedIssuanceModes, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedIssuanceModes(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyAllowedIssuanceModesSlice expands the contents of CaPoolIssuancePolicyAllowedIssuanceModes into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedIssuanceModesSlice(c *Client, f []CaPoolIssuancePolicyAllowedIssuanceModes, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyAllowedIssuanceModes(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyAllowedIssuanceModesMap flattens the contents of CaPoolIssuancePolicyAllowedIssuanceModes from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedIssuanceModesMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyAllowedIssuanceModes { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyAllowedIssuanceModes{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyAllowedIssuanceModes{} + } + + items := make(map[string]CaPoolIssuancePolicyAllowedIssuanceModes) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyAllowedIssuanceModes(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyAllowedIssuanceModesSlice flattens the contents of CaPoolIssuancePolicyAllowedIssuanceModes from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedIssuanceModesSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyAllowedIssuanceModes { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyAllowedIssuanceModes{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyAllowedIssuanceModes{} + } + + items := make([]CaPoolIssuancePolicyAllowedIssuanceModes, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyAllowedIssuanceModes(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyAllowedIssuanceModes expands an instance of CaPoolIssuancePolicyAllowedIssuanceModes into a JSON +// request object. +func expandCaPoolIssuancePolicyAllowedIssuanceModes(c *Client, f *CaPoolIssuancePolicyAllowedIssuanceModes, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.AllowCsrBasedIssuance; !dcl.IsEmptyValueIndirect(v) { + m["allowCsrBasedIssuance"] = v + } + if v := f.AllowConfigBasedIssuance; !dcl.IsEmptyValueIndirect(v) { + m["allowConfigBasedIssuance"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyAllowedIssuanceModes flattens an instance of CaPoolIssuancePolicyAllowedIssuanceModes from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedIssuanceModes(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyAllowedIssuanceModes { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyAllowedIssuanceModes{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyAllowedIssuanceModes + } + r.AllowCsrBasedIssuance = dcl.FlattenBool(m["allowCsrBasedIssuance"]) + r.AllowConfigBasedIssuance = dcl.FlattenBool(m["allowConfigBasedIssuance"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesMap expands the contents of CaPoolIssuancePolicyBaselineValues into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValues, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValues(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesSlice expands the contents of CaPoolIssuancePolicyBaselineValues into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesSlice(c *Client, f []CaPoolIssuancePolicyBaselineValues, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValues(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesMap flattens the contents of CaPoolIssuancePolicyBaselineValues from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValues { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValues{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValues{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValues) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValues(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesSlice flattens the contents of CaPoolIssuancePolicyBaselineValues from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValues { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValues{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValues{} + } + + items := make([]CaPoolIssuancePolicyBaselineValues, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValues(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValues expands an instance of CaPoolIssuancePolicyBaselineValues into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValues(c *Client, f *CaPoolIssuancePolicyBaselineValues, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsage(c, f.KeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding KeyUsage into keyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keyUsage"] = v + } + if v, err := expandCaPoolIssuancePolicyBaselineValuesCAOptions(c, f.CaOptions, res); err != nil { + return nil, fmt.Errorf("error expanding CaOptions into caOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caOptions"] = v + } + if v, err := expandCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(c, f.PolicyIds, res); err != nil { + return nil, fmt.Errorf("error expanding PolicyIds into policyIds: %w", err) + } else if v != nil { + m["policyIds"] = v + } + if v := f.AiaOcspServers; v != nil { + m["aiaOcspServers"] = v + } + if v, err := expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValues flattens an instance of CaPoolIssuancePolicyBaselineValues from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValues(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValues { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValues{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValues + } + r.KeyUsage = flattenCaPoolIssuancePolicyBaselineValuesKeyUsage(c, m["keyUsage"], res) + r.CaOptions = flattenCaPoolIssuancePolicyBaselineValuesCAOptions(c, m["caOptions"], res) + r.PolicyIds = flattenCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(c, m["policyIds"], res) + r.AiaOcspServers = dcl.FlattenStringSlice(m["aiaOcspServers"]) + r.AdditionalExtensions = flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageMap expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesKeyUsage, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageSlice expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesKeyUsage, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageMap flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsage{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsage{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesKeyUsage) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesKeyUsage{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesKeyUsage{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsage expands an instance of CaPoolIssuancePolicyBaselineValuesKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsage(c *Client, f *CaPoolIssuancePolicyBaselineValuesKeyUsage, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, f.BaseKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding BaseKeyUsage into baseKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baseKeyUsage"] = v + } + if v, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, f.ExtendedKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding ExtendedKeyUsage into extendedKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["extendedKeyUsage"] = v + } + if v, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(c, f.UnknownExtendedKeyUsages, res); err != nil { + return nil, fmt.Errorf("error expanding UnknownExtendedKeyUsages into unknownExtendedKeyUsages: %w", err) + } else if v != nil { + m["unknownExtendedKeyUsages"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsage flattens an instance of CaPoolIssuancePolicyBaselineValuesKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsage(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesKeyUsage + } + r.BaseKeyUsage = flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, m["baseKeyUsage"], res) + r.ExtendedKeyUsage = flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, m["extendedKeyUsage"], res) + r.UnknownExtendedKeyUsages = flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(c, m["unknownExtendedKeyUsages"], res) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageMap expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSlice expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageMap flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage expands an instance of CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c *Client, f *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DigitalSignature; !dcl.IsEmptyValueIndirect(v) { + m["digitalSignature"] = v + } + if v := f.ContentCommitment; !dcl.IsEmptyValueIndirect(v) { + m["contentCommitment"] = v + } + if v := f.KeyEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["keyEncipherment"] = v + } + if v := f.DataEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["dataEncipherment"] = v + } + if v := f.KeyAgreement; !dcl.IsEmptyValueIndirect(v) { + m["keyAgreement"] = v + } + if v := f.CertSign; !dcl.IsEmptyValueIndirect(v) { + m["certSign"] = v + } + if v := f.CrlSign; !dcl.IsEmptyValueIndirect(v) { + m["crlSign"] = v + } + if v := f.EncipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["encipherOnly"] = v + } + if v := f.DecipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["decipherOnly"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage flattens an instance of CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageMap expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSlice expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageMap flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage expands an instance of CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c *Client, f *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ServerAuth; !dcl.IsEmptyValueIndirect(v) { + m["serverAuth"] = v + } + if v := f.ClientAuth; !dcl.IsEmptyValueIndirect(v) { + m["clientAuth"] = v + } + if v := f.CodeSigning; !dcl.IsEmptyValueIndirect(v) { + m["codeSigning"] = v + } + if v := f.EmailProtection; !dcl.IsEmptyValueIndirect(v) { + m["emailProtection"] = v + } + if v := f.TimeStamping; !dcl.IsEmptyValueIndirect(v) { + m["timeStamping"] = v + } + if v := f.OcspSigning; !dcl.IsEmptyValueIndirect(v) { + m["ocspSigning"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage flattens an instance of CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesMap expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice expands the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesMap flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages expands an instance of CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c *Client, f *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages flattens an instance of CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesCaOptionsMap expands the contents of CaPoolIssuancePolicyBaselineValuesCaOptions into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesCaOptionsMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesCaOptions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesCaOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesCaOptionsSlice expands the contents of CaPoolIssuancePolicyBaselineValuesCaOptions into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesCaOptionsSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesCaOptions, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesCaOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesCaOptionsMap flattens the contents of CaPoolIssuancePolicyBaselineValuesCaOptions from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesCaOptionsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesCaOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesCaOptions{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesCaOptions{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesCaOptions) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesCaOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesCaOptionsSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesCaOptions from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesCaOptionsSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesCaOptions { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesCaOptions{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesCaOptions{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesCaOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesCaOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesCaOptions expands an instance of CaPoolIssuancePolicyBaselineValuesCaOptions into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesCaOptions(c *Client, f *CaPoolIssuancePolicyBaselineValuesCaOptions, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + if v := f.MaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["maxIssuerPathLength"] = v + } + if v := f.ZeroMaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["zeroMaxIssuerPathLength"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesCaOptions flattens an instance of CaPoolIssuancePolicyBaselineValuesCaOptions from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesCaOptions(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesCaOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesCaOptions + } + r.IsCa = dcl.FlattenBool(m["isCa"]) + r.MaxIssuerPathLength = dcl.FlattenInteger(m["maxIssuerPathLength"]) + r.ZeroMaxIssuerPathLength = dcl.FlattenBool(m["zeroMaxIssuerPathLength"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesPolicyIdsMap expands the contents of CaPoolIssuancePolicyBaselineValuesPolicyIds into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesPolicyIdsMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesPolicyIds, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice expands the contents of CaPoolIssuancePolicyBaselineValuesPolicyIds into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesPolicyIds, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesPolicyIdsMap flattens the contents of CaPoolIssuancePolicyBaselineValuesPolicyIds from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesPolicyIdsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesPolicyIds { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesPolicyIds{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesPolicyIds{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesPolicyIds) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesPolicyIds(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesPolicyIds from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesPolicyIdsSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesPolicyIds { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesPolicyIds{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesPolicyIds{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesPolicyIds, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesPolicyIds(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesPolicyIds expands an instance of CaPoolIssuancePolicyBaselineValuesPolicyIds into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesPolicyIds(c *Client, f *CaPoolIssuancePolicyBaselineValuesPolicyIds, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesPolicyIds flattens an instance of CaPoolIssuancePolicyBaselineValuesPolicyIds from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesPolicyIds(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesPolicyIds { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesPolicyIds{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesPolicyIds + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsMap expands the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice expands the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsMap flattens the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensions expands an instance of CaPoolIssuancePolicyBaselineValuesAdditionalExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c *Client, f *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensions flattens an instance of CaPoolIssuancePolicyBaselineValuesAdditionalExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensions(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensions + } + r.ObjectId = flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdMap expands the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdMap(c *Client, f map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSlice expands the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSlice(c *Client, f []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdMap flattens the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + } + + items := make(map[string]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSlice flattens the contents of CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + } + + items := make([]CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId expands an instance of CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId into a JSON +// request object. +func expandCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c *Client, f *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId flattens an instance of CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCaPoolIssuancePolicyIdentityConstraintsMap expands the contents of CaPoolIssuancePolicyIdentityConstraints into a JSON +// request object. +func expandCaPoolIssuancePolicyIdentityConstraintsMap(c *Client, f map[string]CaPoolIssuancePolicyIdentityConstraints, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyIdentityConstraints(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyIdentityConstraintsSlice expands the contents of CaPoolIssuancePolicyIdentityConstraints into a JSON +// request object. +func expandCaPoolIssuancePolicyIdentityConstraintsSlice(c *Client, f []CaPoolIssuancePolicyIdentityConstraints, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyIdentityConstraints(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyIdentityConstraintsMap flattens the contents of CaPoolIssuancePolicyIdentityConstraints from a JSON +// response object. +func flattenCaPoolIssuancePolicyIdentityConstraintsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyIdentityConstraints { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyIdentityConstraints{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyIdentityConstraints{} + } + + items := make(map[string]CaPoolIssuancePolicyIdentityConstraints) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyIdentityConstraints(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyIdentityConstraintsSlice flattens the contents of CaPoolIssuancePolicyIdentityConstraints from a JSON +// response object. +func flattenCaPoolIssuancePolicyIdentityConstraintsSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyIdentityConstraints { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyIdentityConstraints{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyIdentityConstraints{} + } + + items := make([]CaPoolIssuancePolicyIdentityConstraints, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyIdentityConstraints(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyIdentityConstraints expands an instance of CaPoolIssuancePolicyIdentityConstraints into a JSON +// request object. +func expandCaPoolIssuancePolicyIdentityConstraints(c *Client, f *CaPoolIssuancePolicyIdentityConstraints, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, f.CelExpression, res); err != nil { + return nil, fmt.Errorf("error expanding CelExpression into celExpression: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["celExpression"] = v + } + if v := f.AllowSubjectPassthrough; !dcl.IsEmptyValueIndirect(v) { + m["allowSubjectPassthrough"] = v + } + if v := f.AllowSubjectAltNamesPassthrough; !dcl.IsEmptyValueIndirect(v) { + m["allowSubjectAltNamesPassthrough"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyIdentityConstraints flattens an instance of CaPoolIssuancePolicyIdentityConstraints from a JSON +// response object. +func flattenCaPoolIssuancePolicyIdentityConstraints(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyIdentityConstraints { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyIdentityConstraints{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyIdentityConstraints + } + r.CelExpression = flattenCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, m["celExpression"], res) + r.AllowSubjectPassthrough = dcl.FlattenBool(m["allowSubjectPassthrough"]) + r.AllowSubjectAltNamesPassthrough = dcl.FlattenBool(m["allowSubjectAltNamesPassthrough"]) + + return r +} + +// expandCaPoolIssuancePolicyIdentityConstraintsCelExpressionMap expands the contents of CaPoolIssuancePolicyIdentityConstraintsCelExpression into a JSON +// request object. +func expandCaPoolIssuancePolicyIdentityConstraintsCelExpressionMap(c *Client, f map[string]CaPoolIssuancePolicyIdentityConstraintsCelExpression, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyIdentityConstraintsCelExpressionSlice expands the contents of CaPoolIssuancePolicyIdentityConstraintsCelExpression into a JSON +// request object. +func expandCaPoolIssuancePolicyIdentityConstraintsCelExpressionSlice(c *Client, f []CaPoolIssuancePolicyIdentityConstraintsCelExpression, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyIdentityConstraintsCelExpressionMap flattens the contents of CaPoolIssuancePolicyIdentityConstraintsCelExpression from a JSON +// response object. +func flattenCaPoolIssuancePolicyIdentityConstraintsCelExpressionMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyIdentityConstraintsCelExpression { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + } + + items := make(map[string]CaPoolIssuancePolicyIdentityConstraintsCelExpression) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyIdentityConstraintsCelExpressionSlice flattens the contents of CaPoolIssuancePolicyIdentityConstraintsCelExpression from a JSON +// response object. +func flattenCaPoolIssuancePolicyIdentityConstraintsCelExpressionSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyIdentityConstraintsCelExpression { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + } + + items := make([]CaPoolIssuancePolicyIdentityConstraintsCelExpression, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyIdentityConstraintsCelExpression(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyIdentityConstraintsCelExpression expands an instance of CaPoolIssuancePolicyIdentityConstraintsCelExpression into a JSON +// request object. +func expandCaPoolIssuancePolicyIdentityConstraintsCelExpression(c *Client, f *CaPoolIssuancePolicyIdentityConstraintsCelExpression, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Expression; !dcl.IsEmptyValueIndirect(v) { + m["expression"] = v + } + if v := f.Title; !dcl.IsEmptyValueIndirect(v) { + m["title"] = v + } + if v := f.Description; !dcl.IsEmptyValueIndirect(v) { + m["description"] = v + } + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyIdentityConstraintsCelExpression flattens an instance of CaPoolIssuancePolicyIdentityConstraintsCelExpression from a JSON +// response object. +func flattenCaPoolIssuancePolicyIdentityConstraintsCelExpression(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyIdentityConstraintsCelExpression { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyIdentityConstraintsCelExpression + } + r.Expression = dcl.FlattenString(m["expression"]) + r.Title = dcl.FlattenString(m["title"]) + r.Description = dcl.FlattenString(m["description"]) + r.Location = dcl.FlattenString(m["location"]) + + return r +} + +// expandCaPoolIssuancePolicyPassthroughExtensionsMap expands the contents of CaPoolIssuancePolicyPassthroughExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyPassthroughExtensionsMap(c *Client, f map[string]CaPoolIssuancePolicyPassthroughExtensions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyPassthroughExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyPassthroughExtensionsSlice expands the contents of CaPoolIssuancePolicyPassthroughExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyPassthroughExtensionsSlice(c *Client, f []CaPoolIssuancePolicyPassthroughExtensions, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyPassthroughExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsMap flattens the contents of CaPoolIssuancePolicyPassthroughExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyPassthroughExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyPassthroughExtensions{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyPassthroughExtensions{} + } + + items := make(map[string]CaPoolIssuancePolicyPassthroughExtensions) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyPassthroughExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsSlice flattens the contents of CaPoolIssuancePolicyPassthroughExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyPassthroughExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyPassthroughExtensions{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyPassthroughExtensions{} + } + + items := make([]CaPoolIssuancePolicyPassthroughExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyPassthroughExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyPassthroughExtensions expands an instance of CaPoolIssuancePolicyPassthroughExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyPassthroughExtensions(c *Client, f *CaPoolIssuancePolicyPassthroughExtensions, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.KnownExtensions; v != nil { + m["knownExtensions"] = v + } + if v, err := expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyPassthroughExtensions flattens an instance of CaPoolIssuancePolicyPassthroughExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensions(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyPassthroughExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyPassthroughExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyPassthroughExtensions + } + r.KnownExtensions = flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumSlice(c, m["knownExtensions"], res) + r.AdditionalExtensions = flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsMap expands the contents of CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsMap(c *Client, f map[string]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice expands the contents of CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(c *Client, f []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsMap flattens the contents of CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{} + } + + items := make(map[string]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice flattens the contents of CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{} + } + + items := make([]CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions expands an instance of CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions into a JSON +// request object. +func expandCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c *Client, f *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions flattens an instance of CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions(c *Client, i interface{}, res *CaPool) *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCaPoolPublishingOptionsMap expands the contents of CaPoolPublishingOptions into a JSON +// request object. +func expandCaPoolPublishingOptionsMap(c *Client, f map[string]CaPoolPublishingOptions, res *CaPool) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCaPoolPublishingOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCaPoolPublishingOptionsSlice expands the contents of CaPoolPublishingOptions into a JSON +// request object. +func expandCaPoolPublishingOptionsSlice(c *Client, f []CaPoolPublishingOptions, res *CaPool) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCaPoolPublishingOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCaPoolPublishingOptionsMap flattens the contents of CaPoolPublishingOptions from a JSON +// response object. +func flattenCaPoolPublishingOptionsMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolPublishingOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolPublishingOptions{} + } + + if len(a) == 0 { + return map[string]CaPoolPublishingOptions{} + } + + items := make(map[string]CaPoolPublishingOptions) + for k, item := range a { + items[k] = *flattenCaPoolPublishingOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCaPoolPublishingOptionsSlice flattens the contents of CaPoolPublishingOptions from a JSON +// response object. +func flattenCaPoolPublishingOptionsSlice(c *Client, i interface{}, res *CaPool) []CaPoolPublishingOptions { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolPublishingOptions{} + } + + if len(a) == 0 { + return []CaPoolPublishingOptions{} + } + + items := make([]CaPoolPublishingOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolPublishingOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCaPoolPublishingOptions expands an instance of CaPoolPublishingOptions into a JSON +// request object. +func expandCaPoolPublishingOptions(c *Client, f *CaPoolPublishingOptions, res *CaPool) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.PublishCaCert; !dcl.IsEmptyValueIndirect(v) { + m["publishCaCert"] = v + } + if v := f.PublishCrl; !dcl.IsEmptyValueIndirect(v) { + m["publishCrl"] = v + } + + return m, nil +} + +// flattenCaPoolPublishingOptions flattens an instance of CaPoolPublishingOptions from a JSON +// response object. +func flattenCaPoolPublishingOptions(c *Client, i interface{}, res *CaPool) *CaPoolPublishingOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CaPoolPublishingOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolPublishingOptions + } + r.PublishCaCert = dcl.FlattenBool(m["publishCaCert"]) + r.PublishCrl = dcl.FlattenBool(m["publishCrl"]) + + return r +} + +// flattenCaPoolTierEnumMap flattens the contents of CaPoolTierEnum from a JSON +// response object. +func flattenCaPoolTierEnumMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolTierEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolTierEnum{} + } + + if len(a) == 0 { + return map[string]CaPoolTierEnum{} + } + + items := make(map[string]CaPoolTierEnum) + for k, item := range a { + items[k] = *flattenCaPoolTierEnum(item.(interface{})) + } + + return items +} + +// flattenCaPoolTierEnumSlice flattens the contents of CaPoolTierEnum from a JSON +// response object. +func flattenCaPoolTierEnumSlice(c *Client, i interface{}, res *CaPool) []CaPoolTierEnum { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolTierEnum{} + } + + if len(a) == 0 { + return []CaPoolTierEnum{} + } + + items := make([]CaPoolTierEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolTierEnum(item.(interface{}))) + } + + return items +} + +// flattenCaPoolTierEnum asserts that an interface is a string, and returns a +// pointer to a *CaPoolTierEnum with the same value as that string. +func flattenCaPoolTierEnum(i interface{}) *CaPoolTierEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CaPoolTierEnumRef(s) +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumMap flattens the contents of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum{} + } + + items := make(map[string]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum(item.(interface{})) + } + + return items +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumSlice flattens the contents of CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum from a JSON +// response object. +func flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum{} + } + + items := make([]CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum(item.(interface{}))) + } + + return items +} + +// flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum asserts that an interface is a string, and returns a +// pointer to a *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum with the same value as that string. +func flattenCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum(i interface{}) *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnumRef(s) +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumMap flattens the contents of CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumMap(c *Client, i interface{}, res *CaPool) map[string]CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum{} + } + + if len(a) == 0 { + return map[string]CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum{} + } + + items := make(map[string]CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum) + for k, item := range a { + items[k] = *flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum(item.(interface{})) + } + + return items +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumSlice flattens the contents of CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum from a JSON +// response object. +func flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumSlice(c *Client, i interface{}, res *CaPool) []CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum { + a, ok := i.([]interface{}) + if !ok { + return []CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum{} + } + + if len(a) == 0 { + return []CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum{} + } + + items := make([]CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum(item.(interface{}))) + } + + return items +} + +// flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum asserts that an interface is a string, and returns a +// pointer to a *CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum with the same value as that string. +func flattenCaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum(i interface{}) *CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnumRef(s) +} + +// This function returns a matcher that checks whether a serialized resource matches this resource +// in its parameters (as defined by the fields in a Get, which definitionally define resource +// identity). This is useful in extracting the element from a List call. +func (r *CaPool) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalCaPool(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if nr.Project == nil && ncr.Project == nil { + c.Config.Logger.Info("Both Project fields null - considering equal.") + } else if nr.Project == nil || ncr.Project == nil { + c.Config.Logger.Info("Only one Project field is null - considering unequal.") + return false + } else if *nr.Project != *ncr.Project { + return false + } + if nr.Location == nil && ncr.Location == nil { + c.Config.Logger.Info("Both Location fields null - considering equal.") + } else if nr.Location == nil || ncr.Location == nil { + c.Config.Logger.Info("Only one Location field is null - considering unequal.") + return false + } else if *nr.Location != *ncr.Location { + return false + } + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + return true + } +} + +type caPoolDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp caPoolApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToCaPoolDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]caPoolDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []caPoolDiff + // For each operation name, create a caPoolDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := caPoolDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToCaPoolApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToCaPoolApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (caPoolApiOperation, error) { + switch opName { + + case "updateCaPoolUpdateCaPoolOperation": + return &updateCaPoolUpdateCaPoolOperation{FieldDiffs: fieldDiffs}, nil + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractCaPoolFields(r *CaPool) error { + vIssuancePolicy := r.IssuancePolicy + if vIssuancePolicy == nil { + // note: explicitly not the empty object. + vIssuancePolicy = &CaPoolIssuancePolicy{} + } + if err := extractCaPoolIssuancePolicyFields(r, vIssuancePolicy); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vIssuancePolicy) { + r.IssuancePolicy = vIssuancePolicy + } + vPublishingOptions := r.PublishingOptions + if vPublishingOptions == nil { + // note: explicitly not the empty object. + vPublishingOptions = &CaPoolPublishingOptions{} + } + if err := extractCaPoolPublishingOptionsFields(r, vPublishingOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublishingOptions) { + r.PublishingOptions = vPublishingOptions + } + return nil +} +func extractCaPoolIssuancePolicyFields(r *CaPool, o *CaPoolIssuancePolicy) error { + vAllowedIssuanceModes := o.AllowedIssuanceModes + if vAllowedIssuanceModes == nil { + // note: explicitly not the empty object. + vAllowedIssuanceModes = &CaPoolIssuancePolicyAllowedIssuanceModes{} + } + if err := extractCaPoolIssuancePolicyAllowedIssuanceModesFields(r, vAllowedIssuanceModes); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAllowedIssuanceModes) { + o.AllowedIssuanceModes = vAllowedIssuanceModes + } + vBaselineValues := o.BaselineValues + if vBaselineValues == nil { + // note: explicitly not the empty object. + vBaselineValues = &CaPoolIssuancePolicyBaselineValues{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesFields(r, vBaselineValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaselineValues) { + o.BaselineValues = vBaselineValues + } + vIdentityConstraints := o.IdentityConstraints + if vIdentityConstraints == nil { + // note: explicitly not the empty object. + vIdentityConstraints = &CaPoolIssuancePolicyIdentityConstraints{} + } + if err := extractCaPoolIssuancePolicyIdentityConstraintsFields(r, vIdentityConstraints); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vIdentityConstraints) { + o.IdentityConstraints = vIdentityConstraints + } + vPassthroughExtensions := o.PassthroughExtensions + if vPassthroughExtensions == nil { + // note: explicitly not the empty object. + vPassthroughExtensions = &CaPoolIssuancePolicyPassthroughExtensions{} + } + if err := extractCaPoolIssuancePolicyPassthroughExtensionsFields(r, vPassthroughExtensions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPassthroughExtensions) { + o.PassthroughExtensions = vPassthroughExtensions + } + return nil +} +func extractCaPoolIssuancePolicyAllowedKeyTypesFields(r *CaPool, o *CaPoolIssuancePolicyAllowedKeyTypes) error { + vRsa := o.Rsa + if vRsa == nil { + // note: explicitly not the empty object. + vRsa = &CaPoolIssuancePolicyAllowedKeyTypesRsa{} + } + if err := extractCaPoolIssuancePolicyAllowedKeyTypesRsaFields(r, vRsa); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRsa) { + o.Rsa = vRsa + } + vEllipticCurve := o.EllipticCurve + if vEllipticCurve == nil { + // note: explicitly not the empty object. + vEllipticCurve = &CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + } + if err := extractCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveFields(r, vEllipticCurve); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vEllipticCurve) { + o.EllipticCurve = vEllipticCurve + } + return nil +} +func extractCaPoolIssuancePolicyAllowedKeyTypesRsaFields(r *CaPool, o *CaPoolIssuancePolicyAllowedKeyTypesRsa) error { + return nil +} +func extractCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveFields(r *CaPool, o *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) error { + return nil +} +func extractCaPoolIssuancePolicyAllowedIssuanceModesFields(r *CaPool, o *CaPoolIssuancePolicyAllowedIssuanceModes) error { + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValues) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsage{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CaPoolIssuancePolicyBaselineValuesCaOptions{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesKeyUsageFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) error { + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) error { + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesCaOptionsFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesCaOptions) error { + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesPolicyIdsFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesPolicyIds) error { + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) error { + return nil +} +func extractCaPoolIssuancePolicyIdentityConstraintsFields(r *CaPool, o *CaPoolIssuancePolicyIdentityConstraints) error { + vCelExpression := o.CelExpression + if vCelExpression == nil { + // note: explicitly not the empty object. + vCelExpression = &CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + } + if err := extractCaPoolIssuancePolicyIdentityConstraintsCelExpressionFields(r, vCelExpression); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCelExpression) { + o.CelExpression = vCelExpression + } + return nil +} +func extractCaPoolIssuancePolicyIdentityConstraintsCelExpressionFields(r *CaPool, o *CaPoolIssuancePolicyIdentityConstraintsCelExpression) error { + return nil +} +func extractCaPoolIssuancePolicyPassthroughExtensionsFields(r *CaPool, o *CaPoolIssuancePolicyPassthroughExtensions) error { + return nil +} +func extractCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsFields(r *CaPool, o *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) error { + return nil +} +func extractCaPoolPublishingOptionsFields(r *CaPool, o *CaPoolPublishingOptions) error { + return nil +} + +func postReadExtractCaPoolFields(r *CaPool) error { + vIssuancePolicy := r.IssuancePolicy + if vIssuancePolicy == nil { + // note: explicitly not the empty object. + vIssuancePolicy = &CaPoolIssuancePolicy{} + } + if err := postReadExtractCaPoolIssuancePolicyFields(r, vIssuancePolicy); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vIssuancePolicy) { + r.IssuancePolicy = vIssuancePolicy + } + vPublishingOptions := r.PublishingOptions + if vPublishingOptions == nil { + // note: explicitly not the empty object. + vPublishingOptions = &CaPoolPublishingOptions{} + } + if err := postReadExtractCaPoolPublishingOptionsFields(r, vPublishingOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublishingOptions) { + r.PublishingOptions = vPublishingOptions + } + return nil +} +func postReadExtractCaPoolIssuancePolicyFields(r *CaPool, o *CaPoolIssuancePolicy) error { + vAllowedIssuanceModes := o.AllowedIssuanceModes + if vAllowedIssuanceModes == nil { + // note: explicitly not the empty object. + vAllowedIssuanceModes = &CaPoolIssuancePolicyAllowedIssuanceModes{} + } + if err := extractCaPoolIssuancePolicyAllowedIssuanceModesFields(r, vAllowedIssuanceModes); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAllowedIssuanceModes) { + o.AllowedIssuanceModes = vAllowedIssuanceModes + } + vBaselineValues := o.BaselineValues + if vBaselineValues == nil { + // note: explicitly not the empty object. + vBaselineValues = &CaPoolIssuancePolicyBaselineValues{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesFields(r, vBaselineValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaselineValues) { + o.BaselineValues = vBaselineValues + } + vIdentityConstraints := o.IdentityConstraints + if vIdentityConstraints == nil { + // note: explicitly not the empty object. + vIdentityConstraints = &CaPoolIssuancePolicyIdentityConstraints{} + } + if err := extractCaPoolIssuancePolicyIdentityConstraintsFields(r, vIdentityConstraints); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vIdentityConstraints) { + o.IdentityConstraints = vIdentityConstraints + } + vPassthroughExtensions := o.PassthroughExtensions + if vPassthroughExtensions == nil { + // note: explicitly not the empty object. + vPassthroughExtensions = &CaPoolIssuancePolicyPassthroughExtensions{} + } + if err := extractCaPoolIssuancePolicyPassthroughExtensionsFields(r, vPassthroughExtensions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPassthroughExtensions) { + o.PassthroughExtensions = vPassthroughExtensions + } + return nil +} +func postReadExtractCaPoolIssuancePolicyAllowedKeyTypesFields(r *CaPool, o *CaPoolIssuancePolicyAllowedKeyTypes) error { + vRsa := o.Rsa + if vRsa == nil { + // note: explicitly not the empty object. + vRsa = &CaPoolIssuancePolicyAllowedKeyTypesRsa{} + } + if err := extractCaPoolIssuancePolicyAllowedKeyTypesRsaFields(r, vRsa); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRsa) { + o.Rsa = vRsa + } + vEllipticCurve := o.EllipticCurve + if vEllipticCurve == nil { + // note: explicitly not the empty object. + vEllipticCurve = &CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve{} + } + if err := extractCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveFields(r, vEllipticCurve); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vEllipticCurve) { + o.EllipticCurve = vEllipticCurve + } + return nil +} +func postReadExtractCaPoolIssuancePolicyAllowedKeyTypesRsaFields(r *CaPool, o *CaPoolIssuancePolicyAllowedKeyTypesRsa) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyAllowedKeyTypesEllipticCurveFields(r *CaPool, o *CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyAllowedIssuanceModesFields(r *CaPool, o *CaPoolIssuancePolicyAllowedIssuanceModes) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValues) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsage{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CaPoolIssuancePolicyBaselineValuesCaOptions{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesKeyUsageFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsageFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsageFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsagesFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesCaOptionsFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesCaOptions) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesPolicyIdsFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesPolicyIds) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId{} + } + if err := extractCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectIdFields(r *CaPool, o *CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyIdentityConstraintsFields(r *CaPool, o *CaPoolIssuancePolicyIdentityConstraints) error { + vCelExpression := o.CelExpression + if vCelExpression == nil { + // note: explicitly not the empty object. + vCelExpression = &CaPoolIssuancePolicyIdentityConstraintsCelExpression{} + } + if err := extractCaPoolIssuancePolicyIdentityConstraintsCelExpressionFields(r, vCelExpression); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCelExpression) { + o.CelExpression = vCelExpression + } + return nil +} +func postReadExtractCaPoolIssuancePolicyIdentityConstraintsCelExpressionFields(r *CaPool, o *CaPoolIssuancePolicyIdentityConstraintsCelExpression) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyPassthroughExtensionsFields(r *CaPool, o *CaPoolIssuancePolicyPassthroughExtensions) error { + return nil +} +func postReadExtractCaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensionsFields(r *CaPool, o *CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions) error { + return nil +} +func postReadExtractCaPoolPublishingOptionsFields(r *CaPool, o *CaPoolPublishingOptions) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_schema.go new file mode 100644 index 00000000000..8309aae6e16 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_schema.go @@ -0,0 +1,629 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLCaPoolSchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "Privateca/CaPool", + Description: "The Privateca CaPool resource", + StructName: "CaPool", + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a CaPool", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "caPool", + Required: true, + Description: "A full instance of a CaPool", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a CaPool", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "caPool", + Required: true, + Description: "A full instance of a CaPool", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a CaPool", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "caPool", + Required: true, + Description: "A full instance of a CaPool", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all CaPool", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many CaPool", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "CaPool": &dcl.Component{ + Title: "CaPool", + ID: "projects/{{project}}/locations/{{location}}/caPools/{{name}}", + ParentContainer: "project", + LabelsField: "labels", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "name", + "tier", + "project", + "location", + }, + Properties: map[string]*dcl.Property{ + "issuancePolicy": &dcl.Property{ + Type: "object", + GoName: "IssuancePolicy", + GoType: "CaPoolIssuancePolicy", + Description: "Optional. The IssuancePolicy to control how Certificates will be issued from this CaPool.", + Properties: map[string]*dcl.Property{ + "allowedIssuanceModes": &dcl.Property{ + Type: "object", + GoName: "AllowedIssuanceModes", + GoType: "CaPoolIssuancePolicyAllowedIssuanceModes", + Description: "Optional. If specified, then only methods allowed in the IssuanceModes may be used to issue Certificates.", + Properties: map[string]*dcl.Property{ + "allowConfigBasedIssuance": &dcl.Property{ + Type: "boolean", + GoName: "AllowConfigBasedIssuance", + Description: "Optional. When true, allows callers to create Certificates by specifying a CertificateConfig.", + }, + "allowCsrBasedIssuance": &dcl.Property{ + Type: "boolean", + GoName: "AllowCsrBasedIssuance", + Description: "Optional. When true, allows callers to create Certificates by specifying a CSR.", + }, + }, + }, + "allowedKeyTypes": &dcl.Property{ + Type: "array", + GoName: "AllowedKeyTypes", + Description: "Optional. If any AllowedKeyType is specified, then the certificate request's public key must match one of the key types listed here. Otherwise, any key may be used.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CaPoolIssuancePolicyAllowedKeyTypes", + Properties: map[string]*dcl.Property{ + "ellipticCurve": &dcl.Property{ + Type: "object", + GoName: "EllipticCurve", + GoType: "CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve", + Description: "Represents an allowed Elliptic Curve key type.", + Conflicts: []string{ + "rsa", + }, + Properties: map[string]*dcl.Property{ + "signatureAlgorithm": &dcl.Property{ + Type: "string", + GoName: "SignatureAlgorithm", + GoType: "CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum", + Description: "Optional. A signature algorithm that must be used. If this is omitted, any EC-based signature algorithm will be allowed. Possible values: EC_SIGNATURE_ALGORITHM_UNSPECIFIED, ECDSA_P256, ECDSA_P384, EDDSA_25519", + Enum: []string{ + "EC_SIGNATURE_ALGORITHM_UNSPECIFIED", + "ECDSA_P256", + "ECDSA_P384", + "EDDSA_25519", + }, + }, + }, + }, + "rsa": &dcl.Property{ + Type: "object", + GoName: "Rsa", + GoType: "CaPoolIssuancePolicyAllowedKeyTypesRsa", + Description: "Represents an allowed RSA key type.", + Conflicts: []string{ + "ellipticCurve", + }, + Properties: map[string]*dcl.Property{ + "maxModulusSize": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxModulusSize", + Description: "Optional. The maximum allowed RSA modulus size, in bits. If this is not set, or if set to zero, the service will not enforce an explicit upper bound on RSA modulus sizes.", + }, + "minModulusSize": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MinModulusSize", + Description: "Optional. The minimum allowed RSA modulus size, in bits. If this is not set, or if set to zero, the service-level min RSA modulus size will continue to apply.", + }, + }, + }, + }, + }, + }, + "baselineValues": &dcl.Property{ + Type: "object", + GoName: "BaselineValues", + GoType: "CaPoolIssuancePolicyBaselineValues", + Description: "Optional. A set of X.509 values that will be applied to all certificates issued through this CaPool. If a certificate request includes conflicting values for the same properties, they will be overwritten by the values defined here. If a certificate request uses a CertificateTemplate that defines conflicting predefined_values for the same properties, the certificate issuance request will fail.", + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. Describes custom X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CaPoolIssuancePolicyBaselineValuesAdditionalExtensions", + Required: []string{ + "objectId", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId", + Description: "Required. The OID for this X.509 extension.", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + }, + }, + }, + }, + "aiaOcspServers": &dcl.Property{ + Type: "array", + GoName: "AiaOcspServers", + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "caOptions": &dcl.Property{ + Type: "object", + GoName: "CaOptions", + GoType: "CaPoolIssuancePolicyBaselineValuesCaOptions", + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + Properties: map[string]*dcl.Property{ + "isCa": &dcl.Property{ + Type: "boolean", + GoName: "IsCa", + Description: "Optional. Refers to the \"CA\" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.", + }, + "maxIssuerPathLength": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxIssuerPathLength", + Description: "Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.", + }, + "zeroMaxIssuerPathLength": &dcl.Property{ + Type: "boolean", + GoName: "ZeroMaxIssuerPathLength", + Description: "Optional. When true, the \"path length constraint\" in Basic Constraints extension will be set to 0. if both max_issuer_path_length and zero_max_issuer_path_length are unset, the max path length will be omitted from the CA certificate.", + }, + }, + }, + "keyUsage": &dcl.Property{ + Type: "object", + GoName: "KeyUsage", + GoType: "CaPoolIssuancePolicyBaselineValuesKeyUsage", + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + Properties: map[string]*dcl.Property{ + "baseKeyUsage": &dcl.Property{ + Type: "object", + GoName: "BaseKeyUsage", + GoType: "CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage", + Description: "Describes high-level ways in which a key may be used.", + Properties: map[string]*dcl.Property{ + "certSign": &dcl.Property{ + Type: "boolean", + GoName: "CertSign", + Description: "The key may be used to sign certificates.", + }, + "contentCommitment": &dcl.Property{ + Type: "boolean", + GoName: "ContentCommitment", + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + }, + "crlSign": &dcl.Property{ + Type: "boolean", + GoName: "CrlSign", + Description: "The key may be used sign certificate revocation lists.", + }, + "dataEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "DataEncipherment", + Description: "The key may be used to encipher data.", + }, + "decipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "DecipherOnly", + Description: "The key may be used to decipher only.", + }, + "digitalSignature": &dcl.Property{ + Type: "boolean", + GoName: "DigitalSignature", + Description: "The key may be used for digital signatures.", + }, + "encipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "EncipherOnly", + Description: "The key may be used to encipher only.", + }, + "keyAgreement": &dcl.Property{ + Type: "boolean", + GoName: "KeyAgreement", + Description: "The key may be used in a key agreement protocol.", + }, + "keyEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "KeyEncipherment", + Description: "The key may be used to encipher other keys.", + }, + }, + }, + "extendedKeyUsage": &dcl.Property{ + Type: "object", + GoName: "ExtendedKeyUsage", + GoType: "CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage", + Description: "Detailed scenarios in which a key may be used.", + Properties: map[string]*dcl.Property{ + "clientAuth": &dcl.Property{ + Type: "boolean", + GoName: "ClientAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + }, + "codeSigning": &dcl.Property{ + Type: "boolean", + GoName: "CodeSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + }, + "emailProtection": &dcl.Property{ + Type: "boolean", + GoName: "EmailProtection", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + }, + "ocspSigning": &dcl.Property{ + Type: "boolean", + GoName: "OcspSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + }, + "serverAuth": &dcl.Property{ + Type: "boolean", + GoName: "ServerAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + }, + "timeStamping": &dcl.Property{ + Type: "boolean", + GoName: "TimeStamping", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + }, + }, + }, + "unknownExtendedKeyUsages": &dcl.Property{ + Type: "array", + GoName: "UnknownExtendedKeyUsages", + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "policyIds": &dcl.Property{ + Type: "array", + GoName: "PolicyIds", + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CaPoolIssuancePolicyBaselineValuesPolicyIds", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "identityConstraints": &dcl.Property{ + Type: "object", + GoName: "IdentityConstraints", + GoType: "CaPoolIssuancePolicyIdentityConstraints", + Description: "Optional. Describes constraints on identities that may appear in Certificates issued through this CaPool. If this is omitted, then this CaPool will not add restrictions on a certificate's identity.", + Required: []string{ + "allowSubjectPassthrough", + "allowSubjectAltNamesPassthrough", + }, + Properties: map[string]*dcl.Property{ + "allowSubjectAltNamesPassthrough": &dcl.Property{ + Type: "boolean", + GoName: "AllowSubjectAltNamesPassthrough", + Description: "Required. If this is true, the SubjectAltNames extension may be copied from a certificate request into the signed certificate. Otherwise, the requested SubjectAltNames will be discarded.", + }, + "allowSubjectPassthrough": &dcl.Property{ + Type: "boolean", + GoName: "AllowSubjectPassthrough", + Description: "Required. If this is true, the Subject field may be copied from a certificate request into the signed certificate. Otherwise, the requested Subject will be discarded.", + }, + "celExpression": &dcl.Property{ + Type: "object", + GoName: "CelExpression", + GoType: "CaPoolIssuancePolicyIdentityConstraintsCelExpression", + Description: "Optional. A CEL expression that may be used to validate the resolved X.509 Subject and/or Subject Alternative Name before a certificate is signed. To see the full allowed syntax and some examples, see https://cloud.google.com/certificate-authority-service/docs/using-cel", + Properties: map[string]*dcl.Property{ + "description": &dcl.Property{ + Type: "string", + GoName: "Description", + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, + "expression": &dcl.Property{ + Type: "string", + GoName: "Expression", + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, + "title": &dcl.Property{ + Type: "string", + GoName: "Title", + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, + }, + }, + }, + "maximumLifetime": &dcl.Property{ + Type: "string", + GoName: "MaximumLifetime", + Description: "Optional. The maximum lifetime allowed for issued Certificates. Note that if the issuing CertificateAuthority expires before a Certificate's requested maximum_lifetime, the effective lifetime will be explicitly truncated to match it.", + }, + "passthroughExtensions": &dcl.Property{ + Type: "object", + GoName: "PassthroughExtensions", + GoType: "CaPoolIssuancePolicyPassthroughExtensions", + Description: "Optional. Describes the set of X.509 extensions that may appear in a Certificate issued through this CaPool. If a certificate request sets extensions that don't appear in the passthrough_extensions, those extensions will be dropped. If a certificate request uses a CertificateTemplate with predefined_values that don't appear here, the certificate issuance request will fail. If this is omitted, then this CaPool will not add restrictions on a certificate's X.509 extensions. These constraints do not apply to X.509 extensions set in this CaPool's baseline_values.", + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. A set of ObjectIds identifying custom X.509 extensions. Will be combined with known_extensions to determine the full set of X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + "knownExtensions": &dcl.Property{ + Type: "array", + GoName: "KnownExtensions", + Description: "Optional. A set of named X.509 extensions. Will be combined with additional_extensions to determine the full set of X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum", + Enum: []string{ + "KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED", + "BASE_KEY_USAGE", + "EXTENDED_KEY_USAGE", + "CA_OPTIONS", + "POLICY_IDS", + "AIA_OCSP_SERVERS", + }, + }, + }, + }, + }, + }, + }, + "labels": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "string", + }, + GoName: "Labels", + Description: "Optional. Labels with user-defined metadata.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "The location for the resource", + Immutable: true, + Parameter: true, + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "The resource name for this CaPool in the format `projects/*/locations/*/caPools/*`.", + Immutable: true, + HasLongForm: true, + }, + "project": &dcl.Property{ + Type: "string", + GoName: "Project", + Description: "The project for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "publishingOptions": &dcl.Property{ + Type: "object", + GoName: "PublishingOptions", + GoType: "CaPoolPublishingOptions", + Description: "Optional. The PublishingOptions to follow when issuing Certificates from any CertificateAuthority in this CaPool.", + Properties: map[string]*dcl.Property{ + "publishCaCert": &dcl.Property{ + Type: "boolean", + GoName: "PublishCaCert", + Description: "Optional. When true, publishes each CertificateAuthority's CA certificate and includes its URL in the \"Authority Information Access\" X.509 extension in all issued Certificates. If this is false, the CA certificate will not be published and the corresponding X.509 extension will not be written in issued certificates.", + }, + "publishCrl": &dcl.Property{ + Type: "boolean", + GoName: "PublishCrl", + Description: "Optional. When true, publishes each CertificateAuthority's CRL and includes its URL in the \"CRL Distribution Points\" X.509 extension in all issued Certificates. If this is false, CRLs will not be published and the corresponding X.509 extension will not be written in issued certificates. CRLs will expire 7 days from their creation. However, we will rebuild daily. CRLs are also rebuilt shortly after a certificate is revoked.", + }, + }, + }, + "tier": &dcl.Property{ + Type: "string", + GoName: "Tier", + GoType: "CaPoolTierEnum", + Description: "Required. Immutable. The Tier of this CaPool. Possible values: TIER_UNSPECIFIED, ENTERPRISE, DEVOPS", + Immutable: true, + Enum: []string{ + "TIER_UNSPECIFIED", + "ENTERPRISE", + "DEVOPS", + }, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_yaml_embed.go new file mode 100644 index 00000000000..d4d9f1db092 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/ca_pool_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package privateca -var YAML_ca_pool blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/ca_pool.yaml + +package privateca + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/ca_pool.yaml +var YAML_ca_pool = []byte("info:\n title: Privateca/CaPool\n description: The Privateca CaPool resource\n x-dcl-struct-name: CaPool\n x-dcl-has-iam: false\npaths:\n get:\n description: The function used to get information about a CaPool\n parameters:\n - name: caPool\n required: true\n description: A full instance of a CaPool\n apply:\n description: The function used to apply information about a CaPool\n parameters:\n - name: caPool\n required: true\n description: A full instance of a CaPool\n delete:\n description: The function used to delete a CaPool\n parameters:\n - name: caPool\n required: true\n description: A full instance of a CaPool\n deleteAll:\n description: The function used to delete all CaPool\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many CaPool\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n CaPool:\n title: CaPool\n x-dcl-id: projects/{{project}}/locations/{{location}}/caPools/{{name}}\n x-dcl-parent-container: project\n x-dcl-labels: labels\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - tier\n - project\n - location\n properties:\n issuancePolicy:\n type: object\n x-dcl-go-name: IssuancePolicy\n x-dcl-go-type: CaPoolIssuancePolicy\n description: Optional. The IssuancePolicy to control how Certificates will\n be issued from this CaPool.\n properties:\n allowedIssuanceModes:\n type: object\n x-dcl-go-name: AllowedIssuanceModes\n x-dcl-go-type: CaPoolIssuancePolicyAllowedIssuanceModes\n description: Optional. If specified, then only methods allowed in the\n IssuanceModes may be used to issue Certificates.\n properties:\n allowConfigBasedIssuance:\n type: boolean\n x-dcl-go-name: AllowConfigBasedIssuance\n description: Optional. When true, allows callers to create Certificates\n by specifying a CertificateConfig.\n allowCsrBasedIssuance:\n type: boolean\n x-dcl-go-name: AllowCsrBasedIssuance\n description: Optional. When true, allows callers to create Certificates\n by specifying a CSR.\n allowedKeyTypes:\n type: array\n x-dcl-go-name: AllowedKeyTypes\n description: Optional. If any AllowedKeyType is specified, then the\n certificate request's public key must match one of the key types listed\n here. Otherwise, any key may be used.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypes\n properties:\n ellipticCurve:\n type: object\n x-dcl-go-name: EllipticCurve\n x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypesEllipticCurve\n description: Represents an allowed Elliptic Curve key type.\n x-dcl-conflicts:\n - rsa\n properties:\n signatureAlgorithm:\n type: string\n x-dcl-go-name: SignatureAlgorithm\n x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypesEllipticCurveSignatureAlgorithmEnum\n description: 'Optional. A signature algorithm that must be\n used. If this is omitted, any EC-based signature algorithm\n will be allowed. Possible values: EC_SIGNATURE_ALGORITHM_UNSPECIFIED,\n ECDSA_P256, ECDSA_P384, EDDSA_25519'\n enum:\n - EC_SIGNATURE_ALGORITHM_UNSPECIFIED\n - ECDSA_P256\n - ECDSA_P384\n - EDDSA_25519\n rsa:\n type: object\n x-dcl-go-name: Rsa\n x-dcl-go-type: CaPoolIssuancePolicyAllowedKeyTypesRsa\n description: Represents an allowed RSA key type.\n x-dcl-conflicts:\n - ellipticCurve\n properties:\n maxModulusSize:\n type: integer\n format: int64\n x-dcl-go-name: MaxModulusSize\n description: Optional. The maximum allowed RSA modulus size,\n in bits. If this is not set, or if set to zero, the service\n will not enforce an explicit upper bound on RSA modulus\n sizes.\n minModulusSize:\n type: integer\n format: int64\n x-dcl-go-name: MinModulusSize\n description: Optional. The minimum allowed RSA modulus size,\n in bits. If this is not set, or if set to zero, the service-level\n min RSA modulus size will continue to apply.\n baselineValues:\n type: object\n x-dcl-go-name: BaselineValues\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValues\n description: Optional. A set of X.509 values that will be applied to\n all certificates issued through this CaPool. If a certificate request\n includes conflicting values for the same properties, they will be\n overwritten by the values defined here. If a certificate request uses\n a CertificateTemplate that defines conflicting predefined_values for\n the same properties, the certificate issuance request will fail.\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. Describes custom X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesAdditionalExtensions\n required:\n - objectId\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to handle\n this extension, the client should consider this to be an\n error).\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesAdditionalExtensionsObjectId\n description: Required. The OID for this X.509 extension.\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n aiaOcspServers:\n type: array\n x-dcl-go-name: AiaOcspServers\n description: Optional. Describes Online Certificate Status Protocol\n (OCSP) endpoint addresses that appear in the \"Authority Information\n Access\" extension in the certificate.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caOptions:\n type: object\n x-dcl-go-name: CaOptions\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesCaOptions\n description: Optional. Describes options in this X509Parameters\n that are relevant in a CA certificate.\n properties:\n isCa:\n type: boolean\n x-dcl-go-name: IsCa\n description: Optional. Refers to the \"CA\" X.509 extension, which\n is a boolean value. When this value is missing, the extension\n will be omitted from the CA certificate.\n maxIssuerPathLength:\n type: integer\n format: int64\n x-dcl-go-name: MaxIssuerPathLength\n description: Optional. Refers to the path length restriction\n X.509 extension. For a CA certificate, this value describes\n the depth of subordinate CA certificates that are allowed.\n If this value is less than 0, the request will fail. If this\n value is missing, the max path length will be omitted from\n the CA certificate.\n zeroMaxIssuerPathLength:\n type: boolean\n x-dcl-go-name: ZeroMaxIssuerPathLength\n description: Optional. When true, the \"path length constraint\"\n in Basic Constraints extension will be set to 0. if both max_issuer_path_length\n and zero_max_issuer_path_length are unset, the max path length\n will be omitted from the CA certificate.\n keyUsage:\n type: object\n x-dcl-go-name: KeyUsage\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsage\n description: Optional. Indicates the intended use for keys that\n correspond to a certificate.\n properties:\n baseKeyUsage:\n type: object\n x-dcl-go-name: BaseKeyUsage\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsageBaseKeyUsage\n description: Describes high-level ways in which a key may be\n used.\n properties:\n certSign:\n type: boolean\n x-dcl-go-name: CertSign\n description: The key may be used to sign certificates.\n contentCommitment:\n type: boolean\n x-dcl-go-name: ContentCommitment\n description: The key may be used for cryptographic commitments.\n Note that this may also be referred to as \"non-repudiation\".\n crlSign:\n type: boolean\n x-dcl-go-name: CrlSign\n description: The key may be used sign certificate revocation\n lists.\n dataEncipherment:\n type: boolean\n x-dcl-go-name: DataEncipherment\n description: The key may be used to encipher data.\n decipherOnly:\n type: boolean\n x-dcl-go-name: DecipherOnly\n description: The key may be used to decipher only.\n digitalSignature:\n type: boolean\n x-dcl-go-name: DigitalSignature\n description: The key may be used for digital signatures.\n encipherOnly:\n type: boolean\n x-dcl-go-name: EncipherOnly\n description: The key may be used to encipher only.\n keyAgreement:\n type: boolean\n x-dcl-go-name: KeyAgreement\n description: The key may be used in a key agreement protocol.\n keyEncipherment:\n type: boolean\n x-dcl-go-name: KeyEncipherment\n description: The key may be used to encipher other keys.\n extendedKeyUsage:\n type: object\n x-dcl-go-name: ExtendedKeyUsage\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsageExtendedKeyUsage\n description: Detailed scenarios in which a key may be used.\n properties:\n clientAuth:\n type: boolean\n x-dcl-go-name: ClientAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially\n described as \"TLS WWW client authentication\", though regularly\n used for non-WWW TLS.\n codeSigning:\n type: boolean\n x-dcl-go-name: CodeSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially\n described as \"Signing of downloadable executable code\n client authentication\".\n emailProtection:\n type: boolean\n x-dcl-go-name: EmailProtection\n description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially\n described as \"Email protection\".\n ocspSigning:\n type: boolean\n x-dcl-go-name: OcspSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially\n described as \"Signing OCSP responses\".\n serverAuth:\n type: boolean\n x-dcl-go-name: ServerAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially\n described as \"TLS WWW server authentication\", though regularly\n used for non-WWW TLS.\n timeStamping:\n type: boolean\n x-dcl-go-name: TimeStamping\n description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially\n described as \"Binding the hash of an object to a time\".\n unknownExtendedKeyUsages:\n type: array\n x-dcl-go-name: UnknownExtendedKeyUsages\n description: Used to describe extended key usages that are not\n listed in the KeyUsage.ExtendedKeyUsageOptions message.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesKeyUsageUnknownExtendedKeyUsages\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n policyIds:\n type: array\n x-dcl-go-name: PolicyIds\n description: Optional. Describes the X.509 certificate policy object\n identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CaPoolIssuancePolicyBaselineValuesPolicyIds\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n identityConstraints:\n type: object\n x-dcl-go-name: IdentityConstraints\n x-dcl-go-type: CaPoolIssuancePolicyIdentityConstraints\n description: Optional. Describes constraints on identities that may\n appear in Certificates issued through this CaPool. If this is omitted,\n then this CaPool will not add restrictions on a certificate's identity.\n required:\n - allowSubjectPassthrough\n - allowSubjectAltNamesPassthrough\n properties:\n allowSubjectAltNamesPassthrough:\n type: boolean\n x-dcl-go-name: AllowSubjectAltNamesPassthrough\n description: Required. If this is true, the SubjectAltNames extension\n may be copied from a certificate request into the signed certificate.\n Otherwise, the requested SubjectAltNames will be discarded.\n allowSubjectPassthrough:\n type: boolean\n x-dcl-go-name: AllowSubjectPassthrough\n description: Required. If this is true, the Subject field may be\n copied from a certificate request into the signed certificate.\n Otherwise, the requested Subject will be discarded.\n celExpression:\n type: object\n x-dcl-go-name: CelExpression\n x-dcl-go-type: CaPoolIssuancePolicyIdentityConstraintsCelExpression\n description: Optional. A CEL expression that may be used to validate\n the resolved X.509 Subject and/or Subject Alternative Name before\n a certificate is signed. To see the full allowed syntax and some\n examples, see https://cloud.google.com/certificate-authority-service/docs/using-cel\n properties:\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the expression. This is\n a longer text which describes the expression, e.g. when hovered\n over it in a UI.\n expression:\n type: string\n x-dcl-go-name: Expression\n description: Textual representation of an expression in Common\n Expression Language syntax.\n location:\n type: string\n x-dcl-go-name: Location\n description: Optional. String indicating the location of the\n expression for error reporting, e.g. a file name and a position\n in the file.\n title:\n type: string\n x-dcl-go-name: Title\n description: Optional. Title for the expression, i.e. a short\n string describing its purpose. This can be used e.g. in UIs\n which allow to enter the expression.\n maximumLifetime:\n type: string\n x-dcl-go-name: MaximumLifetime\n description: Optional. The maximum lifetime allowed for issued Certificates.\n Note that if the issuing CertificateAuthority expires before a Certificate's\n requested maximum_lifetime, the effective lifetime will be explicitly\n truncated to match it.\n passthroughExtensions:\n type: object\n x-dcl-go-name: PassthroughExtensions\n x-dcl-go-type: CaPoolIssuancePolicyPassthroughExtensions\n description: Optional. Describes the set of X.509 extensions that may\n appear in a Certificate issued through this CaPool. If a certificate\n request sets extensions that don't appear in the passthrough_extensions,\n those extensions will be dropped. If a certificate request uses a\n CertificateTemplate with predefined_values that don't appear here,\n the certificate issuance request will fail. If this is omitted, then\n this CaPool will not add restrictions on a certificate's X.509 extensions.\n These constraints do not apply to X.509 extensions set in this CaPool's\n baseline_values.\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. A set of ObjectIds identifying custom X.509\n extensions. Will be combined with known_extensions to determine\n the full set of X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CaPoolIssuancePolicyPassthroughExtensionsAdditionalExtensions\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n knownExtensions:\n type: array\n x-dcl-go-name: KnownExtensions\n description: Optional. A set of named X.509 extensions. Will be\n combined with additional_extensions to determine the full set\n of X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: CaPoolIssuancePolicyPassthroughExtensionsKnownExtensionsEnum\n enum:\n - KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED\n - BASE_KEY_USAGE\n - EXTENDED_KEY_USAGE\n - CA_OPTIONS\n - POLICY_IDS\n - AIA_OCSP_SERVERS\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: Optional. Labels with user-defined metadata.\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: The resource name for this CaPool in the format `projects/*/locations/*/caPools/*`.\n x-kubernetes-immutable: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n publishingOptions:\n type: object\n x-dcl-go-name: PublishingOptions\n x-dcl-go-type: CaPoolPublishingOptions\n description: Optional. The PublishingOptions to follow when issuing Certificates\n from any CertificateAuthority in this CaPool.\n properties:\n publishCaCert:\n type: boolean\n x-dcl-go-name: PublishCaCert\n description: Optional. When true, publishes each CertificateAuthority's\n CA certificate and includes its URL in the \"Authority Information\n Access\" X.509 extension in all issued Certificates. If this is false,\n the CA certificate will not be published and the corresponding X.509\n extension will not be written in issued certificates.\n publishCrl:\n type: boolean\n x-dcl-go-name: PublishCrl\n description: Optional. When true, publishes each CertificateAuthority's\n CRL and includes its URL in the \"CRL Distribution Points\" X.509 extension\n in all issued Certificates. If this is false, CRLs will not be published\n and the corresponding X.509 extension will not be written in issued\n certificates. CRLs will expire 7 days from their creation. However,\n we will rebuild daily. CRLs are also rebuilt shortly after a certificate\n is revoked.\n tier:\n type: string\n x-dcl-go-name: Tier\n x-dcl-go-type: CaPoolTierEnum\n description: 'Required. Immutable. The Tier of this CaPool. Possible values:\n TIER_UNSPECIFIED, ENTERPRISE, DEVOPS'\n x-kubernetes-immutable: true\n enum:\n - TIER_UNSPECIFIED\n - ENTERPRISE\n - DEVOPS\n") + +// 27569 bytes +// MD5: 3a662d926a2c95a9b0c73399b01f20a4 diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate.go new file mode 100644 index 00000000000..916dce5d7eb --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate.go @@ -0,0 +1,2332 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type Certificate struct { + Name *string `json:"name"` + PemCsr *string `json:"pemCsr"` + Config *CertificateConfig `json:"config"` + IssuerCertificateAuthority *string `json:"issuerCertificateAuthority"` + Lifetime *string `json:"lifetime"` + CertificateTemplate *string `json:"certificateTemplate"` + SubjectMode *CertificateSubjectModeEnum `json:"subjectMode"` + RevocationDetails *CertificateRevocationDetails `json:"revocationDetails"` + PemCertificate *string `json:"pemCertificate"` + CertificateDescription *CertificateCertificateDescription `json:"certificateDescription"` + PemCertificateChain []string `json:"pemCertificateChain"` + CreateTime *string `json:"createTime"` + UpdateTime *string `json:"updateTime"` + Labels map[string]string `json:"labels"` + Project *string `json:"project"` + Location *string `json:"location"` + CaPool *string `json:"caPool"` + CertificateAuthority *string `json:"certificateAuthority"` +} + +func (r *Certificate) String() string { + return dcl.SprintResource(r) +} + +// The enum CertificateConfigPublicKeyFormatEnum. +type CertificateConfigPublicKeyFormatEnum string + +// CertificateConfigPublicKeyFormatEnumRef returns a *CertificateConfigPublicKeyFormatEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateConfigPublicKeyFormatEnumRef(s string) *CertificateConfigPublicKeyFormatEnum { + v := CertificateConfigPublicKeyFormatEnum(s) + return &v +} + +func (v CertificateConfigPublicKeyFormatEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"KEY_FORMAT_UNSPECIFIED", "PEM"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateConfigPublicKeyFormatEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateSubjectModeEnum. +type CertificateSubjectModeEnum string + +// CertificateSubjectModeEnumRef returns a *CertificateSubjectModeEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateSubjectModeEnumRef(s string) *CertificateSubjectModeEnum { + v := CertificateSubjectModeEnum(s) + return &v +} + +func (v CertificateSubjectModeEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"SUBJECT_REQUEST_MODE_UNSPECIFIED", "DEFAULT", "REFLECTED_SPIFFE"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateSubjectModeEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateRevocationDetailsRevocationStateEnum. +type CertificateRevocationDetailsRevocationStateEnum string + +// CertificateRevocationDetailsRevocationStateEnumRef returns a *CertificateRevocationDetailsRevocationStateEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateRevocationDetailsRevocationStateEnumRef(s string) *CertificateRevocationDetailsRevocationStateEnum { + v := CertificateRevocationDetailsRevocationStateEnum(s) + return &v +} + +func (v CertificateRevocationDetailsRevocationStateEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"REVOCATION_REASON_UNSPECIFIED", "KEY_COMPROMISE", "CERTIFICATE_AUTHORITY_COMPROMISE", "AFFILIATION_CHANGED", "SUPERSEDED", "CESSATION_OF_OPERATION", "CERTIFICATE_HOLD", "PRIVILEGE_WITHDRAWN", "ATTRIBUTE_AUTHORITY_COMPROMISE"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateRevocationDetailsRevocationStateEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateCertificateDescriptionPublicKeyFormatEnum. +type CertificateCertificateDescriptionPublicKeyFormatEnum string + +// CertificateCertificateDescriptionPublicKeyFormatEnumRef returns a *CertificateCertificateDescriptionPublicKeyFormatEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateCertificateDescriptionPublicKeyFormatEnumRef(s string) *CertificateCertificateDescriptionPublicKeyFormatEnum { + v := CertificateCertificateDescriptionPublicKeyFormatEnum(s) + return &v +} + +func (v CertificateCertificateDescriptionPublicKeyFormatEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"KEY_FORMAT_UNSPECIFIED", "PEM"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateCertificateDescriptionPublicKeyFormatEnum", + Value: string(v), + Valid: []string{}, + } +} + +type CertificateConfig struct { + empty bool `json:"-"` + SubjectConfig *CertificateConfigSubjectConfig `json:"subjectConfig"` + X509Config *CertificateConfigX509Config `json:"x509Config"` + PublicKey *CertificateConfigPublicKey `json:"publicKey"` +} + +type jsonCertificateConfig CertificateConfig + +func (r *CertificateConfig) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfig + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfig + } else { + + r.SubjectConfig = res.SubjectConfig + + r.X509Config = res.X509Config + + r.PublicKey = res.PublicKey + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfig is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfig *CertificateConfig = &CertificateConfig{empty: true} + +func (r *CertificateConfig) Empty() bool { + return r.empty +} + +func (r *CertificateConfig) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfig) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigSubjectConfig struct { + empty bool `json:"-"` + Subject *CertificateConfigSubjectConfigSubject `json:"subject"` + SubjectAltName *CertificateConfigSubjectConfigSubjectAltName `json:"subjectAltName"` +} + +type jsonCertificateConfigSubjectConfig CertificateConfigSubjectConfig + +func (r *CertificateConfigSubjectConfig) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigSubjectConfig + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigSubjectConfig + } else { + + r.Subject = res.Subject + + r.SubjectAltName = res.SubjectAltName + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigSubjectConfig is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigSubjectConfig *CertificateConfigSubjectConfig = &CertificateConfigSubjectConfig{empty: true} + +func (r *CertificateConfigSubjectConfig) Empty() bool { + return r.empty +} + +func (r *CertificateConfigSubjectConfig) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigSubjectConfig) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigSubjectConfigSubject struct { + empty bool `json:"-"` + CommonName *string `json:"commonName"` + CountryCode *string `json:"countryCode"` + Organization *string `json:"organization"` + OrganizationalUnit *string `json:"organizationalUnit"` + Locality *string `json:"locality"` + Province *string `json:"province"` + StreetAddress *string `json:"streetAddress"` + PostalCode *string `json:"postalCode"` +} + +type jsonCertificateConfigSubjectConfigSubject CertificateConfigSubjectConfigSubject + +func (r *CertificateConfigSubjectConfigSubject) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigSubjectConfigSubject + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigSubjectConfigSubject + } else { + + r.CommonName = res.CommonName + + r.CountryCode = res.CountryCode + + r.Organization = res.Organization + + r.OrganizationalUnit = res.OrganizationalUnit + + r.Locality = res.Locality + + r.Province = res.Province + + r.StreetAddress = res.StreetAddress + + r.PostalCode = res.PostalCode + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigSubjectConfigSubject is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigSubjectConfigSubject *CertificateConfigSubjectConfigSubject = &CertificateConfigSubjectConfigSubject{empty: true} + +func (r *CertificateConfigSubjectConfigSubject) Empty() bool { + return r.empty +} + +func (r *CertificateConfigSubjectConfigSubject) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigSubjectConfigSubject) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigSubjectConfigSubjectAltName struct { + empty bool `json:"-"` + DnsNames []string `json:"dnsNames"` + Uris []string `json:"uris"` + EmailAddresses []string `json:"emailAddresses"` + IPAddresses []string `json:"ipAddresses"` +} + +type jsonCertificateConfigSubjectConfigSubjectAltName CertificateConfigSubjectConfigSubjectAltName + +func (r *CertificateConfigSubjectConfigSubjectAltName) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigSubjectConfigSubjectAltName + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigSubjectConfigSubjectAltName + } else { + + r.DnsNames = res.DnsNames + + r.Uris = res.Uris + + r.EmailAddresses = res.EmailAddresses + + r.IPAddresses = res.IPAddresses + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigSubjectConfigSubjectAltName is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigSubjectConfigSubjectAltName *CertificateConfigSubjectConfigSubjectAltName = &CertificateConfigSubjectConfigSubjectAltName{empty: true} + +func (r *CertificateConfigSubjectConfigSubjectAltName) Empty() bool { + return r.empty +} + +func (r *CertificateConfigSubjectConfigSubjectAltName) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigSubjectConfigSubjectAltName) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509Config struct { + empty bool `json:"-"` + KeyUsage *CertificateConfigX509ConfigKeyUsage `json:"keyUsage"` + CaOptions *CertificateConfigX509ConfigCaOptions `json:"caOptions"` + PolicyIds []CertificateConfigX509ConfigPolicyIds `json:"policyIds"` + AiaOcspServers []string `json:"aiaOcspServers"` + AdditionalExtensions []CertificateConfigX509ConfigAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCertificateConfigX509Config CertificateConfigX509Config + +func (r *CertificateConfigX509Config) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509Config + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509Config + } else { + + r.KeyUsage = res.KeyUsage + + r.CaOptions = res.CaOptions + + r.PolicyIds = res.PolicyIds + + r.AiaOcspServers = res.AiaOcspServers + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509Config is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509Config *CertificateConfigX509Config = &CertificateConfigX509Config{empty: true} + +func (r *CertificateConfigX509Config) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509Config) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509Config) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigKeyUsage struct { + empty bool `json:"-"` + BaseKeyUsage *CertificateConfigX509ConfigKeyUsageBaseKeyUsage `json:"baseKeyUsage"` + ExtendedKeyUsage *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage `json:"extendedKeyUsage"` + UnknownExtendedKeyUsages []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages `json:"unknownExtendedKeyUsages"` +} + +type jsonCertificateConfigX509ConfigKeyUsage CertificateConfigX509ConfigKeyUsage + +func (r *CertificateConfigX509ConfigKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigKeyUsage + } else { + + r.BaseKeyUsage = res.BaseKeyUsage + + r.ExtendedKeyUsage = res.ExtendedKeyUsage + + r.UnknownExtendedKeyUsages = res.UnknownExtendedKeyUsages + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigKeyUsage *CertificateConfigX509ConfigKeyUsage = &CertificateConfigX509ConfigKeyUsage{empty: true} + +func (r *CertificateConfigX509ConfigKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigKeyUsageBaseKeyUsage struct { + empty bool `json:"-"` + DigitalSignature *bool `json:"digitalSignature"` + ContentCommitment *bool `json:"contentCommitment"` + KeyEncipherment *bool `json:"keyEncipherment"` + DataEncipherment *bool `json:"dataEncipherment"` + KeyAgreement *bool `json:"keyAgreement"` + CertSign *bool `json:"certSign"` + CrlSign *bool `json:"crlSign"` + EncipherOnly *bool `json:"encipherOnly"` + DecipherOnly *bool `json:"decipherOnly"` +} + +type jsonCertificateConfigX509ConfigKeyUsageBaseKeyUsage CertificateConfigX509ConfigKeyUsageBaseKeyUsage + +func (r *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigKeyUsageBaseKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigKeyUsageBaseKeyUsage + } else { + + r.DigitalSignature = res.DigitalSignature + + r.ContentCommitment = res.ContentCommitment + + r.KeyEncipherment = res.KeyEncipherment + + r.DataEncipherment = res.DataEncipherment + + r.KeyAgreement = res.KeyAgreement + + r.CertSign = res.CertSign + + r.CrlSign = res.CrlSign + + r.EncipherOnly = res.EncipherOnly + + r.DecipherOnly = res.DecipherOnly + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigKeyUsageBaseKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigKeyUsageBaseKeyUsage *CertificateConfigX509ConfigKeyUsageBaseKeyUsage = &CertificateConfigX509ConfigKeyUsageBaseKeyUsage{empty: true} + +func (r *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigKeyUsageExtendedKeyUsage struct { + empty bool `json:"-"` + ServerAuth *bool `json:"serverAuth"` + ClientAuth *bool `json:"clientAuth"` + CodeSigning *bool `json:"codeSigning"` + EmailProtection *bool `json:"emailProtection"` + TimeStamping *bool `json:"timeStamping"` + OcspSigning *bool `json:"ocspSigning"` +} + +type jsonCertificateConfigX509ConfigKeyUsageExtendedKeyUsage CertificateConfigX509ConfigKeyUsageExtendedKeyUsage + +func (r *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigKeyUsageExtendedKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigKeyUsageExtendedKeyUsage + } else { + + r.ServerAuth = res.ServerAuth + + r.ClientAuth = res.ClientAuth + + r.CodeSigning = res.CodeSigning + + r.EmailProtection = res.EmailProtection + + r.TimeStamping = res.TimeStamping + + r.OcspSigning = res.OcspSigning + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigKeyUsageExtendedKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigKeyUsageExtendedKeyUsage *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage = &CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{empty: true} + +func (r *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + +func (r *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages = &CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{empty: true} + +func (r *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigCaOptions struct { + empty bool `json:"-"` + IsCa *bool `json:"isCa"` + NonCa *bool `json:"nonCa"` + MaxIssuerPathLength *int64 `json:"maxIssuerPathLength"` + ZeroMaxIssuerPathLength *bool `json:"zeroMaxIssuerPathLength"` +} + +type jsonCertificateConfigX509ConfigCaOptions CertificateConfigX509ConfigCaOptions + +func (r *CertificateConfigX509ConfigCaOptions) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigCaOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigCaOptions + } else { + + r.IsCa = res.IsCa + + r.NonCa = res.NonCa + + r.MaxIssuerPathLength = res.MaxIssuerPathLength + + r.ZeroMaxIssuerPathLength = res.ZeroMaxIssuerPathLength + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigCaOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigCaOptions *CertificateConfigX509ConfigCaOptions = &CertificateConfigX509ConfigCaOptions{empty: true} + +func (r *CertificateConfigX509ConfigCaOptions) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigCaOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigCaOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigPolicyIds struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateConfigX509ConfigPolicyIds CertificateConfigX509ConfigPolicyIds + +func (r *CertificateConfigX509ConfigPolicyIds) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigPolicyIds + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigPolicyIds + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigPolicyIds is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigPolicyIds *CertificateConfigX509ConfigPolicyIds = &CertificateConfigX509ConfigPolicyIds{empty: true} + +func (r *CertificateConfigX509ConfigPolicyIds) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigPolicyIds) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigPolicyIds) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigAdditionalExtensions struct { + empty bool `json:"-"` + ObjectId *CertificateConfigX509ConfigAdditionalExtensionsObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateConfigX509ConfigAdditionalExtensions CertificateConfigX509ConfigAdditionalExtensions + +func (r *CertificateConfigX509ConfigAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigAdditionalExtensions + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigAdditionalExtensions *CertificateConfigX509ConfigAdditionalExtensions = &CertificateConfigX509ConfigAdditionalExtensions{empty: true} + +func (r *CertificateConfigX509ConfigAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigX509ConfigAdditionalExtensionsObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateConfigX509ConfigAdditionalExtensionsObjectId CertificateConfigX509ConfigAdditionalExtensionsObjectId + +func (r *CertificateConfigX509ConfigAdditionalExtensionsObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigX509ConfigAdditionalExtensionsObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigX509ConfigAdditionalExtensionsObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigX509ConfigAdditionalExtensionsObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigX509ConfigAdditionalExtensionsObjectId *CertificateConfigX509ConfigAdditionalExtensionsObjectId = &CertificateConfigX509ConfigAdditionalExtensionsObjectId{empty: true} + +func (r *CertificateConfigX509ConfigAdditionalExtensionsObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateConfigX509ConfigAdditionalExtensionsObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigX509ConfigAdditionalExtensionsObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateConfigPublicKey struct { + empty bool `json:"-"` + Key *string `json:"key"` + Format *CertificateConfigPublicKeyFormatEnum `json:"format"` +} + +type jsonCertificateConfigPublicKey CertificateConfigPublicKey + +func (r *CertificateConfigPublicKey) UnmarshalJSON(data []byte) error { + var res jsonCertificateConfigPublicKey + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateConfigPublicKey + } else { + + r.Key = res.Key + + r.Format = res.Format + + } + return nil +} + +// This object is used to assert a desired state where this CertificateConfigPublicKey is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateConfigPublicKey *CertificateConfigPublicKey = &CertificateConfigPublicKey{empty: true} + +func (r *CertificateConfigPublicKey) Empty() bool { + return r.empty +} + +func (r *CertificateConfigPublicKey) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateConfigPublicKey) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateRevocationDetails struct { + empty bool `json:"-"` + RevocationState *CertificateRevocationDetailsRevocationStateEnum `json:"revocationState"` + RevocationTime *string `json:"revocationTime"` +} + +type jsonCertificateRevocationDetails CertificateRevocationDetails + +func (r *CertificateRevocationDetails) UnmarshalJSON(data []byte) error { + var res jsonCertificateRevocationDetails + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateRevocationDetails + } else { + + r.RevocationState = res.RevocationState + + r.RevocationTime = res.RevocationTime + + } + return nil +} + +// This object is used to assert a desired state where this CertificateRevocationDetails is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateRevocationDetails *CertificateRevocationDetails = &CertificateRevocationDetails{empty: true} + +func (r *CertificateRevocationDetails) Empty() bool { + return r.empty +} + +func (r *CertificateRevocationDetails) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateRevocationDetails) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescription struct { + empty bool `json:"-"` + SubjectDescription *CertificateCertificateDescriptionSubjectDescription `json:"subjectDescription"` + X509Description *CertificateCertificateDescriptionX509Description `json:"x509Description"` + PublicKey *CertificateCertificateDescriptionPublicKey `json:"publicKey"` + SubjectKeyId *CertificateCertificateDescriptionSubjectKeyId `json:"subjectKeyId"` + AuthorityKeyId *CertificateCertificateDescriptionAuthorityKeyId `json:"authorityKeyId"` + CrlDistributionPoints []string `json:"crlDistributionPoints"` + AiaIssuingCertificateUrls []string `json:"aiaIssuingCertificateUrls"` + CertFingerprint *CertificateCertificateDescriptionCertFingerprint `json:"certFingerprint"` +} + +type jsonCertificateCertificateDescription CertificateCertificateDescription + +func (r *CertificateCertificateDescription) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescription + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescription + } else { + + r.SubjectDescription = res.SubjectDescription + + r.X509Description = res.X509Description + + r.PublicKey = res.PublicKey + + r.SubjectKeyId = res.SubjectKeyId + + r.AuthorityKeyId = res.AuthorityKeyId + + r.CrlDistributionPoints = res.CrlDistributionPoints + + r.AiaIssuingCertificateUrls = res.AiaIssuingCertificateUrls + + r.CertFingerprint = res.CertFingerprint + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescription is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescription *CertificateCertificateDescription = &CertificateCertificateDescription{empty: true} + +func (r *CertificateCertificateDescription) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescription) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescription) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionSubjectDescription struct { + empty bool `json:"-"` + Subject *CertificateCertificateDescriptionSubjectDescriptionSubject `json:"subject"` + SubjectAltName *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName `json:"subjectAltName"` + HexSerialNumber *string `json:"hexSerialNumber"` + Lifetime *string `json:"lifetime"` + NotBeforeTime *string `json:"notBeforeTime"` + NotAfterTime *string `json:"notAfterTime"` +} + +type jsonCertificateCertificateDescriptionSubjectDescription CertificateCertificateDescriptionSubjectDescription + +func (r *CertificateCertificateDescriptionSubjectDescription) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionSubjectDescription + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionSubjectDescription + } else { + + r.Subject = res.Subject + + r.SubjectAltName = res.SubjectAltName + + r.HexSerialNumber = res.HexSerialNumber + + r.Lifetime = res.Lifetime + + r.NotBeforeTime = res.NotBeforeTime + + r.NotAfterTime = res.NotAfterTime + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionSubjectDescription is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionSubjectDescription *CertificateCertificateDescriptionSubjectDescription = &CertificateCertificateDescriptionSubjectDescription{empty: true} + +func (r *CertificateCertificateDescriptionSubjectDescription) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionSubjectDescription) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionSubjectDescription) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionSubjectDescriptionSubject struct { + empty bool `json:"-"` + CommonName *string `json:"commonName"` + CountryCode *string `json:"countryCode"` + Organization *string `json:"organization"` + OrganizationalUnit *string `json:"organizationalUnit"` + Locality *string `json:"locality"` + Province *string `json:"province"` + StreetAddress *string `json:"streetAddress"` + PostalCode *string `json:"postalCode"` +} + +type jsonCertificateCertificateDescriptionSubjectDescriptionSubject CertificateCertificateDescriptionSubjectDescriptionSubject + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubject) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionSubjectDescriptionSubject + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionSubjectDescriptionSubject + } else { + + r.CommonName = res.CommonName + + r.CountryCode = res.CountryCode + + r.Organization = res.Organization + + r.OrganizationalUnit = res.OrganizationalUnit + + r.Locality = res.Locality + + r.Province = res.Province + + r.StreetAddress = res.StreetAddress + + r.PostalCode = res.PostalCode + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionSubjectDescriptionSubject is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionSubjectDescriptionSubject *CertificateCertificateDescriptionSubjectDescriptionSubject = &CertificateCertificateDescriptionSubjectDescriptionSubject{empty: true} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubject) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubject) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubject) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionSubjectDescriptionSubjectAltName struct { + empty bool `json:"-"` + DnsNames []string `json:"dnsNames"` + Uris []string `json:"uris"` + EmailAddresses []string `json:"emailAddresses"` + IPAddresses []string `json:"ipAddresses"` + CustomSans []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans `json:"customSans"` +} + +type jsonCertificateCertificateDescriptionSubjectDescriptionSubjectAltName CertificateCertificateDescriptionSubjectDescriptionSubjectAltName + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionSubjectDescriptionSubjectAltName + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltName + } else { + + r.DnsNames = res.DnsNames + + r.Uris = res.Uris + + r.EmailAddresses = res.EmailAddresses + + r.IPAddresses = res.IPAddresses + + r.CustomSans = res.CustomSans + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionSubjectDescriptionSubjectAltName is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltName *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{empty: true} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans struct { + empty bool `json:"-"` + ObjectId *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{empty: true} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{empty: true} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509Description struct { + empty bool `json:"-"` + KeyUsage *CertificateCertificateDescriptionX509DescriptionKeyUsage `json:"keyUsage"` + CaOptions *CertificateCertificateDescriptionX509DescriptionCaOptions `json:"caOptions"` + PolicyIds []CertificateCertificateDescriptionX509DescriptionPolicyIds `json:"policyIds"` + AiaOcspServers []string `json:"aiaOcspServers"` + AdditionalExtensions []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCertificateCertificateDescriptionX509Description CertificateCertificateDescriptionX509Description + +func (r *CertificateCertificateDescriptionX509Description) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509Description + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509Description + } else { + + r.KeyUsage = res.KeyUsage + + r.CaOptions = res.CaOptions + + r.PolicyIds = res.PolicyIds + + r.AiaOcspServers = res.AiaOcspServers + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509Description is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509Description *CertificateCertificateDescriptionX509Description = &CertificateCertificateDescriptionX509Description{empty: true} + +func (r *CertificateCertificateDescriptionX509Description) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509Description) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509Description) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionKeyUsage struct { + empty bool `json:"-"` + BaseKeyUsage *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage `json:"baseKeyUsage"` + ExtendedKeyUsage *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage `json:"extendedKeyUsage"` + UnknownExtendedKeyUsages []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages `json:"unknownExtendedKeyUsages"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionKeyUsage CertificateCertificateDescriptionX509DescriptionKeyUsage + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionKeyUsage + } else { + + r.BaseKeyUsage = res.BaseKeyUsage + + r.ExtendedKeyUsage = res.ExtendedKeyUsage + + r.UnknownExtendedKeyUsages = res.UnknownExtendedKeyUsages + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionKeyUsage *CertificateCertificateDescriptionX509DescriptionKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsage{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage struct { + empty bool `json:"-"` + DigitalSignature *bool `json:"digitalSignature"` + ContentCommitment *bool `json:"contentCommitment"` + KeyEncipherment *bool `json:"keyEncipherment"` + DataEncipherment *bool `json:"dataEncipherment"` + KeyAgreement *bool `json:"keyAgreement"` + CertSign *bool `json:"certSign"` + CrlSign *bool `json:"crlSign"` + EncipherOnly *bool `json:"encipherOnly"` + DecipherOnly *bool `json:"decipherOnly"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + } else { + + r.DigitalSignature = res.DigitalSignature + + r.ContentCommitment = res.ContentCommitment + + r.KeyEncipherment = res.KeyEncipherment + + r.DataEncipherment = res.DataEncipherment + + r.KeyAgreement = res.KeyAgreement + + r.CertSign = res.CertSign + + r.CrlSign = res.CrlSign + + r.EncipherOnly = res.EncipherOnly + + r.DecipherOnly = res.DecipherOnly + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage struct { + empty bool `json:"-"` + ServerAuth *bool `json:"serverAuth"` + ClientAuth *bool `json:"clientAuth"` + CodeSigning *bool `json:"codeSigning"` + EmailProtection *bool `json:"emailProtection"` + TimeStamping *bool `json:"timeStamping"` + OcspSigning *bool `json:"ocspSigning"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + } else { + + r.ServerAuth = res.ServerAuth + + r.ClientAuth = res.ClientAuth + + r.CodeSigning = res.CodeSigning + + r.EmailProtection = res.EmailProtection + + r.TimeStamping = res.TimeStamping + + r.OcspSigning = res.OcspSigning + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages = &CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionCaOptions struct { + empty bool `json:"-"` + IsCa *bool `json:"isCa"` + MaxIssuerPathLength *int64 `json:"maxIssuerPathLength"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionCaOptions CertificateCertificateDescriptionX509DescriptionCaOptions + +func (r *CertificateCertificateDescriptionX509DescriptionCaOptions) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionCaOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionCaOptions + } else { + + r.IsCa = res.IsCa + + r.MaxIssuerPathLength = res.MaxIssuerPathLength + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionCaOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionCaOptions *CertificateCertificateDescriptionX509DescriptionCaOptions = &CertificateCertificateDescriptionX509DescriptionCaOptions{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionCaOptions) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionCaOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionCaOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionPolicyIds struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionPolicyIds CertificateCertificateDescriptionX509DescriptionPolicyIds + +func (r *CertificateCertificateDescriptionX509DescriptionPolicyIds) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionPolicyIds + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionPolicyIds + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionPolicyIds is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionPolicyIds *CertificateCertificateDescriptionX509DescriptionPolicyIds = &CertificateCertificateDescriptionX509DescriptionPolicyIds{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionPolicyIds) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionPolicyIds) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionPolicyIds) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionAdditionalExtensions struct { + empty bool `json:"-"` + ObjectId *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionAdditionalExtensions CertificateCertificateDescriptionX509DescriptionAdditionalExtensions + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensions + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensions *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions = &CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId = &CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{empty: true} + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionPublicKey struct { + empty bool `json:"-"` + Key *string `json:"key"` + Format *CertificateCertificateDescriptionPublicKeyFormatEnum `json:"format"` +} + +type jsonCertificateCertificateDescriptionPublicKey CertificateCertificateDescriptionPublicKey + +func (r *CertificateCertificateDescriptionPublicKey) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionPublicKey + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionPublicKey + } else { + + r.Key = res.Key + + r.Format = res.Format + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionPublicKey is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionPublicKey *CertificateCertificateDescriptionPublicKey = &CertificateCertificateDescriptionPublicKey{empty: true} + +func (r *CertificateCertificateDescriptionPublicKey) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionPublicKey) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionPublicKey) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionSubjectKeyId struct { + empty bool `json:"-"` + KeyId *string `json:"keyId"` +} + +type jsonCertificateCertificateDescriptionSubjectKeyId CertificateCertificateDescriptionSubjectKeyId + +func (r *CertificateCertificateDescriptionSubjectKeyId) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionSubjectKeyId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionSubjectKeyId + } else { + + r.KeyId = res.KeyId + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionSubjectKeyId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionSubjectKeyId *CertificateCertificateDescriptionSubjectKeyId = &CertificateCertificateDescriptionSubjectKeyId{empty: true} + +func (r *CertificateCertificateDescriptionSubjectKeyId) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionSubjectKeyId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionSubjectKeyId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionAuthorityKeyId struct { + empty bool `json:"-"` + KeyId *string `json:"keyId"` +} + +type jsonCertificateCertificateDescriptionAuthorityKeyId CertificateCertificateDescriptionAuthorityKeyId + +func (r *CertificateCertificateDescriptionAuthorityKeyId) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionAuthorityKeyId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionAuthorityKeyId + } else { + + r.KeyId = res.KeyId + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionAuthorityKeyId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionAuthorityKeyId *CertificateCertificateDescriptionAuthorityKeyId = &CertificateCertificateDescriptionAuthorityKeyId{empty: true} + +func (r *CertificateCertificateDescriptionAuthorityKeyId) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionAuthorityKeyId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionAuthorityKeyId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateCertificateDescriptionCertFingerprint struct { + empty bool `json:"-"` + Sha256Hash *string `json:"sha256Hash"` +} + +type jsonCertificateCertificateDescriptionCertFingerprint CertificateCertificateDescriptionCertFingerprint + +func (r *CertificateCertificateDescriptionCertFingerprint) UnmarshalJSON(data []byte) error { + var res jsonCertificateCertificateDescriptionCertFingerprint + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateCertificateDescriptionCertFingerprint + } else { + + r.Sha256Hash = res.Sha256Hash + + } + return nil +} + +// This object is used to assert a desired state where this CertificateCertificateDescriptionCertFingerprint is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateCertificateDescriptionCertFingerprint *CertificateCertificateDescriptionCertFingerprint = &CertificateCertificateDescriptionCertFingerprint{empty: true} + +func (r *CertificateCertificateDescriptionCertFingerprint) Empty() bool { + return r.empty +} + +func (r *CertificateCertificateDescriptionCertFingerprint) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateCertificateDescriptionCertFingerprint) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *Certificate) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "privateca", + Type: "Certificate", + Version: "privateca", + } +} + +func (r *Certificate) ID() (string, error) { + if err := extractCertificateFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "pem_csr": dcl.ValueOrEmptyString(nr.PemCsr), + "config": dcl.ValueOrEmptyString(nr.Config), + "issuer_certificate_authority": dcl.ValueOrEmptyString(nr.IssuerCertificateAuthority), + "lifetime": dcl.ValueOrEmptyString(nr.Lifetime), + "certificate_template": dcl.ValueOrEmptyString(nr.CertificateTemplate), + "subject_mode": dcl.ValueOrEmptyString(nr.SubjectMode), + "revocation_details": dcl.ValueOrEmptyString(nr.RevocationDetails), + "pem_certificate": dcl.ValueOrEmptyString(nr.PemCertificate), + "certificate_description": dcl.ValueOrEmptyString(nr.CertificateDescription), + "pem_certificate_chain": dcl.ValueOrEmptyString(nr.PemCertificateChain), + "create_time": dcl.ValueOrEmptyString(nr.CreateTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "ca_pool": dcl.ValueOrEmptyString(nr.CaPool), + "certificate_authority": dcl.ValueOrEmptyString(nr.CertificateAuthority), + } + return dcl.Nprintf("projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificates/{{name}}", params), nil +} + +const CertificateMaxPage = -1 + +type CertificateList struct { + Items []*Certificate + + nextToken string + + pageSize int32 + + resource *Certificate +} + +func (l *CertificateList) HasNext() bool { + return l.nextToken != "" +} + +func (l *CertificateList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listCertificate(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListCertificate(ctx context.Context, project, location, caPool string) (*CertificateList, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListCertificateWithMaxResults(ctx, project, location, caPool, CertificateMaxPage) + +} + +func (c *Client) ListCertificateWithMaxResults(ctx context.Context, project, location, caPool string, pageSize int32) (*CertificateList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &Certificate{ + Project: &project, + Location: &location, + CaPool: &caPool, + } + items, token, err := c.listCertificate(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &CertificateList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetCertificate(ctx context.Context, r *Certificate) (*Certificate, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractCertificateFields(r) + + b, err := c.getCertificateRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalCertificate(b, c, r) + if err != nil { + return nil, err + } + result.Project = r.Project + result.Location = r.Location + result.CaPool = r.CaPool + result.Name = r.Name + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizeCertificateNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractCertificateFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeleteCertificate(ctx context.Context, r *Certificate) error { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("Certificate resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting Certificate...") + deleteOp := deleteCertificateOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllCertificate deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllCertificate(ctx context.Context, project, location, caPool string, filter func(*Certificate) bool) error { + listObj, err := c.ListCertificate(ctx, project, location, caPool) + if err != nil { + return err + } + + err = c.deleteAllCertificate(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllCertificate(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyCertificate(ctx context.Context, rawDesired *Certificate, opts ...dcl.ApplyOption) (*Certificate, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + var resultNewState *Certificate + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyCertificateHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyCertificateHelper(c *Client, ctx context.Context, rawDesired *Certificate, opts ...dcl.ApplyOption) (*Certificate, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyCertificate...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractCertificateFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.certificateDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToCertificateDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []certificateApiOperation + if create { + ops = append(ops, &createCertificateOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyCertificateDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyCertificateDiff(c *Client, ctx context.Context, desired *Certificate, rawDesired *Certificate, ops []certificateApiOperation, opts ...dcl.ApplyOption) (*Certificate, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetCertificate(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createCertificateOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapCertificate(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizeCertificateNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizeCertificateNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizeCertificateDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractCertificateFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractCertificateFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffCertificate(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate.yaml new file mode 100644 index 00000000000..07cf6e29928 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate.yaml @@ -0,0 +1,1181 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Privateca/Certificate + description: The Privateca Certificate resource + x-dcl-struct-name: Certificate + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a Certificate + parameters: + - name: certificate + required: true + description: A full instance of a Certificate + apply: + description: The function used to apply information about a Certificate + parameters: + - name: certificate + required: true + description: A full instance of a Certificate + delete: + description: The function used to delete a Certificate + parameters: + - name: certificate + required: true + description: A full instance of a Certificate + deleteAll: + description: The function used to delete all Certificate + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + - name: caPool + required: true + schema: + type: string + list: + description: The function used to list information about many Certificate + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + - name: caPool + required: true + schema: + type: string +components: + schemas: + Certificate: + title: Certificate + x-dcl-id: projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificates/{{name}} + x-dcl-parent-container: project + x-dcl-labels: labels + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - name + - lifetime + - project + - location + - caPool + properties: + caPool: + type: string + x-dcl-go-name: CaPool + description: The ca_pool for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Privateca/CaPool + field: name + parent: true + x-dcl-parameter: true + certificateAuthority: + type: string + x-dcl-go-name: CertificateAuthority + description: The certificate authority for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Privateca/CertificateAuthority + field: name + x-dcl-parameter: true + certificateDescription: + type: object + x-dcl-go-name: CertificateDescription + x-dcl-go-type: CertificateCertificateDescription + readOnly: true + description: Output only. A structured description of the issued X.509 certificate. + x-kubernetes-immutable: true + properties: + aiaIssuingCertificateUrls: + type: array + x-dcl-go-name: AiaIssuingCertificateUrls + description: Describes lists of issuer CA certificate URLs that appear + in the "Authority Information Access" extension in the certificate. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + authorityKeyId: + type: object + x-dcl-go-name: AuthorityKeyId + x-dcl-go-type: CertificateCertificateDescriptionAuthorityKeyId + description: Identifies the subject_key_id of the parent certificate, + per https://tools.ietf.org/html/rfc5280#section-4.2.1.1 + x-kubernetes-immutable: true + properties: + keyId: + type: string + x-dcl-go-name: KeyId + description: Optional. The value of this KeyId encoded in lowercase + hexadecimal. This is most likely the 160 bit SHA-1 hash of the + public key. + x-kubernetes-immutable: true + certFingerprint: + type: object + x-dcl-go-name: CertFingerprint + x-dcl-go-type: CertificateCertificateDescriptionCertFingerprint + description: The hash of the x.509 certificate. + x-kubernetes-immutable: true + properties: + sha256Hash: + type: string + x-dcl-go-name: Sha256Hash + description: The SHA 256 hash, encoded in hexadecimal, of the DER + x509 certificate. + x-kubernetes-immutable: true + crlDistributionPoints: + type: array + x-dcl-go-name: CrlDistributionPoints + description: Describes a list of locations to obtain CRL information, + i.e. the DistributionPoint.fullName described by https://tools.ietf.org/html/rfc5280#section-4.2.1.13 + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + publicKey: + type: object + x-dcl-go-name: PublicKey + x-dcl-go-type: CertificateCertificateDescriptionPublicKey + description: The public key that corresponds to an issued certificate. + x-kubernetes-immutable: true + properties: + format: + type: string + x-dcl-go-name: Format + x-dcl-go-type: CertificateCertificateDescriptionPublicKeyFormatEnum + description: 'Required. The format of the public key. Possible values: + KEY_FORMAT_UNSPECIFIED, PEM' + x-kubernetes-immutable: true + enum: + - KEY_FORMAT_UNSPECIFIED + - PEM + key: + type: string + x-dcl-go-name: Key + description: Required. A public key. The padding and encoding must + match with the `KeyFormat` value specified for the `format` field. + x-kubernetes-immutable: true + subjectDescription: + type: object + x-dcl-go-name: SubjectDescription + x-dcl-go-type: CertificateCertificateDescriptionSubjectDescription + description: Describes some of the values in a certificate that are + related to the subject and lifetime. + x-kubernetes-immutable: true + properties: + hexSerialNumber: + type: string + x-dcl-go-name: HexSerialNumber + description: The serial number encoded in lowercase hexadecimal. + x-kubernetes-immutable: true + lifetime: + type: string + x-dcl-go-name: Lifetime + description: For convenience, the actual lifetime of an issued certificate. + x-kubernetes-immutable: true + notAfterTime: + type: string + format: date-time + x-dcl-go-name: NotAfterTime + description: The time after which the certificate is expired. Per + RFC 5280, the validity period for a certificate is the period + of time from not_before_time through not_after_time, inclusive. + Corresponds to 'not_before_time' + 'lifetime' - 1 second. + x-kubernetes-immutable: true + notBeforeTime: + type: string + format: date-time + x-dcl-go-name: NotBeforeTime + description: The time at which the certificate becomes valid. + x-kubernetes-immutable: true + subject: + type: object + x-dcl-go-name: Subject + x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubject + description: Contains distinguished name fields such as the common + name, location and / organization. + x-kubernetes-immutable: true + properties: + commonName: + type: string + x-dcl-go-name: CommonName + description: The "common name" of the subject. + x-kubernetes-immutable: true + countryCode: + type: string + x-dcl-go-name: CountryCode + description: The country code of the subject. + x-kubernetes-immutable: true + locality: + type: string + x-dcl-go-name: Locality + description: The locality or city of the subject. + x-kubernetes-immutable: true + organization: + type: string + x-dcl-go-name: Organization + description: The organization of the subject. + x-kubernetes-immutable: true + organizationalUnit: + type: string + x-dcl-go-name: OrganizationalUnit + description: The organizational_unit of the subject. + x-kubernetes-immutable: true + postalCode: + type: string + x-dcl-go-name: PostalCode + description: The postal code of the subject. + x-kubernetes-immutable: true + province: + type: string + x-dcl-go-name: Province + description: The province, territory, or regional state of the + subject. + x-kubernetes-immutable: true + streetAddress: + type: string + x-dcl-go-name: StreetAddress + description: The street address of the subject. + x-kubernetes-immutable: true + subjectAltName: + type: object + x-dcl-go-name: SubjectAltName + x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubjectAltName + description: The subject alternative name fields. + x-kubernetes-immutable: true + properties: + customSans: + type: array + x-dcl-go-name: CustomSans + description: Contains additional subject alternative name values. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to + handle this extension, the client should consider this + to be an error). + x-kubernetes-immutable: true + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + description: Required. The OID for this X.509 extension. + x-kubernetes-immutable: true + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The + most significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + x-kubernetes-immutable: true + dnsNames: + type: array + x-dcl-go-name: DnsNames + description: Contains only valid, fully-qualified host names. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + emailAddresses: + type: array + x-dcl-go-name: EmailAddresses + description: Contains only valid RFC 2822 E-mail addresses. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + ipAddresses: + type: array + x-dcl-go-name: IPAddresses + description: Contains only valid 32-bit IPv4 addresses or RFC + 4291 IPv6 addresses. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + uris: + type: array + x-dcl-go-name: Uris + description: Contains only valid RFC 3986 URIs. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + subjectKeyId: + type: object + x-dcl-go-name: SubjectKeyId + x-dcl-go-type: CertificateCertificateDescriptionSubjectKeyId + description: Provides a means of identifiying certificates that contain + a particular public key, per https://tools.ietf.org/html/rfc5280#section-4.2.1.2. + x-kubernetes-immutable: true + properties: + keyId: + type: string + x-dcl-go-name: KeyId + description: Optional. The value of this KeyId encoded in lowercase + hexadecimal. This is most likely the 160 bit SHA-1 hash of the + public key. + x-kubernetes-immutable: true + x509Description: + type: object + x-dcl-go-name: X509Description + x-dcl-go-type: CertificateCertificateDescriptionX509Description + description: Describes some of the technical X.509 fields in a certificate. + x-kubernetes-immutable: true + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. Describes custom X.509 extensions. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionAdditionalExtensions + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to handle + this extension, the client should consider this to be an + error). + x-kubernetes-immutable: true + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + description: Required. The OID for this X.509 extension. + x-kubernetes-immutable: true + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + x-kubernetes-immutable: true + aiaOcspServers: + type: array + x-dcl-go-name: AiaOcspServers + description: Optional. Describes Online Certificate Status Protocol + (OCSP) endpoint addresses that appear in the "Authority Information + Access" extension in the certificate. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caOptions: + type: object + x-dcl-go-name: CaOptions + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionCaOptions + description: Optional. Describes options in this X509Parameters + that are relevant in a CA certificate. + x-kubernetes-immutable: true + properties: + isCa: + type: boolean + x-dcl-go-name: IsCa + description: Optional. Refers to the "CA" X.509 extension, which + is a boolean value. When this value is missing, the extension + will be omitted from the CA certificate. + x-kubernetes-immutable: true + maxIssuerPathLength: + type: integer + format: int64 + x-dcl-go-name: MaxIssuerPathLength + description: Optional. Refers to the path length restriction + X.509 extension. For a CA certificate, this value describes + the depth of subordinate CA certificates that are allowed. + If this value is less than 0, the request will fail. If this + value is missing, the max path length will be omitted from + the CA certificate. + x-kubernetes-immutable: true + keyUsage: + type: object + x-dcl-go-name: KeyUsage + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsage + description: Optional. Indicates the intended use for keys that + correspond to a certificate. + x-kubernetes-immutable: true + properties: + baseKeyUsage: + type: object + x-dcl-go-name: BaseKeyUsage + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + description: Describes high-level ways in which a key may be + used. + x-kubernetes-immutable: true + properties: + certSign: + type: boolean + x-dcl-go-name: CertSign + description: The key may be used to sign certificates. + x-kubernetes-immutable: true + contentCommitment: + type: boolean + x-dcl-go-name: ContentCommitment + description: The key may be used for cryptographic commitments. + Note that this may also be referred to as "non-repudiation". + x-kubernetes-immutable: true + crlSign: + type: boolean + x-dcl-go-name: CrlSign + description: The key may be used sign certificate revocation + lists. + x-kubernetes-immutable: true + dataEncipherment: + type: boolean + x-dcl-go-name: DataEncipherment + description: The key may be used to encipher data. + x-kubernetes-immutable: true + decipherOnly: + type: boolean + x-dcl-go-name: DecipherOnly + description: The key may be used to decipher only. + x-kubernetes-immutable: true + digitalSignature: + type: boolean + x-dcl-go-name: DigitalSignature + description: The key may be used for digital signatures. + x-kubernetes-immutable: true + encipherOnly: + type: boolean + x-dcl-go-name: EncipherOnly + description: The key may be used to encipher only. + x-kubernetes-immutable: true + keyAgreement: + type: boolean + x-dcl-go-name: KeyAgreement + description: The key may be used in a key agreement protocol. + x-kubernetes-immutable: true + keyEncipherment: + type: boolean + x-dcl-go-name: KeyEncipherment + description: The key may be used to encipher other keys. + x-kubernetes-immutable: true + extendedKeyUsage: + type: object + x-dcl-go-name: ExtendedKeyUsage + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + description: Detailed scenarios in which a key may be used. + x-kubernetes-immutable: true + properties: + clientAuth: + type: boolean + x-dcl-go-name: ClientAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially + described as "TLS WWW client authentication", though regularly + used for non-WWW TLS. + x-kubernetes-immutable: true + codeSigning: + type: boolean + x-dcl-go-name: CodeSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially + described as "Signing of downloadable executable code + client authentication". + x-kubernetes-immutable: true + emailProtection: + type: boolean + x-dcl-go-name: EmailProtection + description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially + described as "Email protection". + x-kubernetes-immutable: true + ocspSigning: + type: boolean + x-dcl-go-name: OcspSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially + described as "Signing OCSP responses". + x-kubernetes-immutable: true + serverAuth: + type: boolean + x-dcl-go-name: ServerAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially + described as "TLS WWW server authentication", though regularly + used for non-WWW TLS. + x-kubernetes-immutable: true + timeStamping: + type: boolean + x-dcl-go-name: TimeStamping + description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially + described as "Binding the hash of an object to a time". + x-kubernetes-immutable: true + unknownExtendedKeyUsages: + type: array + x-dcl-go-name: UnknownExtendedKeyUsages + description: Used to describe extended key usages that are not + listed in the KeyUsage.ExtendedKeyUsageOptions message. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + policyIds: + type: array + x-dcl-go-name: PolicyIds + description: Optional. Describes the X.509 certificate policy object + identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionPolicyIds + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + certificateTemplate: + type: string + x-dcl-go-name: CertificateTemplate + description: Immutable. The resource name for a CertificateTemplate used + to issue this certificate, in the format `projects/*/locations/*/certificateTemplates/*`. + If this is specified, the caller must have the necessary permission to + use this template. If this is omitted, no template will be used. This + template must be in the same location as the Certificate. + x-kubernetes-immutable: true + x-dcl-references: + - resource: Privateca/CertificateTemplate + field: selfLink + x-dcl-has-long-form: true + config: + type: object + x-dcl-go-name: Config + x-dcl-go-type: CertificateConfig + description: Immutable. A description of the certificate and key that does + not require X.509 or ASN.1. + x-kubernetes-immutable: true + x-dcl-conflicts: + - pemCsr + required: + - subjectConfig + - x509Config + properties: + publicKey: + type: object + x-dcl-go-name: PublicKey + x-dcl-go-type: CertificateConfigPublicKey + description: Optional. The public key that corresponds to this config. + This is, for example, used when issuing Certificates, but not when + creating a self-signed CertificateAuthority or CertificateAuthority + CSR. + x-kubernetes-immutable: true + required: + - key + - format + properties: + format: + type: string + x-dcl-go-name: Format + x-dcl-go-type: CertificateConfigPublicKeyFormatEnum + description: 'Required. The format of the public key. Possible values: + KEY_FORMAT_UNSPECIFIED, PEM' + x-kubernetes-immutable: true + enum: + - KEY_FORMAT_UNSPECIFIED + - PEM + key: + type: string + x-dcl-go-name: Key + description: Required. A public key. The padding and encoding must + match with the `KeyFormat` value specified for the `format` field. + x-kubernetes-immutable: true + subjectConfig: + type: object + x-dcl-go-name: SubjectConfig + x-dcl-go-type: CertificateConfigSubjectConfig + description: Required. Specifies some of the values in a certificate + that are related to the subject. + x-kubernetes-immutable: true + required: + - subject + properties: + subject: + type: object + x-dcl-go-name: Subject + x-dcl-go-type: CertificateConfigSubjectConfigSubject + description: Required. Contains distinguished name fields such as + the common name, location and organization. + x-kubernetes-immutable: true + properties: + commonName: + type: string + x-dcl-go-name: CommonName + description: The "common name" of the subject. + x-kubernetes-immutable: true + countryCode: + type: string + x-dcl-go-name: CountryCode + description: The country code of the subject. + x-kubernetes-immutable: true + locality: + type: string + x-dcl-go-name: Locality + description: The locality or city of the subject. + x-kubernetes-immutable: true + organization: + type: string + x-dcl-go-name: Organization + description: The organization of the subject. + x-kubernetes-immutable: true + organizationalUnit: + type: string + x-dcl-go-name: OrganizationalUnit + description: The organizational_unit of the subject. + x-kubernetes-immutable: true + postalCode: + type: string + x-dcl-go-name: PostalCode + description: The postal code of the subject. + x-kubernetes-immutable: true + province: + type: string + x-dcl-go-name: Province + description: The province, territory, or regional state of the + subject. + x-kubernetes-immutable: true + streetAddress: + type: string + x-dcl-go-name: StreetAddress + description: The street address of the subject. + x-kubernetes-immutable: true + subjectAltName: + type: object + x-dcl-go-name: SubjectAltName + x-dcl-go-type: CertificateConfigSubjectConfigSubjectAltName + description: Optional. The subject alternative name fields. + x-kubernetes-immutable: true + properties: + dnsNames: + type: array + x-dcl-go-name: DnsNames + description: Contains only valid, fully-qualified host names. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + emailAddresses: + type: array + x-dcl-go-name: EmailAddresses + description: Contains only valid RFC 2822 E-mail addresses. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + ipAddresses: + type: array + x-dcl-go-name: IPAddresses + description: Contains only valid 32-bit IPv4 addresses or RFC + 4291 IPv6 addresses. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + uris: + type: array + x-dcl-go-name: Uris + description: Contains only valid RFC 3986 URIs. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + x509Config: + type: object + x-dcl-go-name: X509Config + x-dcl-go-type: CertificateConfigX509Config + description: Required. Describes how some of the technical X.509 fields + in a certificate should be populated. + x-kubernetes-immutable: true + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. Describes custom X.509 extensions. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateConfigX509ConfigAdditionalExtensions + required: + - objectId + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to handle + this extension, the client should consider this to be an + error). + x-kubernetes-immutable: true + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateConfigX509ConfigAdditionalExtensionsObjectId + description: Required. The OID for this X.509 extension. + x-kubernetes-immutable: true + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + x-kubernetes-immutable: true + aiaOcspServers: + type: array + x-dcl-go-name: AiaOcspServers + description: Optional. Describes Online Certificate Status Protocol + (OCSP) endpoint addresses that appear in the "Authority Information + Access" extension in the certificate. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caOptions: + type: object + x-dcl-go-name: CaOptions + x-dcl-go-type: CertificateConfigX509ConfigCaOptions + description: Optional. Describes options in this X509Parameters + that are relevant in a CA certificate. + x-kubernetes-immutable: true + properties: + isCa: + type: boolean + x-dcl-go-name: IsCa + description: Optional. When true, the "CA" in Basic Constraints + extension will be set to true. + x-kubernetes-immutable: true + maxIssuerPathLength: + type: integer + format: int64 + x-dcl-go-name: MaxIssuerPathLength + description: Optional. Refers to the "path length constraint" + in Basic Constraints extension. For a CA certificate, this + value describes the depth of subordinate CA certificates that + are allowed. If this value is less than 0, the request will + fail. + x-kubernetes-immutable: true + nonCa: + type: boolean + x-dcl-go-name: NonCa + description: Optional. When true, the "CA" in Basic Constraints + extension will be set to false. If both `is_ca` and `non_ca` + are unset, the extension will be omitted from the CA certificate. + x-kubernetes-immutable: true + zeroMaxIssuerPathLength: + type: boolean + x-dcl-go-name: ZeroMaxIssuerPathLength + description: Optional. When true, the "path length constraint" + in Basic Constraints extension will be set to 0. if both max_issuer_path_length + and zero_max_issuer_path_length are unset, the max path length + will be omitted from the CA certificate. + x-kubernetes-immutable: true + keyUsage: + type: object + x-dcl-go-name: KeyUsage + x-dcl-go-type: CertificateConfigX509ConfigKeyUsage + description: Optional. Indicates the intended use for keys that + correspond to a certificate. + x-kubernetes-immutable: true + properties: + baseKeyUsage: + type: object + x-dcl-go-name: BaseKeyUsage + x-dcl-go-type: CertificateConfigX509ConfigKeyUsageBaseKeyUsage + description: Describes high-level ways in which a key may be + used. + x-kubernetes-immutable: true + properties: + certSign: + type: boolean + x-dcl-go-name: CertSign + description: The key may be used to sign certificates. + x-kubernetes-immutable: true + contentCommitment: + type: boolean + x-dcl-go-name: ContentCommitment + description: The key may be used for cryptographic commitments. + Note that this may also be referred to as "non-repudiation". + x-kubernetes-immutable: true + crlSign: + type: boolean + x-dcl-go-name: CrlSign + description: The key may be used sign certificate revocation + lists. + x-kubernetes-immutable: true + dataEncipherment: + type: boolean + x-dcl-go-name: DataEncipherment + description: The key may be used to encipher data. + x-kubernetes-immutable: true + decipherOnly: + type: boolean + x-dcl-go-name: DecipherOnly + description: The key may be used to decipher only. + x-kubernetes-immutable: true + digitalSignature: + type: boolean + x-dcl-go-name: DigitalSignature + description: The key may be used for digital signatures. + x-kubernetes-immutable: true + encipherOnly: + type: boolean + x-dcl-go-name: EncipherOnly + description: The key may be used to encipher only. + x-kubernetes-immutable: true + keyAgreement: + type: boolean + x-dcl-go-name: KeyAgreement + description: The key may be used in a key agreement protocol. + x-kubernetes-immutable: true + keyEncipherment: + type: boolean + x-dcl-go-name: KeyEncipherment + description: The key may be used to encipher other keys. + x-kubernetes-immutable: true + extendedKeyUsage: + type: object + x-dcl-go-name: ExtendedKeyUsage + x-dcl-go-type: CertificateConfigX509ConfigKeyUsageExtendedKeyUsage + description: Detailed scenarios in which a key may be used. + x-kubernetes-immutable: true + properties: + clientAuth: + type: boolean + x-dcl-go-name: ClientAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially + described as "TLS WWW client authentication", though regularly + used for non-WWW TLS. + x-kubernetes-immutable: true + codeSigning: + type: boolean + x-dcl-go-name: CodeSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially + described as "Signing of downloadable executable code + client authentication". + x-kubernetes-immutable: true + emailProtection: + type: boolean + x-dcl-go-name: EmailProtection + description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially + described as "Email protection". + x-kubernetes-immutable: true + ocspSigning: + type: boolean + x-dcl-go-name: OcspSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially + described as "Signing OCSP responses". + x-kubernetes-immutable: true + serverAuth: + type: boolean + x-dcl-go-name: ServerAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially + described as "TLS WWW server authentication", though regularly + used for non-WWW TLS. + x-kubernetes-immutable: true + timeStamping: + type: boolean + x-dcl-go-name: TimeStamping + description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially + described as "Binding the hash of an object to a time". + x-kubernetes-immutable: true + unknownExtendedKeyUsages: + type: array + x-dcl-go-name: UnknownExtendedKeyUsages + description: Used to describe extended key usages that are not + listed in the KeyUsage.ExtendedKeyUsageOptions message. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + policyIds: + type: array + x-dcl-go-name: PolicyIds + description: Optional. Describes the X.509 certificate policy object + identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateConfigX509ConfigPolicyIds + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time at which this Certificate was created. + x-kubernetes-immutable: true + issuerCertificateAuthority: + type: string + x-dcl-go-name: IssuerCertificateAuthority + readOnly: true + description: Output only. The resource name of the issuing CertificateAuthority + in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`. + x-kubernetes-immutable: true + x-dcl-references: + - resource: Privateca/CertificateAuthority + field: selfLink + labels: + type: object + additionalProperties: + type: string + x-dcl-go-name: Labels + description: Optional. Labels with user-defined metadata. + lifetime: + type: string + x-dcl-go-name: Lifetime + description: Required. Immutable. The desired lifetime of a certificate. + Used to create the "not_before_time" and "not_after_time" fields inside + an X.509 certificate. Note that the lifetime may be truncated if it would + extend past the life of any certificate authority in the issuing chain. + x-kubernetes-immutable: true + location: + type: string + x-dcl-go-name: Location + description: The location for the resource + x-kubernetes-immutable: true + x-dcl-parameter: true + name: + type: string + x-dcl-go-name: Name + description: The resource name for this Certificate in the format `projects/*/locations/*/caPools/*/certificates/*`. + x-kubernetes-immutable: true + x-dcl-has-long-form: true + pemCertificate: + type: string + x-dcl-go-name: PemCertificate + readOnly: true + description: Output only. The pem-encoded, signed X.509 certificate. + x-kubernetes-immutable: true + pemCertificateChain: + type: array + x-dcl-go-name: PemCertificateChain + readOnly: true + description: Output only. The chain that may be used to verify the X.509 + certificate. Expected to be in issuer-to-root order according to RFC 5246. + x-kubernetes-immutable: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + pemCsr: + type: string + x-dcl-go-name: PemCsr + description: Immutable. A pem-encoded X.509 certificate signing request + (CSR). + x-kubernetes-immutable: true + x-dcl-conflicts: + - config + project: + type: string + x-dcl-go-name: Project + description: The project for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-parameter: true + revocationDetails: + type: object + x-dcl-go-name: RevocationDetails + x-dcl-go-type: CertificateRevocationDetails + readOnly: true + description: Output only. Details regarding the revocation of this Certificate. + This Certificate is considered revoked if and only if this field is present. + x-kubernetes-immutable: true + properties: + revocationState: + type: string + x-dcl-go-name: RevocationState + x-dcl-go-type: CertificateRevocationDetailsRevocationStateEnum + description: 'Indicates why a Certificate was revoked. Possible values: + REVOCATION_REASON_UNSPECIFIED, KEY_COMPROMISE, CERTIFICATE_AUTHORITY_COMPROMISE, + AFFILIATION_CHANGED, SUPERSEDED, CESSATION_OF_OPERATION, CERTIFICATE_HOLD, + PRIVILEGE_WITHDRAWN, ATTRIBUTE_AUTHORITY_COMPROMISE' + x-kubernetes-immutable: true + enum: + - REVOCATION_REASON_UNSPECIFIED + - KEY_COMPROMISE + - CERTIFICATE_AUTHORITY_COMPROMISE + - AFFILIATION_CHANGED + - SUPERSEDED + - CESSATION_OF_OPERATION + - CERTIFICATE_HOLD + - PRIVILEGE_WITHDRAWN + - ATTRIBUTE_AUTHORITY_COMPROMISE + revocationTime: + type: string + format: date-time + x-dcl-go-name: RevocationTime + description: The time at which this Certificate was revoked. + x-kubernetes-immutable: true + subjectMode: + type: string + x-dcl-go-name: SubjectMode + x-dcl-go-type: CertificateSubjectModeEnum + description: 'Immutable. Specifies how the Certificate''s identity fields + are to be decided. If this is omitted, the `DEFAULT` subject mode will + be used. Possible values: SUBJECT_REQUEST_MODE_UNSPECIFIED, DEFAULT, REFLECTED_SPIFFE' + x-kubernetes-immutable: true + enum: + - SUBJECT_REQUEST_MODE_UNSPECIFIED + - DEFAULT + - REFLECTED_SPIFFE + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time at which this Certificate was updated. + x-kubernetes-immutable: true diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority.go new file mode 100644 index 00000000000..7a2fa2c53d5 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority.go @@ -0,0 +1,2632 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type CertificateAuthority struct { + Name *string `json:"name"` + Type *CertificateAuthorityTypeEnum `json:"type"` + Config *CertificateAuthorityConfig `json:"config"` + Lifetime *string `json:"lifetime"` + KeySpec *CertificateAuthorityKeySpec `json:"keySpec"` + SubordinateConfig *CertificateAuthoritySubordinateConfig `json:"subordinateConfig"` + Tier *CertificateAuthorityTierEnum `json:"tier"` + State *CertificateAuthorityStateEnum `json:"state"` + PemCaCertificates []string `json:"pemCaCertificates"` + CaCertificateDescriptions []CertificateAuthorityCaCertificateDescriptions `json:"caCertificateDescriptions"` + GcsBucket *string `json:"gcsBucket"` + AccessUrls *CertificateAuthorityAccessUrls `json:"accessUrls"` + CreateTime *string `json:"createTime"` + UpdateTime *string `json:"updateTime"` + DeleteTime *string `json:"deleteTime"` + ExpireTime *string `json:"expireTime"` + Labels map[string]string `json:"labels"` + Project *string `json:"project"` + Location *string `json:"location"` + CaPool *string `json:"caPool"` +} + +func (r *CertificateAuthority) String() string { + return dcl.SprintResource(r) +} + +// The enum CertificateAuthorityTypeEnum. +type CertificateAuthorityTypeEnum string + +// CertificateAuthorityTypeEnumRef returns a *CertificateAuthorityTypeEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateAuthorityTypeEnumRef(s string) *CertificateAuthorityTypeEnum { + v := CertificateAuthorityTypeEnum(s) + return &v +} + +func (v CertificateAuthorityTypeEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"SELF_SIGNED", "SUBORDINATE"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateAuthorityTypeEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateAuthorityConfigPublicKeyFormatEnum. +type CertificateAuthorityConfigPublicKeyFormatEnum string + +// CertificateAuthorityConfigPublicKeyFormatEnumRef returns a *CertificateAuthorityConfigPublicKeyFormatEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateAuthorityConfigPublicKeyFormatEnumRef(s string) *CertificateAuthorityConfigPublicKeyFormatEnum { + v := CertificateAuthorityConfigPublicKeyFormatEnum(s) + return &v +} + +func (v CertificateAuthorityConfigPublicKeyFormatEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"PEM"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateAuthorityConfigPublicKeyFormatEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateAuthorityKeySpecAlgorithmEnum. +type CertificateAuthorityKeySpecAlgorithmEnum string + +// CertificateAuthorityKeySpecAlgorithmEnumRef returns a *CertificateAuthorityKeySpecAlgorithmEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateAuthorityKeySpecAlgorithmEnumRef(s string) *CertificateAuthorityKeySpecAlgorithmEnum { + v := CertificateAuthorityKeySpecAlgorithmEnum(s) + return &v +} + +func (v CertificateAuthorityKeySpecAlgorithmEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"RSA_PSS_2048_SHA256", "RSA_PSS_3072_SHA256", "RSA_PSS_4096_SHA256", "RSA_PKCS1_2048_SHA256", "RSA_PKCS1_3072_SHA256", "RSA_PKCS1_4096_SHA256", "EC_P256_SHA256", "EC_P384_SHA384"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateAuthorityKeySpecAlgorithmEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateAuthorityTierEnum. +type CertificateAuthorityTierEnum string + +// CertificateAuthorityTierEnumRef returns a *CertificateAuthorityTierEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateAuthorityTierEnumRef(s string) *CertificateAuthorityTierEnum { + v := CertificateAuthorityTierEnum(s) + return &v +} + +func (v CertificateAuthorityTierEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"ENTERPRISE", "DEVOPS"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateAuthorityTierEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateAuthorityStateEnum. +type CertificateAuthorityStateEnum string + +// CertificateAuthorityStateEnumRef returns a *CertificateAuthorityStateEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateAuthorityStateEnumRef(s string) *CertificateAuthorityStateEnum { + v := CertificateAuthorityStateEnum(s) + return &v +} + +func (v CertificateAuthorityStateEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"ENABLED", "DISABLED", "STAGED", "AWAITING_USER_ACTIVATION", "DELETED"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateAuthorityStateEnum", + Value: string(v), + Valid: []string{}, + } +} + +// The enum CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum. +type CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum string + +// CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumRef returns a *CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumRef(s string) *CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum { + v := CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum(s) + return &v +} + +func (v CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"PEM"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum", + Value: string(v), + Valid: []string{}, + } +} + +type CertificateAuthorityConfig struct { + empty bool `json:"-"` + SubjectConfig *CertificateAuthorityConfigSubjectConfig `json:"subjectConfig"` + X509Config *CertificateAuthorityConfigX509Config `json:"x509Config"` + PublicKey *CertificateAuthorityConfigPublicKey `json:"publicKey"` +} + +type jsonCertificateAuthorityConfig CertificateAuthorityConfig + +func (r *CertificateAuthorityConfig) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfig + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfig + } else { + + r.SubjectConfig = res.SubjectConfig + + r.X509Config = res.X509Config + + r.PublicKey = res.PublicKey + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfig is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfig *CertificateAuthorityConfig = &CertificateAuthorityConfig{empty: true} + +func (r *CertificateAuthorityConfig) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfig) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfig) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigSubjectConfig struct { + empty bool `json:"-"` + Subject *CertificateAuthorityConfigSubjectConfigSubject `json:"subject"` + SubjectAltName *CertificateAuthorityConfigSubjectConfigSubjectAltName `json:"subjectAltName"` +} + +type jsonCertificateAuthorityConfigSubjectConfig CertificateAuthorityConfigSubjectConfig + +func (r *CertificateAuthorityConfigSubjectConfig) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigSubjectConfig + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigSubjectConfig + } else { + + r.Subject = res.Subject + + r.SubjectAltName = res.SubjectAltName + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigSubjectConfig is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigSubjectConfig *CertificateAuthorityConfigSubjectConfig = &CertificateAuthorityConfigSubjectConfig{empty: true} + +func (r *CertificateAuthorityConfigSubjectConfig) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigSubjectConfig) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigSubjectConfig) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigSubjectConfigSubject struct { + empty bool `json:"-"` + CommonName *string `json:"commonName"` + CountryCode *string `json:"countryCode"` + Organization *string `json:"organization"` + OrganizationalUnit *string `json:"organizationalUnit"` + Locality *string `json:"locality"` + Province *string `json:"province"` + StreetAddress *string `json:"streetAddress"` + PostalCode *string `json:"postalCode"` +} + +type jsonCertificateAuthorityConfigSubjectConfigSubject CertificateAuthorityConfigSubjectConfigSubject + +func (r *CertificateAuthorityConfigSubjectConfigSubject) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigSubjectConfigSubject + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigSubjectConfigSubject + } else { + + r.CommonName = res.CommonName + + r.CountryCode = res.CountryCode + + r.Organization = res.Organization + + r.OrganizationalUnit = res.OrganizationalUnit + + r.Locality = res.Locality + + r.Province = res.Province + + r.StreetAddress = res.StreetAddress + + r.PostalCode = res.PostalCode + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigSubjectConfigSubject is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigSubjectConfigSubject *CertificateAuthorityConfigSubjectConfigSubject = &CertificateAuthorityConfigSubjectConfigSubject{empty: true} + +func (r *CertificateAuthorityConfigSubjectConfigSubject) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigSubjectConfigSubject) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigSubjectConfigSubject) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigSubjectConfigSubjectAltName struct { + empty bool `json:"-"` + DnsNames []string `json:"dnsNames"` + Uris []string `json:"uris"` + EmailAddresses []string `json:"emailAddresses"` + IPAddresses []string `json:"ipAddresses"` + CustomSans []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans `json:"customSans"` +} + +type jsonCertificateAuthorityConfigSubjectConfigSubjectAltName CertificateAuthorityConfigSubjectConfigSubjectAltName + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltName) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigSubjectConfigSubjectAltName + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigSubjectConfigSubjectAltName + } else { + + r.DnsNames = res.DnsNames + + r.Uris = res.Uris + + r.EmailAddresses = res.EmailAddresses + + r.IPAddresses = res.IPAddresses + + r.CustomSans = res.CustomSans + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigSubjectConfigSubjectAltName is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigSubjectConfigSubjectAltName *CertificateAuthorityConfigSubjectConfigSubjectAltName = &CertificateAuthorityConfigSubjectConfigSubjectAltName{empty: true} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltName) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltName) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltName) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans struct { + empty bool `json:"-"` + ObjectId *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans = &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{empty: true} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId = &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{empty: true} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509Config struct { + empty bool `json:"-"` + KeyUsage *CertificateAuthorityConfigX509ConfigKeyUsage `json:"keyUsage"` + CaOptions *CertificateAuthorityConfigX509ConfigCaOptions `json:"caOptions"` + PolicyIds []CertificateAuthorityConfigX509ConfigPolicyIds `json:"policyIds"` + AiaOcspServers []string `json:"aiaOcspServers"` + AdditionalExtensions []CertificateAuthorityConfigX509ConfigAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCertificateAuthorityConfigX509Config CertificateAuthorityConfigX509Config + +func (r *CertificateAuthorityConfigX509Config) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509Config + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509Config + } else { + + r.KeyUsage = res.KeyUsage + + r.CaOptions = res.CaOptions + + r.PolicyIds = res.PolicyIds + + r.AiaOcspServers = res.AiaOcspServers + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509Config is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509Config *CertificateAuthorityConfigX509Config = &CertificateAuthorityConfigX509Config{empty: true} + +func (r *CertificateAuthorityConfigX509Config) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509Config) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509Config) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigKeyUsage struct { + empty bool `json:"-"` + BaseKeyUsage *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage `json:"baseKeyUsage"` + ExtendedKeyUsage *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage `json:"extendedKeyUsage"` + UnknownExtendedKeyUsages []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages `json:"unknownExtendedKeyUsages"` +} + +type jsonCertificateAuthorityConfigX509ConfigKeyUsage CertificateAuthorityConfigX509ConfigKeyUsage + +func (r *CertificateAuthorityConfigX509ConfigKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigKeyUsage + } else { + + r.BaseKeyUsage = res.BaseKeyUsage + + r.ExtendedKeyUsage = res.ExtendedKeyUsage + + r.UnknownExtendedKeyUsages = res.UnknownExtendedKeyUsages + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigKeyUsage *CertificateAuthorityConfigX509ConfigKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsage{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage struct { + empty bool `json:"-"` + DigitalSignature *bool `json:"digitalSignature"` + ContentCommitment *bool `json:"contentCommitment"` + KeyEncipherment *bool `json:"keyEncipherment"` + DataEncipherment *bool `json:"dataEncipherment"` + KeyAgreement *bool `json:"keyAgreement"` + CertSign *bool `json:"certSign"` + CrlSign *bool `json:"crlSign"` + EncipherOnly *bool `json:"encipherOnly"` + DecipherOnly *bool `json:"decipherOnly"` +} + +type jsonCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + } else { + + r.DigitalSignature = res.DigitalSignature + + r.ContentCommitment = res.ContentCommitment + + r.KeyEncipherment = res.KeyEncipherment + + r.DataEncipherment = res.DataEncipherment + + r.KeyAgreement = res.KeyAgreement + + r.CertSign = res.CertSign + + r.CrlSign = res.CrlSign + + r.EncipherOnly = res.EncipherOnly + + r.DecipherOnly = res.DecipherOnly + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage struct { + empty bool `json:"-"` + ServerAuth *bool `json:"serverAuth"` + ClientAuth *bool `json:"clientAuth"` + CodeSigning *bool `json:"codeSigning"` + EmailProtection *bool `json:"emailProtection"` + TimeStamping *bool `json:"timeStamping"` + OcspSigning *bool `json:"ocspSigning"` +} + +type jsonCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + } else { + + r.ServerAuth = res.ServerAuth + + r.ClientAuth = res.ClientAuth + + r.CodeSigning = res.CodeSigning + + r.EmailProtection = res.EmailProtection + + r.TimeStamping = res.TimeStamping + + r.OcspSigning = res.OcspSigning + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages = &CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigCaOptions struct { + empty bool `json:"-"` + IsCa *bool `json:"isCa"` + MaxIssuerPathLength *int64 `json:"maxIssuerPathLength"` + ZeroMaxIssuerPathLength *bool `json:"zeroMaxIssuerPathLength"` +} + +type jsonCertificateAuthorityConfigX509ConfigCaOptions CertificateAuthorityConfigX509ConfigCaOptions + +func (r *CertificateAuthorityConfigX509ConfigCaOptions) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigCaOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigCaOptions + } else { + + r.IsCa = res.IsCa + + r.MaxIssuerPathLength = res.MaxIssuerPathLength + + r.ZeroMaxIssuerPathLength = res.ZeroMaxIssuerPathLength + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigCaOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigCaOptions *CertificateAuthorityConfigX509ConfigCaOptions = &CertificateAuthorityConfigX509ConfigCaOptions{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigCaOptions) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigCaOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigCaOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigPolicyIds struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityConfigX509ConfigPolicyIds CertificateAuthorityConfigX509ConfigPolicyIds + +func (r *CertificateAuthorityConfigX509ConfigPolicyIds) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigPolicyIds + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigPolicyIds + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigPolicyIds is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigPolicyIds *CertificateAuthorityConfigX509ConfigPolicyIds = &CertificateAuthorityConfigX509ConfigPolicyIds{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigPolicyIds) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigPolicyIds) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigPolicyIds) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigAdditionalExtensions struct { + empty bool `json:"-"` + ObjectId *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateAuthorityConfigX509ConfigAdditionalExtensions CertificateAuthorityConfigX509ConfigAdditionalExtensions + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensions + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensions *CertificateAuthorityConfigX509ConfigAdditionalExtensions = &CertificateAuthorityConfigX509ConfigAdditionalExtensions{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId = &CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{empty: true} + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityConfigPublicKey struct { + empty bool `json:"-"` + Key *string `json:"key"` + Format *CertificateAuthorityConfigPublicKeyFormatEnum `json:"format"` +} + +type jsonCertificateAuthorityConfigPublicKey CertificateAuthorityConfigPublicKey + +func (r *CertificateAuthorityConfigPublicKey) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityConfigPublicKey + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityConfigPublicKey + } else { + + r.Key = res.Key + + r.Format = res.Format + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityConfigPublicKey is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityConfigPublicKey *CertificateAuthorityConfigPublicKey = &CertificateAuthorityConfigPublicKey{empty: true} + +func (r *CertificateAuthorityConfigPublicKey) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityConfigPublicKey) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityConfigPublicKey) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityKeySpec struct { + empty bool `json:"-"` + CloudKmsKeyVersion *string `json:"cloudKmsKeyVersion"` + Algorithm *CertificateAuthorityKeySpecAlgorithmEnum `json:"algorithm"` +} + +type jsonCertificateAuthorityKeySpec CertificateAuthorityKeySpec + +func (r *CertificateAuthorityKeySpec) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityKeySpec + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityKeySpec + } else { + + r.CloudKmsKeyVersion = res.CloudKmsKeyVersion + + r.Algorithm = res.Algorithm + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityKeySpec is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityKeySpec *CertificateAuthorityKeySpec = &CertificateAuthorityKeySpec{empty: true} + +func (r *CertificateAuthorityKeySpec) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityKeySpec) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityKeySpec) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthoritySubordinateConfig struct { + empty bool `json:"-"` + CertificateAuthority *string `json:"certificateAuthority"` + PemIssuerChain *CertificateAuthoritySubordinateConfigPemIssuerChain `json:"pemIssuerChain"` +} + +type jsonCertificateAuthoritySubordinateConfig CertificateAuthoritySubordinateConfig + +func (r *CertificateAuthoritySubordinateConfig) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthoritySubordinateConfig + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthoritySubordinateConfig + } else { + + r.CertificateAuthority = res.CertificateAuthority + + r.PemIssuerChain = res.PemIssuerChain + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthoritySubordinateConfig is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthoritySubordinateConfig *CertificateAuthoritySubordinateConfig = &CertificateAuthoritySubordinateConfig{empty: true} + +func (r *CertificateAuthoritySubordinateConfig) Empty() bool { + return r.empty +} + +func (r *CertificateAuthoritySubordinateConfig) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthoritySubordinateConfig) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthoritySubordinateConfigPemIssuerChain struct { + empty bool `json:"-"` + PemCertificates []string `json:"pemCertificates"` +} + +type jsonCertificateAuthoritySubordinateConfigPemIssuerChain CertificateAuthoritySubordinateConfigPemIssuerChain + +func (r *CertificateAuthoritySubordinateConfigPemIssuerChain) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthoritySubordinateConfigPemIssuerChain + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthoritySubordinateConfigPemIssuerChain + } else { + + r.PemCertificates = res.PemCertificates + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthoritySubordinateConfigPemIssuerChain is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthoritySubordinateConfigPemIssuerChain *CertificateAuthoritySubordinateConfigPemIssuerChain = &CertificateAuthoritySubordinateConfigPemIssuerChain{empty: true} + +func (r *CertificateAuthoritySubordinateConfigPemIssuerChain) Empty() bool { + return r.empty +} + +func (r *CertificateAuthoritySubordinateConfigPemIssuerChain) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthoritySubordinateConfigPemIssuerChain) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptions struct { + empty bool `json:"-"` + SubjectDescription *CertificateAuthorityCaCertificateDescriptionsSubjectDescription `json:"subjectDescription"` + X509Description *CertificateAuthorityCaCertificateDescriptionsX509Description `json:"x509Description"` + PublicKey *CertificateAuthorityCaCertificateDescriptionsPublicKey `json:"publicKey"` + SubjectKeyId *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId `json:"subjectKeyId"` + AuthorityKeyId *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId `json:"authorityKeyId"` + CrlDistributionPoints []string `json:"crlDistributionPoints"` + AiaIssuingCertificateUrls []string `json:"aiaIssuingCertificateUrls"` + CertFingerprint *CertificateAuthorityCaCertificateDescriptionsCertFingerprint `json:"certFingerprint"` +} + +type jsonCertificateAuthorityCaCertificateDescriptions CertificateAuthorityCaCertificateDescriptions + +func (r *CertificateAuthorityCaCertificateDescriptions) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptions + } else { + + r.SubjectDescription = res.SubjectDescription + + r.X509Description = res.X509Description + + r.PublicKey = res.PublicKey + + r.SubjectKeyId = res.SubjectKeyId + + r.AuthorityKeyId = res.AuthorityKeyId + + r.CrlDistributionPoints = res.CrlDistributionPoints + + r.AiaIssuingCertificateUrls = res.AiaIssuingCertificateUrls + + r.CertFingerprint = res.CertFingerprint + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptions *CertificateAuthorityCaCertificateDescriptions = &CertificateAuthorityCaCertificateDescriptions{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptions) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsSubjectDescription struct { + empty bool `json:"-"` + Subject *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject `json:"subject"` + SubjectAltName *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName `json:"subjectAltName"` + HexSerialNumber *string `json:"hexSerialNumber"` + Lifetime *string `json:"lifetime"` + NotBeforeTime *string `json:"notBeforeTime"` + NotAfterTime *string `json:"notAfterTime"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescription CertificateAuthorityCaCertificateDescriptionsSubjectDescription + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescription + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescription + } else { + + r.Subject = res.Subject + + r.SubjectAltName = res.SubjectAltName + + r.HexSerialNumber = res.HexSerialNumber + + r.Lifetime = res.Lifetime + + r.NotBeforeTime = res.NotBeforeTime + + r.NotAfterTime = res.NotAfterTime + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsSubjectDescription is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescription *CertificateAuthorityCaCertificateDescriptionsSubjectDescription = &CertificateAuthorityCaCertificateDescriptionsSubjectDescription{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject struct { + empty bool `json:"-"` + CommonName *string `json:"commonName"` + CountryCode *string `json:"countryCode"` + Organization *string `json:"organization"` + OrganizationalUnit *string `json:"organizationalUnit"` + Locality *string `json:"locality"` + Province *string `json:"province"` + StreetAddress *string `json:"streetAddress"` + PostalCode *string `json:"postalCode"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + } else { + + r.CommonName = res.CommonName + + r.CountryCode = res.CountryCode + + r.Organization = res.Organization + + r.OrganizationalUnit = res.OrganizationalUnit + + r.Locality = res.Locality + + r.Province = res.Province + + r.StreetAddress = res.StreetAddress + + r.PostalCode = res.PostalCode + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName struct { + empty bool `json:"-"` + DnsNames []string `json:"dnsNames"` + Uris []string `json:"uris"` + EmailAddresses []string `json:"emailAddresses"` + IPAddresses []string `json:"ipAddresses"` + CustomSans []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans `json:"customSans"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + } else { + + r.DnsNames = res.DnsNames + + r.Uris = res.Uris + + r.EmailAddresses = res.EmailAddresses + + r.IPAddresses = res.IPAddresses + + r.CustomSans = res.CustomSans + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans struct { + empty bool `json:"-"` + ObjectId *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509Description struct { + empty bool `json:"-"` + KeyUsage *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage `json:"keyUsage"` + CaOptions *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions `json:"caOptions"` + PolicyIds []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds `json:"policyIds"` + AiaOcspServers []string `json:"aiaOcspServers"` + AdditionalExtensions []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509Description CertificateAuthorityCaCertificateDescriptionsX509Description + +func (r *CertificateAuthorityCaCertificateDescriptionsX509Description) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509Description + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509Description + } else { + + r.KeyUsage = res.KeyUsage + + r.CaOptions = res.CaOptions + + r.PolicyIds = res.PolicyIds + + r.AiaOcspServers = res.AiaOcspServers + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509Description is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509Description *CertificateAuthorityCaCertificateDescriptionsX509Description = &CertificateAuthorityCaCertificateDescriptionsX509Description{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509Description) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509Description) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509Description) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage struct { + empty bool `json:"-"` + BaseKeyUsage *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage `json:"baseKeyUsage"` + ExtendedKeyUsage *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage `json:"extendedKeyUsage"` + UnknownExtendedKeyUsages []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages `json:"unknownExtendedKeyUsages"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + } else { + + r.BaseKeyUsage = res.BaseKeyUsage + + r.ExtendedKeyUsage = res.ExtendedKeyUsage + + r.UnknownExtendedKeyUsages = res.UnknownExtendedKeyUsages + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage struct { + empty bool `json:"-"` + DigitalSignature *bool `json:"digitalSignature"` + ContentCommitment *bool `json:"contentCommitment"` + KeyEncipherment *bool `json:"keyEncipherment"` + DataEncipherment *bool `json:"dataEncipherment"` + KeyAgreement *bool `json:"keyAgreement"` + CertSign *bool `json:"certSign"` + CrlSign *bool `json:"crlSign"` + EncipherOnly *bool `json:"encipherOnly"` + DecipherOnly *bool `json:"decipherOnly"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + } else { + + r.DigitalSignature = res.DigitalSignature + + r.ContentCommitment = res.ContentCommitment + + r.KeyEncipherment = res.KeyEncipherment + + r.DataEncipherment = res.DataEncipherment + + r.KeyAgreement = res.KeyAgreement + + r.CertSign = res.CertSign + + r.CrlSign = res.CrlSign + + r.EncipherOnly = res.EncipherOnly + + r.DecipherOnly = res.DecipherOnly + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage struct { + empty bool `json:"-"` + ServerAuth *bool `json:"serverAuth"` + ClientAuth *bool `json:"clientAuth"` + CodeSigning *bool `json:"codeSigning"` + EmailProtection *bool `json:"emailProtection"` + TimeStamping *bool `json:"timeStamping"` + OcspSigning *bool `json:"ocspSigning"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + } else { + + r.ServerAuth = res.ServerAuth + + r.ClientAuth = res.ClientAuth + + r.CodeSigning = res.CodeSigning + + r.EmailProtection = res.EmailProtection + + r.TimeStamping = res.TimeStamping + + r.OcspSigning = res.OcspSigning + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions struct { + empty bool `json:"-"` + IsCa *bool `json:"isCa"` + MaxIssuerPathLength *int64 `json:"maxIssuerPathLength"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + } else { + + r.IsCa = res.IsCa + + r.MaxIssuerPathLength = res.MaxIssuerPathLength + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions struct { + empty bool `json:"-"` + ObjectId *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsPublicKey struct { + empty bool `json:"-"` + Key *string `json:"key"` + Format *CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum `json:"format"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsPublicKey CertificateAuthorityCaCertificateDescriptionsPublicKey + +func (r *CertificateAuthorityCaCertificateDescriptionsPublicKey) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsPublicKey + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsPublicKey + } else { + + r.Key = res.Key + + r.Format = res.Format + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsPublicKey is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsPublicKey *CertificateAuthorityCaCertificateDescriptionsPublicKey = &CertificateAuthorityCaCertificateDescriptionsPublicKey{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsPublicKey) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsPublicKey) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsPublicKey) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsSubjectKeyId struct { + empty bool `json:"-"` + KeyId *string `json:"keyId"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsSubjectKeyId CertificateAuthorityCaCertificateDescriptionsSubjectKeyId + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsSubjectKeyId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsSubjectKeyId + } else { + + r.KeyId = res.KeyId + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsSubjectKeyId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsSubjectKeyId *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId = &CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId struct { + empty bool `json:"-"` + KeyId *string `json:"keyId"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + +func (r *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + } else { + + r.KeyId = res.KeyId + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId = &CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityCaCertificateDescriptionsCertFingerprint struct { + empty bool `json:"-"` + Sha256Hash *string `json:"sha256Hash"` +} + +type jsonCertificateAuthorityCaCertificateDescriptionsCertFingerprint CertificateAuthorityCaCertificateDescriptionsCertFingerprint + +func (r *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityCaCertificateDescriptionsCertFingerprint + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityCaCertificateDescriptionsCertFingerprint + } else { + + r.Sha256Hash = res.Sha256Hash + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityCaCertificateDescriptionsCertFingerprint is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityCaCertificateDescriptionsCertFingerprint *CertificateAuthorityCaCertificateDescriptionsCertFingerprint = &CertificateAuthorityCaCertificateDescriptionsCertFingerprint{empty: true} + +func (r *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateAuthorityAccessUrls struct { + empty bool `json:"-"` + CaCertificateAccessUrl *string `json:"caCertificateAccessUrl"` + CrlAccessUrls []string `json:"crlAccessUrls"` +} + +type jsonCertificateAuthorityAccessUrls CertificateAuthorityAccessUrls + +func (r *CertificateAuthorityAccessUrls) UnmarshalJSON(data []byte) error { + var res jsonCertificateAuthorityAccessUrls + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateAuthorityAccessUrls + } else { + + r.CaCertificateAccessUrl = res.CaCertificateAccessUrl + + r.CrlAccessUrls = res.CrlAccessUrls + + } + return nil +} + +// This object is used to assert a desired state where this CertificateAuthorityAccessUrls is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateAuthorityAccessUrls *CertificateAuthorityAccessUrls = &CertificateAuthorityAccessUrls{empty: true} + +func (r *CertificateAuthorityAccessUrls) Empty() bool { + return r.empty +} + +func (r *CertificateAuthorityAccessUrls) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateAuthorityAccessUrls) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *CertificateAuthority) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "privateca", + Type: "CertificateAuthority", + Version: "privateca", + } +} + +func (r *CertificateAuthority) ID() (string, error) { + if err := extractCertificateAuthorityFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "type": dcl.ValueOrEmptyString(nr.Type), + "config": dcl.ValueOrEmptyString(nr.Config), + "lifetime": dcl.ValueOrEmptyString(nr.Lifetime), + "key_spec": dcl.ValueOrEmptyString(nr.KeySpec), + "subordinate_config": dcl.ValueOrEmptyString(nr.SubordinateConfig), + "tier": dcl.ValueOrEmptyString(nr.Tier), + "state": dcl.ValueOrEmptyString(nr.State), + "pem_ca_certificates": dcl.ValueOrEmptyString(nr.PemCaCertificates), + "ca_certificate_descriptions": dcl.ValueOrEmptyString(nr.CaCertificateDescriptions), + "gcs_bucket": dcl.ValueOrEmptyString(nr.GcsBucket), + "access_urls": dcl.ValueOrEmptyString(nr.AccessUrls), + "create_time": dcl.ValueOrEmptyString(nr.CreateTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "delete_time": dcl.ValueOrEmptyString(nr.DeleteTime), + "expire_time": dcl.ValueOrEmptyString(nr.ExpireTime), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "ca_pool": dcl.ValueOrEmptyString(nr.CaPool), + } + return dcl.Nprintf("projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificateAuthorities/{{name}}", params), nil +} + +const CertificateAuthorityMaxPage = -1 + +type CertificateAuthorityList struct { + Items []*CertificateAuthority + + nextToken string + + pageSize int32 + + resource *CertificateAuthority +} + +func (l *CertificateAuthorityList) HasNext() bool { + return l.nextToken != "" +} + +func (l *CertificateAuthorityList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listCertificateAuthority(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListCertificateAuthority(ctx context.Context, project, location, caPool string) (*CertificateAuthorityList, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListCertificateAuthorityWithMaxResults(ctx, project, location, caPool, CertificateAuthorityMaxPage) + +} + +func (c *Client) ListCertificateAuthorityWithMaxResults(ctx context.Context, project, location, caPool string, pageSize int32) (*CertificateAuthorityList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &CertificateAuthority{ + Project: &project, + Location: &location, + CaPool: &caPool, + } + items, token, err := c.listCertificateAuthority(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &CertificateAuthorityList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetCertificateAuthority(ctx context.Context, r *CertificateAuthority) (*CertificateAuthority, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractCertificateAuthorityFields(r) + + b, err := c.getCertificateAuthorityRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalCertificateAuthority(b, c, r) + if err != nil { + return nil, err + } + result.Project = r.Project + result.Location = r.Location + result.CaPool = r.CaPool + result.Name = r.Name + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizeCertificateAuthorityNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractCertificateAuthorityFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeleteCertificateAuthority(ctx context.Context, r *CertificateAuthority) error { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("CertificateAuthority resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting CertificateAuthority...") + deleteOp := deleteCertificateAuthorityOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllCertificateAuthority deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllCertificateAuthority(ctx context.Context, project, location, caPool string, filter func(*CertificateAuthority) bool) error { + listObj, err := c.ListCertificateAuthority(ctx, project, location, caPool) + if err != nil { + return err + } + + err = c.deleteAllCertificateAuthority(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllCertificateAuthority(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyCertificateAuthority(ctx context.Context, rawDesired *CertificateAuthority, opts ...dcl.ApplyOption) (*CertificateAuthority, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + var resultNewState *CertificateAuthority + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyCertificateAuthorityHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyCertificateAuthorityHelper(c *Client, ctx context.Context, rawDesired *CertificateAuthority, opts ...dcl.ApplyOption) (*CertificateAuthority, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyCertificateAuthority...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractCertificateAuthorityFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.certificateAuthorityDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToCertificateAuthorityDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []certificateAuthorityApiOperation + if create { + ops = append(ops, &createCertificateAuthorityOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyCertificateAuthorityDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyCertificateAuthorityDiff(c *Client, ctx context.Context, desired *CertificateAuthority, rawDesired *CertificateAuthority, ops []certificateAuthorityApiOperation, opts ...dcl.ApplyOption) (*CertificateAuthority, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetCertificateAuthority(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createCertificateAuthorityOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapCertificateAuthority(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizeCertificateAuthorityNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizeCertificateAuthorityNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizeCertificateAuthorityDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractCertificateAuthorityFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractCertificateAuthorityFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffCertificateAuthority(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority.yaml new file mode 100644 index 00000000000..da80b26c993 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority.yaml @@ -0,0 +1,1278 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Privateca/CertificateAuthority + description: The Privateca CertificateAuthority resource + x-dcl-struct-name: CertificateAuthority + x-dcl-has-iam: false +paths: + get: + description: The function used to get information about a CertificateAuthority + parameters: + - name: certificateAuthority + required: true + description: A full instance of a CertificateAuthority + apply: + description: The function used to apply information about a CertificateAuthority + parameters: + - name: certificateAuthority + required: true + description: A full instance of a CertificateAuthority + delete: + description: The function used to delete a CertificateAuthority + parameters: + - name: certificateAuthority + required: true + description: A full instance of a CertificateAuthority + deleteAll: + description: The function used to delete all CertificateAuthority + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + - name: caPool + required: true + schema: + type: string + list: + description: The function used to list information about many CertificateAuthority + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + - name: caPool + required: true + schema: + type: string +components: + schemas: + CertificateAuthority: + title: CertificateAuthority + x-dcl-id: projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificateAuthorities/{{name}} + x-dcl-parent-container: project + x-dcl-labels: labels + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - name + - type + - config + - lifetime + - keySpec + - project + - location + - caPool + properties: + accessUrls: + type: object + x-dcl-go-name: AccessUrls + x-dcl-go-type: CertificateAuthorityAccessUrls + readOnly: true + description: Output only. URLs for accessing content published by this CA, + such as the CA certificate and CRLs. + x-kubernetes-immutable: true + properties: + caCertificateAccessUrl: + type: string + x-dcl-go-name: CaCertificateAccessUrl + description: The URL where this CertificateAuthority's CA certificate + is published. This will only be set for CAs that have been activated. + x-kubernetes-immutable: true + crlAccessUrls: + type: array + x-dcl-go-name: CrlAccessUrls + description: The URLs where this CertificateAuthority's CRLs are published. + This will only be set for CAs that have been activated. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caCertificateDescriptions: + type: array + x-dcl-go-name: CaCertificateDescriptions + readOnly: true + description: Output only. A structured description of this CertificateAuthority's + CA certificate and its issuers. Ordered as self-to-root. + x-kubernetes-immutable: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptions + properties: + aiaIssuingCertificateUrls: + type: array + x-dcl-go-name: AiaIssuingCertificateUrls + description: Describes lists of issuer CA certificate URLs that appear + in the "Authority Information Access" extension in the certificate. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + authorityKeyId: + type: object + x-dcl-go-name: AuthorityKeyId + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + description: Identifies the subject_key_id of the parent certificate, + per https://tools.ietf.org/html/rfc5280#section-4.2.1.1 + properties: + keyId: + type: string + x-dcl-go-name: KeyId + description: Optional. The value of this KeyId encoded in lowercase + hexadecimal. This is most likely the 160 bit SHA-1 hash of the + public key. + certFingerprint: + type: object + x-dcl-go-name: CertFingerprint + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsCertFingerprint + description: The hash of the x.509 certificate. + properties: + sha256Hash: + type: string + x-dcl-go-name: Sha256Hash + description: The SHA 256 hash, encoded in hexadecimal, of the + DER x509 certificate. + crlDistributionPoints: + type: array + x-dcl-go-name: CrlDistributionPoints + description: Describes a list of locations to obtain CRL information, + i.e. the DistributionPoint.fullName described by https://tools.ietf.org/html/rfc5280#section-4.2.1.13 + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + publicKey: + type: object + x-dcl-go-name: PublicKey + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsPublicKey + description: The public key that corresponds to an issued certificate. + required: + - key + - format + properties: + format: + type: string + x-dcl-go-name: Format + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum + description: 'Required. The format of the public key. Possible + values: PEM' + enum: + - PEM + key: + type: string + x-dcl-go-name: Key + description: Required. A public key. The padding and encoding + must match with the `KeyFormat` value specified for the `format` + field. + subjectDescription: + type: object + x-dcl-go-name: SubjectDescription + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescription + description: Describes some of the values in a certificate that are + related to the subject and lifetime. + properties: + hexSerialNumber: + type: string + x-dcl-go-name: HexSerialNumber + description: The serial number encoded in lowercase hexadecimal. + lifetime: + type: string + x-dcl-go-name: Lifetime + description: For convenience, the actual lifetime of an issued + certificate. + notAfterTime: + type: string + format: date-time + x-dcl-go-name: NotAfterTime + description: The time after which the certificate is expired. + Per RFC 5280, the validity period for a certificate is the period + of time from not_before_time through not_after_time, inclusive. + Corresponds to 'not_before_time' + 'lifetime' - 1 second. + notBeforeTime: + type: string + format: date-time + x-dcl-go-name: NotBeforeTime + description: The time at which the certificate becomes valid. + subject: + type: object + x-dcl-go-name: Subject + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + description: Contains distinguished name fields such as the common + name, location and organization. + properties: + commonName: + type: string + x-dcl-go-name: CommonName + description: The "common name" of the subject. + countryCode: + type: string + x-dcl-go-name: CountryCode + description: The country code of the subject. + locality: + type: string + x-dcl-go-name: Locality + description: The locality or city of the subject. + organization: + type: string + x-dcl-go-name: Organization + description: The organization of the subject. + organizationalUnit: + type: string + x-dcl-go-name: OrganizationalUnit + description: The organizational_unit of the subject. + postalCode: + type: string + x-dcl-go-name: PostalCode + description: The postal code of the subject. + province: + type: string + x-dcl-go-name: Province + description: The province, territory, or regional state of + the subject. + streetAddress: + type: string + x-dcl-go-name: StreetAddress + description: The street address of the subject. + subjectAltName: + type: object + x-dcl-go-name: SubjectAltName + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + description: The subject alternative name fields. + properties: + customSans: + type: array + x-dcl-go-name: CustomSans + description: Contains additional subject alternative name + values. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + required: + - objectId + - critical + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this + extension is critical (i.e., if the client does not + know how to handle this extension, the client should + consider this to be an error). + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + description: Required. The OID for this X.509 extension. + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. + The most significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + dnsNames: + type: array + x-dcl-go-name: DnsNames + description: Contains only valid, fully-qualified host names. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + emailAddresses: + type: array + x-dcl-go-name: EmailAddresses + description: Contains only valid RFC 2822 E-mail addresses. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + ipAddresses: + type: array + x-dcl-go-name: IPAddresses + description: Contains only valid 32-bit IPv4 addresses or + RFC 4291 IPv6 addresses. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + uris: + type: array + x-dcl-go-name: Uris + description: Contains only valid RFC 3986 URIs. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + subjectKeyId: + type: object + x-dcl-go-name: SubjectKeyId + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectKeyId + description: Provides a means of identifiying certificates that contain + a particular public key, per https://tools.ietf.org/html/rfc5280#section-4.2.1.2. + properties: + keyId: + type: string + x-dcl-go-name: KeyId + description: Optional. The value of this KeyId encoded in lowercase + hexadecimal. This is most likely the 160 bit SHA-1 hash of the + public key. + x509Description: + type: object + x-dcl-go-name: X509Description + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509Description + description: Describes some of the technical X.509 fields in a certificate. + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. Describes custom X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + required: + - objectId + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to + handle this extension, the client should consider this + to be an error). + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + description: Required. The OID for this X.509 extension. + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The + most significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + aiaOcspServers: + type: array + x-dcl-go-name: AiaOcspServers + readOnly: true + description: Optional. Describes Online Certificate Status Protocol + (OCSP) endpoint addresses that appear in the "Authority Information + Access" extension in the certificate. + x-kubernetes-immutable: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caOptions: + type: object + x-dcl-go-name: CaOptions + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + description: Optional. Describes options in this X509Parameters + that are relevant in a CA certificate. + properties: + isCa: + type: boolean + x-dcl-go-name: IsCa + description: Optional. Refers to the "CA" X.509 extension, + which is a boolean value. When this value is missing, the + extension will be omitted from the CA certificate. + maxIssuerPathLength: + type: integer + format: int64 + x-dcl-go-name: MaxIssuerPathLength + description: Optional. Refers to the path length restriction + X.509 extension. For a CA certificate, this value describes + the depth of subordinate CA certificates that are allowed. + If this value is less than 0, the request will fail. If + this value is missing, the max path length will be omitted + from the CA certificate. + keyUsage: + type: object + x-dcl-go-name: KeyUsage + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + description: Optional. Indicates the intended use for keys that + correspond to a certificate. + properties: + baseKeyUsage: + type: object + x-dcl-go-name: BaseKeyUsage + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + description: Describes high-level ways in which a key may + be used. + properties: + certSign: + type: boolean + x-dcl-go-name: CertSign + description: The key may be used to sign certificates. + contentCommitment: + type: boolean + x-dcl-go-name: ContentCommitment + description: The key may be used for cryptographic commitments. + Note that this may also be referred to as "non-repudiation". + crlSign: + type: boolean + x-dcl-go-name: CrlSign + description: The key may be used sign certificate revocation + lists. + dataEncipherment: + type: boolean + x-dcl-go-name: DataEncipherment + description: The key may be used to encipher data. + decipherOnly: + type: boolean + x-dcl-go-name: DecipherOnly + description: The key may be used to decipher only. + digitalSignature: + type: boolean + x-dcl-go-name: DigitalSignature + description: The key may be used for digital signatures. + encipherOnly: + type: boolean + x-dcl-go-name: EncipherOnly + description: The key may be used to encipher only. + keyAgreement: + type: boolean + x-dcl-go-name: KeyAgreement + description: The key may be used in a key agreement protocol. + keyEncipherment: + type: boolean + x-dcl-go-name: KeyEncipherment + description: The key may be used to encipher other keys. + extendedKeyUsage: + type: object + x-dcl-go-name: ExtendedKeyUsage + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + description: Detailed scenarios in which a key may be used. + properties: + clientAuth: + type: boolean + x-dcl-go-name: ClientAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially + described as "TLS WWW client authentication", though + regularly used for non-WWW TLS. + codeSigning: + type: boolean + x-dcl-go-name: CodeSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially + described as "Signing of downloadable executable code + client authentication". + emailProtection: + type: boolean + x-dcl-go-name: EmailProtection + description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially + described as "Email protection". + ocspSigning: + type: boolean + x-dcl-go-name: OcspSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially + described as "Signing OCSP responses". + serverAuth: + type: boolean + x-dcl-go-name: ServerAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially + described as "TLS WWW server authentication", though + regularly used for non-WWW TLS. + timeStamping: + type: boolean + x-dcl-go-name: TimeStamping + description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially + described as "Binding the hash of an object to a time". + unknownExtendedKeyUsages: + type: array + x-dcl-go-name: UnknownExtendedKeyUsages + description: Used to describe extended key usages that are + not listed in the KeyUsage.ExtendedKeyUsageOptions message. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The + most significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + policyIds: + type: array + x-dcl-go-name: PolicyIds + description: Optional. Describes the X.509 certificate policy + object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + caPool: + type: string + x-dcl-go-name: CaPool + description: The caPool for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Privateca/CaPool + field: name + parent: true + x-dcl-parameter: true + config: + type: object + x-dcl-go-name: Config + x-dcl-go-type: CertificateAuthorityConfig + description: Required. Immutable. The config used to create a self-signed + X.509 certificate or CSR. + x-kubernetes-immutable: true + required: + - subjectConfig + - x509Config + properties: + publicKey: + type: object + x-dcl-go-name: PublicKey + x-dcl-go-type: CertificateAuthorityConfigPublicKey + readOnly: true + description: Optional. The public key that corresponds to this config. + This is, for example, used when issuing Certificates, but not when + creating a self-signed CertificateAuthority or CertificateAuthority + CSR. + x-kubernetes-immutable: true + required: + - key + - format + properties: + format: + type: string + x-dcl-go-name: Format + x-dcl-go-type: CertificateAuthorityConfigPublicKeyFormatEnum + description: 'Required. The format of the public key. Possible values: + PEM' + x-kubernetes-immutable: true + enum: + - PEM + key: + type: string + x-dcl-go-name: Key + description: Required. A public key. The padding and encoding must + match with the `KeyFormat` value specified for the `format` field. + x-kubernetes-immutable: true + subjectConfig: + type: object + x-dcl-go-name: SubjectConfig + x-dcl-go-type: CertificateAuthorityConfigSubjectConfig + description: Required. Specifies some of the values in a certificate + that are related to the subject. + x-kubernetes-immutable: true + required: + - subject + properties: + subject: + type: object + x-dcl-go-name: Subject + x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubject + description: Required. Contains distinguished name fields such as + the common name, location and organization. + x-kubernetes-immutable: true + properties: + commonName: + type: string + x-dcl-go-name: CommonName + description: The "common name" of the subject. + x-kubernetes-immutable: true + countryCode: + type: string + x-dcl-go-name: CountryCode + description: The country code of the subject. + x-kubernetes-immutable: true + locality: + type: string + x-dcl-go-name: Locality + description: The locality or city of the subject. + x-kubernetes-immutable: true + organization: + type: string + x-dcl-go-name: Organization + description: The organization of the subject. + x-kubernetes-immutable: true + organizationalUnit: + type: string + x-dcl-go-name: OrganizationalUnit + description: The organizational_unit of the subject. + x-kubernetes-immutable: true + postalCode: + type: string + x-dcl-go-name: PostalCode + description: The postal code of the subject. + x-kubernetes-immutable: true + province: + type: string + x-dcl-go-name: Province + description: The province, territory, or regional state of the + subject. + x-kubernetes-immutable: true + streetAddress: + type: string + x-dcl-go-name: StreetAddress + description: The street address of the subject. + x-kubernetes-immutable: true + subjectAltName: + type: object + x-dcl-go-name: SubjectAltName + x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubjectAltName + description: Optional. The subject alternative name fields. + x-kubernetes-immutable: true + properties: + customSans: + type: array + x-dcl-go-name: CustomSans + description: Contains additional subject alternative name values. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + required: + - objectId + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to + handle this extension, the client should consider this + to be an error). + x-kubernetes-immutable: true + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + description: Required. The OID for this X.509 extension. + x-kubernetes-immutable: true + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The + most significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + x-kubernetes-immutable: true + dnsNames: + type: array + x-dcl-go-name: DnsNames + description: Contains only valid, fully-qualified host names. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + emailAddresses: + type: array + x-dcl-go-name: EmailAddresses + description: Contains only valid RFC 2822 E-mail addresses. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + ipAddresses: + type: array + x-dcl-go-name: IPAddresses + description: Contains only valid 32-bit IPv4 addresses or RFC + 4291 IPv6 addresses. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + uris: + type: array + x-dcl-go-name: Uris + description: Contains only valid RFC 3986 URIs. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + x509Config: + type: object + x-dcl-go-name: X509Config + x-dcl-go-type: CertificateAuthorityConfigX509Config + description: Required. Describes how some of the technical X.509 fields + in a certificate should be populated. + x-kubernetes-immutable: true + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. Describes custom X.509 extensions. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityConfigX509ConfigAdditionalExtensions + required: + - objectId + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to handle + this extension, the client should consider this to be an + error). + x-kubernetes-immutable: true + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + description: Required. The OID for this X.509 extension. + x-kubernetes-immutable: true + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + x-kubernetes-immutable: true + aiaOcspServers: + type: array + x-dcl-go-name: AiaOcspServers + readOnly: true + description: Optional. Describes Online Certificate Status Protocol + (OCSP) endpoint addresses that appear in the "Authority Information + Access" extension in the certificate. + x-kubernetes-immutable: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caOptions: + type: object + x-dcl-go-name: CaOptions + x-dcl-go-type: CertificateAuthorityConfigX509ConfigCaOptions + description: Optional. Describes options in this X509Parameters + that are relevant in a CA certificate. + x-kubernetes-immutable: true + properties: + isCa: + type: boolean + x-dcl-go-name: IsCa + description: Optional. Refers to the "CA" X.509 extension, which + is a boolean value. When this value is missing, the extension + will be omitted from the CA certificate. + x-kubernetes-immutable: true + maxIssuerPathLength: + type: integer + format: int64 + x-dcl-go-name: MaxIssuerPathLength + description: Optional. Refers to the path length restriction + X.509 extension. For a CA certificate, this value describes + the depth of subordinate CA certificates that are allowed. + If this value is less than 0, the request will fail. If this + value is missing, the max path length will be omitted from + the CA certificate. + x-kubernetes-immutable: true + zeroMaxIssuerPathLength: + type: boolean + x-dcl-go-name: ZeroMaxIssuerPathLength + description: Optional. When true, the "path length constraint" + in Basic Constraints extension will be set to 0. if both max_issuer_path_length + and zero_max_issuer_path_length are unset, the max path length + will be omitted from the CA certificate. + x-kubernetes-immutable: true + keyUsage: + type: object + x-dcl-go-name: KeyUsage + x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsage + description: Optional. Indicates the intended use for keys that + correspond to a certificate. + x-kubernetes-immutable: true + properties: + baseKeyUsage: + type: object + x-dcl-go-name: BaseKeyUsage + x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + description: Describes high-level ways in which a key may be + used. + x-kubernetes-immutable: true + properties: + certSign: + type: boolean + x-dcl-go-name: CertSign + description: The key may be used to sign certificates. + x-kubernetes-immutable: true + contentCommitment: + type: boolean + x-dcl-go-name: ContentCommitment + description: The key may be used for cryptographic commitments. + Note that this may also be referred to as "non-repudiation". + x-kubernetes-immutable: true + crlSign: + type: boolean + x-dcl-go-name: CrlSign + description: The key may be used sign certificate revocation + lists. + x-kubernetes-immutable: true + dataEncipherment: + type: boolean + x-dcl-go-name: DataEncipherment + description: The key may be used to encipher data. + x-kubernetes-immutable: true + decipherOnly: + type: boolean + x-dcl-go-name: DecipherOnly + description: The key may be used to decipher only. + x-kubernetes-immutable: true + digitalSignature: + type: boolean + x-dcl-go-name: DigitalSignature + description: The key may be used for digital signatures. + x-kubernetes-immutable: true + encipherOnly: + type: boolean + x-dcl-go-name: EncipherOnly + description: The key may be used to encipher only. + x-kubernetes-immutable: true + keyAgreement: + type: boolean + x-dcl-go-name: KeyAgreement + description: The key may be used in a key agreement protocol. + x-kubernetes-immutable: true + keyEncipherment: + type: boolean + x-dcl-go-name: KeyEncipherment + description: The key may be used to encipher other keys. + x-kubernetes-immutable: true + extendedKeyUsage: + type: object + x-dcl-go-name: ExtendedKeyUsage + x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + description: Detailed scenarios in which a key may be used. + x-kubernetes-immutable: true + properties: + clientAuth: + type: boolean + x-dcl-go-name: ClientAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially + described as "TLS WWW client authentication", though regularly + used for non-WWW TLS. + x-kubernetes-immutable: true + codeSigning: + type: boolean + x-dcl-go-name: CodeSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially + described as "Signing of downloadable executable code + client authentication". + x-kubernetes-immutable: true + emailProtection: + type: boolean + x-dcl-go-name: EmailProtection + description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially + described as "Email protection". + x-kubernetes-immutable: true + ocspSigning: + type: boolean + x-dcl-go-name: OcspSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially + described as "Signing OCSP responses". + x-kubernetes-immutable: true + serverAuth: + type: boolean + x-dcl-go-name: ServerAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially + described as "TLS WWW server authentication", though regularly + used for non-WWW TLS. + x-kubernetes-immutable: true + timeStamping: + type: boolean + x-dcl-go-name: TimeStamping + description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially + described as "Binding the hash of an object to a time". + x-kubernetes-immutable: true + unknownExtendedKeyUsages: + type: array + x-dcl-go-name: UnknownExtendedKeyUsages + description: Used to describe extended key usages that are not + listed in the KeyUsage.ExtendedKeyUsageOptions message. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + policyIds: + type: array + x-dcl-go-name: PolicyIds + description: Optional. Describes the X.509 certificate policy object + identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateAuthorityConfigX509ConfigPolicyIds + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time at which this CertificateAuthority was + created. + x-kubernetes-immutable: true + deleteTime: + type: string + format: date-time + x-dcl-go-name: DeleteTime + readOnly: true + description: Output only. The time at which this CertificateAuthority was + soft deleted, if it is in the DELETED state. + x-kubernetes-immutable: true + expireTime: + type: string + format: date-time + x-dcl-go-name: ExpireTime + readOnly: true + description: Output only. The time at which this CertificateAuthority will + be permanently purged, if it is in the DELETED state. + x-kubernetes-immutable: true + gcsBucket: + type: string + x-dcl-go-name: GcsBucket + description: Immutable. The name of a Cloud Storage bucket where this CertificateAuthority + will publish content, such as the CA certificate and CRLs. This must be + a bucket name, without any prefixes (such as `gs://`) or suffixes (such + as `.googleapis.com`). For example, to use a bucket named `my-bucket`, + you would simply specify `my-bucket`. If not specified, a managed bucket + will be created. + x-kubernetes-immutable: true + x-dcl-references: + - resource: Storage/Bucket + field: name + keySpec: + type: object + x-dcl-go-name: KeySpec + x-dcl-go-type: CertificateAuthorityKeySpec + description: Required. Immutable. Used when issuing certificates for this + CertificateAuthority. If this CertificateAuthority is a self-signed CertificateAuthority, + this key is also used to sign the self-signed CA certificate. Otherwise, + it is used to sign a CSR. + x-kubernetes-immutable: true + properties: + algorithm: + type: string + x-dcl-go-name: Algorithm + x-dcl-go-type: CertificateAuthorityKeySpecAlgorithmEnum + description: 'The algorithm to use for creating a managed Cloud KMS + key for a for a simplified experience. All managed keys will be have + their ProtectionLevel as `HSM`. Possible values: RSA_PSS_2048_SHA256, + RSA_PSS_3072_SHA256, RSA_PSS_4096_SHA256, RSA_PKCS1_2048_SHA256, RSA_PKCS1_3072_SHA256, + RSA_PKCS1_4096_SHA256, EC_P256_SHA256, EC_P384_SHA384' + x-kubernetes-immutable: true + x-dcl-conflicts: + - cloudKmsKeyVersion + enum: + - RSA_PSS_2048_SHA256 + - RSA_PSS_3072_SHA256 + - RSA_PSS_4096_SHA256 + - RSA_PKCS1_2048_SHA256 + - RSA_PKCS1_3072_SHA256 + - RSA_PKCS1_4096_SHA256 + - EC_P256_SHA256 + - EC_P384_SHA384 + cloudKmsKeyVersion: + type: string + x-dcl-go-name: CloudKmsKeyVersion + description: The resource name for an existing Cloud KMS CryptoKeyVersion + in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`. + This option enables full flexibility in the key's capabilities and + properties. + x-kubernetes-immutable: true + x-dcl-conflicts: + - algorithm + x-dcl-references: + - resource: Cloudkms/CryptoKeyVersion + field: name + labels: + type: object + additionalProperties: + type: string + x-dcl-go-name: Labels + description: Optional. Labels with user-defined metadata. + lifetime: + type: string + x-dcl-go-name: Lifetime + description: Required. The desired lifetime of the CA certificate. Used + to create the "not_before_time" and "not_after_time" fields inside an + X.509 certificate. + x-kubernetes-immutable: true + location: + type: string + x-dcl-go-name: Location + description: The location for the resource + x-kubernetes-immutable: true + x-dcl-parameter: true + name: + type: string + x-dcl-go-name: Name + description: The resource name for this CertificateAuthority in the format + `projects/*/locations/*/caPools/*/certificateAuthorities/*`. + x-kubernetes-immutable: true + x-dcl-has-long-form: true + pemCaCertificates: + type: array + x-dcl-go-name: PemCaCertificates + readOnly: true + description: Output only. This CertificateAuthority's certificate chain, + including the current CertificateAuthority's certificate. Ordered such + that the root issuer is the final element (consistent with RFC 5246). + For a self-signed CA, this will only list the current CertificateAuthority's + certificate. + x-kubernetes-immutable: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + project: + type: string + x-dcl-go-name: Project + description: The project for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-parameter: true + state: + type: string + x-dcl-go-name: State + x-dcl-go-type: CertificateAuthorityStateEnum + readOnly: true + description: 'Output only. The State for this CertificateAuthority. Possible + values: ENABLED, DISABLED, STAGED, AWAITING_USER_ACTIVATION, DELETED' + x-kubernetes-immutable: true + enum: + - ENABLED + - DISABLED + - STAGED + - AWAITING_USER_ACTIVATION + - DELETED + subordinateConfig: + type: object + x-dcl-go-name: SubordinateConfig + x-dcl-go-type: CertificateAuthoritySubordinateConfig + readOnly: true + description: Optional. If this is a subordinate CertificateAuthority, this + field will be set with the subordinate configuration, which describes + its issuers. This may be updated, but this CertificateAuthority must continue + to validate. + x-kubernetes-immutable: true + properties: + certificateAuthority: + type: string + x-dcl-go-name: CertificateAuthority + description: Required. This can refer to a CertificateAuthority in the + same project that was used to create a subordinate CertificateAuthority. + This field is used for information and usability purposes only. The + resource name is in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`. + x-kubernetes-immutable: true + x-dcl-conflicts: + - pemIssuerChain + x-dcl-references: + - resource: Privateca/CertificateAuthority + field: selfLink + pemIssuerChain: + type: object + x-dcl-go-name: PemIssuerChain + x-dcl-go-type: CertificateAuthoritySubordinateConfigPemIssuerChain + description: Required. Contains the PEM certificate chain for the issuers + of this CertificateAuthority, but not pem certificate for this CA + itself. + x-kubernetes-immutable: true + x-dcl-conflicts: + - certificateAuthority + required: + - pemCertificates + properties: + pemCertificates: + type: array + x-dcl-go-name: PemCertificates + description: Required. Expected to be in leaf-to-root order according + to RFC 5246. + x-kubernetes-immutable: true + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + tier: + type: string + x-dcl-go-name: Tier + x-dcl-go-type: CertificateAuthorityTierEnum + readOnly: true + description: 'Output only. The CaPool.Tier of the CaPool that includes this + CertificateAuthority. Possible values: ENTERPRISE, DEVOPS' + x-kubernetes-immutable: true + enum: + - ENTERPRISE + - DEVOPS + type: + type: string + x-dcl-go-name: Type + x-dcl-go-type: CertificateAuthorityTypeEnum + description: 'Required. Immutable. The Type of this CertificateAuthority. + Possible values: SELF_SIGNED, SUBORDINATE' + x-kubernetes-immutable: true + enum: + - SELF_SIGNED + - SUBORDINATE + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time at which this CertificateAuthority was + last updated. + x-kubernetes-immutable: true diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_internal.go new file mode 100644 index 00000000000..1c6700f8af1 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_internal.go @@ -0,0 +1,14320 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" +) + +func (r *CertificateAuthority) validate() error { + + if err := dcl.Required(r, "name"); err != nil { + return err + } + if err := dcl.Required(r, "type"); err != nil { + return err + } + if err := dcl.Required(r, "config"); err != nil { + return err + } + if err := dcl.Required(r, "lifetime"); err != nil { + return err + } + if err := dcl.Required(r, "keySpec"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Project, "Project"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Location, "Location"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.CaPool, "CaPool"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Config) { + if err := r.Config.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.KeySpec) { + if err := r.KeySpec.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubordinateConfig) { + if err := r.SubordinateConfig.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.AccessUrls) { + if err := r.AccessUrls.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfig) validate() error { + if err := dcl.Required(r, "subjectConfig"); err != nil { + return err + } + if err := dcl.Required(r, "x509Config"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.SubjectConfig) { + if err := r.SubjectConfig.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.X509Config) { + if err := r.X509Config.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PublicKey) { + if err := r.PublicKey.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfigSubjectConfig) validate() error { + if err := dcl.Required(r, "subject"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Subject) { + if err := r.Subject.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubjectAltName) { + if err := r.SubjectAltName.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfigSubjectConfigSubject) validate() error { + return nil +} +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltName) validate() error { + return nil +} +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityConfigX509Config) validate() error { + if !dcl.IsEmptyValueIndirect(r.KeyUsage) { + if err := r.KeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CaOptions) { + if err := r.CaOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfigX509ConfigKeyUsage) validate() error { + if !dcl.IsEmptyValueIndirect(r.BaseKeyUsage) { + if err := r.BaseKeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.ExtendedKeyUsage) { + if err := r.ExtendedKeyUsage.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) validate() error { + return nil +} +func (r *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) validate() error { + return nil +} +func (r *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityConfigX509ConfigCaOptions) validate() error { + return nil +} +func (r *CertificateAuthorityConfigX509ConfigPolicyIds) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityConfigPublicKey) validate() error { + if err := dcl.Required(r, "key"); err != nil { + return err + } + if err := dcl.Required(r, "format"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityKeySpec) validate() error { + if err := dcl.ValidateExactlyOneOfFieldsSet([]string{"CloudKmsKeyVersion", "Algorithm"}, r.CloudKmsKeyVersion, r.Algorithm); err != nil { + return err + } + return nil +} +func (r *CertificateAuthoritySubordinateConfig) validate() error { + if err := dcl.ValidateExactlyOneOfFieldsSet([]string{"CertificateAuthority", "PemIssuerChain"}, r.CertificateAuthority, r.PemIssuerChain); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.PemIssuerChain) { + if err := r.PemIssuerChain.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthoritySubordinateConfigPemIssuerChain) validate() error { + if err := dcl.Required(r, "pemCertificates"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptions) validate() error { + if !dcl.IsEmptyValueIndirect(r.SubjectDescription) { + if err := r.SubjectDescription.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.X509Description) { + if err := r.X509Description.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PublicKey) { + if err := r.PublicKey.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubjectKeyId) { + if err := r.SubjectKeyId.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.AuthorityKeyId) { + if err := r.AuthorityKeyId.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CertFingerprint) { + if err := r.CertFingerprint.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) validate() error { + if !dcl.IsEmptyValueIndirect(r.Subject) { + if err := r.Subject.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubjectAltName) { + if err := r.SubjectAltName.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "critical"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509Description) validate() error { + if !dcl.IsEmptyValueIndirect(r.KeyUsage) { + if err := r.KeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CaOptions) { + if err := r.CaOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) validate() error { + if !dcl.IsEmptyValueIndirect(r.BaseKeyUsage) { + if err := r.BaseKeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.ExtendedKeyUsage) { + if err := r.ExtendedKeyUsage.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsPublicKey) validate() error { + if err := dcl.Required(r, "key"); err != nil { + return err + } + if err := dcl.Required(r, "format"); err != nil { + return err + } + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) validate() error { + return nil +} +func (r *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) validate() error { + return nil +} +func (r *CertificateAuthorityAccessUrls) validate() error { + return nil +} +func (r *CertificateAuthority) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://privateca.googleapis.com/v1/", params) +} + +func (r *CertificateAuthority) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificateAuthorities/{{name}}", nr.basePath(), userBasePath, params), nil +} + +func (r *CertificateAuthority) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificateAuthorities", nr.basePath(), userBasePath, params), nil + +} + +func (r *CertificateAuthority) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificateAuthorities?certificateAuthorityId={{name}}", nr.basePath(), userBasePath, params), nil + +} + +func (r *CertificateAuthority) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificateAuthorities/{{name}}?ignoreActiveCertificates=true", nr.basePath(), userBasePath, params), nil +} + +// certificateAuthorityApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type certificateAuthorityApiOperation interface { + do(context.Context, *CertificateAuthority, *Client) error +} + +// newUpdateCertificateAuthorityUpdateCertificateAuthorityRequest creates a request for an +// CertificateAuthority resource's UpdateCertificateAuthority update type by filling in the update +// fields based on the intended state of the resource. +func newUpdateCertificateAuthorityUpdateCertificateAuthorityRequest(ctx context.Context, f *CertificateAuthority, c *Client) (map[string]interface{}, error) { + req := map[string]interface{}{} + res := f + _ = res + + if v := f.Labels; !dcl.IsEmptyValueIndirect(v) { + req["labels"] = v + } + return req, nil +} + +// marshalUpdateCertificateAuthorityUpdateCertificateAuthorityRequest converts the update into +// the final JSON request body. +func marshalUpdateCertificateAuthorityUpdateCertificateAuthorityRequest(c *Client, m map[string]interface{}) ([]byte, error) { + + return json.Marshal(m) +} + +type updateCertificateAuthorityUpdateCertificateAuthorityOperation struct { + // If the update operation has the REQUIRES_APPLY_OPTIONS trait, this will be populated. + // Usually it will be nil - this is to prevent us from accidentally depending on apply + // options, which should usually be unnecessary. + ApplyOptions []dcl.ApplyOption + FieldDiffs []*dcl.FieldDiff +} + +// do creates a request and sends it to the appropriate URL. In most operations, +// do will transcribe a subset of the resource into a request object and send a +// PUT request to a single URL. + +func (op *updateCertificateAuthorityUpdateCertificateAuthorityOperation) do(ctx context.Context, r *CertificateAuthority, c *Client) error { + _, err := c.GetCertificateAuthority(ctx, r) + if err != nil { + return err + } + + u, err := r.updateURL(c.Config.BasePath, "UpdateCertificateAuthority") + if err != nil { + return err + } + mask := dcl.UpdateMask(op.FieldDiffs) + u, err = dcl.AddQueryParams(u, map[string]string{"updateMask": mask}) + if err != nil { + return err + } + + req, err := newUpdateCertificateAuthorityUpdateCertificateAuthorityRequest(ctx, r, c) + if err != nil { + return err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created update: %#v", req) + body, err := marshalUpdateCertificateAuthorityUpdateCertificateAuthorityRequest(c, req) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "PATCH", u, bytes.NewBuffer(body), c.Config.RetryProvider) + if err != nil { + return err + } + + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + err = o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET") + + if err != nil { + return err + } + + return nil +} + +func (c *Client) listCertificateAuthorityRaw(ctx context.Context, r *CertificateAuthority, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != CertificateAuthorityMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listCertificateAuthorityOperation struct { + CertificateAuthorities []map[string]interface{} `json:"certificateAuthorities"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listCertificateAuthority(ctx context.Context, r *CertificateAuthority, pageToken string, pageSize int32) ([]*CertificateAuthority, string, error) { + b, err := c.listCertificateAuthorityRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listCertificateAuthorityOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*CertificateAuthority + for _, v := range m.CertificateAuthorities { + res, err := unmarshalMapCertificateAuthority(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Project = r.Project + res.Location = r.Location + res.CaPool = r.CaPool + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllCertificateAuthority(ctx context.Context, f func(*CertificateAuthority) bool, resources []*CertificateAuthority) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeleteCertificateAuthority(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deleteCertificateAuthorityOperation struct{} + +func (op *deleteCertificateAuthorityOperation) do(ctx context.Context, r *CertificateAuthority, c *Client) error { + r, err := c.GetCertificateAuthority(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "CertificateAuthority not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetCertificateAuthority checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + resp, err := dcl.SendRequest(ctx, c.Config, "DELETE", u, body, c.Config.RetryProvider) + if err != nil { + return err + } + + // wait for object to be deleted. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET"); err != nil { + return err + } + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createCertificateAuthorityOperation struct { + response map[string]interface{} +} + +func (op *createCertificateAuthorityOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createCertificateAuthorityOperation) do(ctx context.Context, r *CertificateAuthority, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + // wait for object to be created. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET"); err != nil { + c.Config.Logger.Warningf("Creation failed after waiting for operation: %v", err) + return err + } + c.Config.Logger.InfoWithContextf(ctx, "Successfully waited for operation") + op.response, _ = o.FirstResponse() + + if _, err := c.GetCertificateAuthority(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + err = r.waitForCertificateAuthorityEnabled(ctx, c) + if err != nil { + return err + } + + return nil +} + +func (c *Client) getCertificateAuthorityRaw(ctx context.Context, r *CertificateAuthority) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + return b, nil +} + +func (c *Client) certificateAuthorityDiffsForRawDesired(ctx context.Context, rawDesired *CertificateAuthority, opts ...dcl.ApplyOption) (initial, desired *CertificateAuthority, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *CertificateAuthority + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*CertificateAuthority); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected CertificateAuthority, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetCertificateAuthority(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a CertificateAuthority resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve CertificateAuthority resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that CertificateAuthority resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizeCertificateAuthorityDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for CertificateAuthority: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for CertificateAuthority: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractCertificateAuthorityFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizeCertificateAuthorityInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for CertificateAuthority: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizeCertificateAuthorityDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for CertificateAuthority: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffCertificateAuthority(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizeCertificateAuthorityInitialState(rawInitial, rawDesired *CertificateAuthority) (*CertificateAuthority, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizeCertificateAuthorityDesiredState(rawDesired, rawInitial *CertificateAuthority, opts ...dcl.ApplyOption) (*CertificateAuthority, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + rawDesired.Config = canonicalizeCertificateAuthorityConfig(rawDesired.Config, nil, opts...) + rawDesired.KeySpec = canonicalizeCertificateAuthorityKeySpec(rawDesired.KeySpec, nil, opts...) + rawDesired.SubordinateConfig = canonicalizeCertificateAuthoritySubordinateConfig(rawDesired.SubordinateConfig, nil, opts...) + rawDesired.AccessUrls = canonicalizeCertificateAuthorityAccessUrls(rawDesired.AccessUrls, nil, opts...) + + return rawDesired, nil + } + canonicalDesired := &CertificateAuthority{} + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawInitial.Name) { + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + if dcl.IsZeroValue(rawDesired.Type) || (dcl.IsEmptyValueIndirect(rawDesired.Type) && dcl.IsEmptyValueIndirect(rawInitial.Type)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Type = rawInitial.Type + } else { + canonicalDesired.Type = rawDesired.Type + } + canonicalDesired.Config = canonicalizeCertificateAuthorityConfig(rawDesired.Config, rawInitial.Config, opts...) + if dcl.StringCanonicalize(rawDesired.Lifetime, rawInitial.Lifetime) { + canonicalDesired.Lifetime = rawInitial.Lifetime + } else { + canonicalDesired.Lifetime = rawDesired.Lifetime + } + canonicalDesired.KeySpec = canonicalizeCertificateAuthorityKeySpec(rawDesired.KeySpec, rawInitial.KeySpec, opts...) + if dcl.IsZeroValue(rawDesired.GcsBucket) || (dcl.IsEmptyValueIndirect(rawDesired.GcsBucket) && dcl.IsEmptyValueIndirect(rawInitial.GcsBucket)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.GcsBucket = rawInitial.GcsBucket + } else { + canonicalDesired.GcsBucket = rawDesired.GcsBucket + } + if dcl.IsZeroValue(rawDesired.Labels) || (dcl.IsEmptyValueIndirect(rawDesired.Labels) && dcl.IsEmptyValueIndirect(rawInitial.Labels)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Labels = rawInitial.Labels + } else { + canonicalDesired.Labels = rawDesired.Labels + } + if dcl.NameToSelfLink(rawDesired.Project, rawInitial.Project) { + canonicalDesired.Project = rawInitial.Project + } else { + canonicalDesired.Project = rawDesired.Project + } + if dcl.NameToSelfLink(rawDesired.Location, rawInitial.Location) { + canonicalDesired.Location = rawInitial.Location + } else { + canonicalDesired.Location = rawDesired.Location + } + if dcl.NameToSelfLink(rawDesired.CaPool, rawInitial.CaPool) { + canonicalDesired.CaPool = rawInitial.CaPool + } else { + canonicalDesired.CaPool = rawDesired.CaPool + } + return canonicalDesired, nil +} + +func canonicalizeCertificateAuthorityNewState(c *Client, rawNew, rawDesired *CertificateAuthority) (*CertificateAuthority, error) { + + if dcl.IsEmptyValueIndirect(rawNew.Name) && dcl.IsEmptyValueIndirect(rawDesired.Name) { + rawNew.Name = rawDesired.Name + } else { + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawNew.Name) { + rawNew.Name = rawDesired.Name + } + } + + if dcl.IsEmptyValueIndirect(rawNew.Type) && dcl.IsEmptyValueIndirect(rawDesired.Type) { + rawNew.Type = rawDesired.Type + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.Config) && dcl.IsEmptyValueIndirect(rawDesired.Config) { + rawNew.Config = rawDesired.Config + } else { + rawNew.Config = canonicalizeNewCertificateAuthorityConfig(c, rawDesired.Config, rawNew.Config) + } + + if dcl.IsEmptyValueIndirect(rawNew.Lifetime) && dcl.IsEmptyValueIndirect(rawDesired.Lifetime) { + rawNew.Lifetime = rawDesired.Lifetime + } else { + if dcl.StringCanonicalize(rawDesired.Lifetime, rawNew.Lifetime) { + rawNew.Lifetime = rawDesired.Lifetime + } + } + + if dcl.IsEmptyValueIndirect(rawNew.KeySpec) && dcl.IsEmptyValueIndirect(rawDesired.KeySpec) { + rawNew.KeySpec = rawDesired.KeySpec + } else { + rawNew.KeySpec = canonicalizeNewCertificateAuthorityKeySpec(c, rawDesired.KeySpec, rawNew.KeySpec) + } + + if dcl.IsEmptyValueIndirect(rawNew.SubordinateConfig) && dcl.IsEmptyValueIndirect(rawDesired.SubordinateConfig) { + rawNew.SubordinateConfig = rawDesired.SubordinateConfig + } else { + rawNew.SubordinateConfig = canonicalizeNewCertificateAuthoritySubordinateConfig(c, rawDesired.SubordinateConfig, rawNew.SubordinateConfig) + } + + if dcl.IsEmptyValueIndirect(rawNew.Tier) && dcl.IsEmptyValueIndirect(rawDesired.Tier) { + rawNew.Tier = rawDesired.Tier + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.State) && dcl.IsEmptyValueIndirect(rawDesired.State) { + rawNew.State = rawDesired.State + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.PemCaCertificates) && dcl.IsEmptyValueIndirect(rawDesired.PemCaCertificates) { + rawNew.PemCaCertificates = rawDesired.PemCaCertificates + } else { + if dcl.StringArrayCanonicalize(rawDesired.PemCaCertificates, rawNew.PemCaCertificates) { + rawNew.PemCaCertificates = rawDesired.PemCaCertificates + } + } + + if dcl.IsEmptyValueIndirect(rawNew.CaCertificateDescriptions) && dcl.IsEmptyValueIndirect(rawDesired.CaCertificateDescriptions) { + rawNew.CaCertificateDescriptions = rawDesired.CaCertificateDescriptions + } else { + rawNew.CaCertificateDescriptions = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSlice(c, rawDesired.CaCertificateDescriptions, rawNew.CaCertificateDescriptions) + } + + if dcl.IsEmptyValueIndirect(rawNew.GcsBucket) && dcl.IsEmptyValueIndirect(rawDesired.GcsBucket) { + rawNew.GcsBucket = rawDesired.GcsBucket + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.AccessUrls) && dcl.IsEmptyValueIndirect(rawDesired.AccessUrls) { + rawNew.AccessUrls = rawDesired.AccessUrls + } else { + rawNew.AccessUrls = canonicalizeNewCertificateAuthorityAccessUrls(c, rawDesired.AccessUrls, rawNew.AccessUrls) + } + + if dcl.IsEmptyValueIndirect(rawNew.CreateTime) && dcl.IsEmptyValueIndirect(rawDesired.CreateTime) { + rawNew.CreateTime = rawDesired.CreateTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.UpdateTime) && dcl.IsEmptyValueIndirect(rawDesired.UpdateTime) { + rawNew.UpdateTime = rawDesired.UpdateTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.DeleteTime) && dcl.IsEmptyValueIndirect(rawDesired.DeleteTime) { + rawNew.DeleteTime = rawDesired.DeleteTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.ExpireTime) && dcl.IsEmptyValueIndirect(rawDesired.ExpireTime) { + rawNew.ExpireTime = rawDesired.ExpireTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.Labels) && dcl.IsEmptyValueIndirect(rawDesired.Labels) { + rawNew.Labels = rawDesired.Labels + } else { + } + + rawNew.Project = rawDesired.Project + + rawNew.Location = rawDesired.Location + + rawNew.CaPool = rawDesired.CaPool + + return rawNew, nil +} + +func canonicalizeCertificateAuthorityConfig(des, initial *CertificateAuthorityConfig, opts ...dcl.ApplyOption) *CertificateAuthorityConfig { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfig{} + + cDes.SubjectConfig = canonicalizeCertificateAuthorityConfigSubjectConfig(des.SubjectConfig, initial.SubjectConfig, opts...) + cDes.X509Config = canonicalizeCertificateAuthorityConfigX509Config(des.X509Config, initial.X509Config, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityConfigSlice(des, initial []CertificateAuthorityConfig, opts ...dcl.ApplyOption) []CertificateAuthorityConfig { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfig, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfig(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfig, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfig(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfig(c *Client, des, nw *CertificateAuthorityConfig) *CertificateAuthorityConfig { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfig while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.SubjectConfig = canonicalizeNewCertificateAuthorityConfigSubjectConfig(c, des.SubjectConfig, nw.SubjectConfig) + nw.X509Config = canonicalizeNewCertificateAuthorityConfigX509Config(c, des.X509Config, nw.X509Config) + nw.PublicKey = canonicalizeNewCertificateAuthorityConfigPublicKey(c, des.PublicKey, nw.PublicKey) + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigSet(c *Client, des, nw []CertificateAuthorityConfig) []CertificateAuthorityConfig { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfig + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfig(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigSlice(c *Client, des, nw []CertificateAuthorityConfig) []CertificateAuthorityConfig { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfig + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfig(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigSubjectConfig(des, initial *CertificateAuthorityConfigSubjectConfig, opts ...dcl.ApplyOption) *CertificateAuthorityConfigSubjectConfig { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigSubjectConfig{} + + cDes.Subject = canonicalizeCertificateAuthorityConfigSubjectConfigSubject(des.Subject, initial.Subject, opts...) + cDes.SubjectAltName = canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltName(des.SubjectAltName, initial.SubjectAltName, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSlice(des, initial []CertificateAuthorityConfigSubjectConfig, opts ...dcl.ApplyOption) []CertificateAuthorityConfigSubjectConfig { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigSubjectConfig, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfig(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigSubjectConfig, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfig(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfig(c *Client, des, nw *CertificateAuthorityConfigSubjectConfig) *CertificateAuthorityConfigSubjectConfig { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigSubjectConfig while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Subject = canonicalizeNewCertificateAuthorityConfigSubjectConfigSubject(c, des.Subject, nw.Subject) + nw.SubjectAltName = canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltName(c, des.SubjectAltName, nw.SubjectAltName) + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSet(c *Client, des, nw []CertificateAuthorityConfigSubjectConfig) []CertificateAuthorityConfigSubjectConfig { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigSubjectConfig + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigSubjectConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfig(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSlice(c *Client, des, nw []CertificateAuthorityConfigSubjectConfig) []CertificateAuthorityConfigSubjectConfig { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigSubjectConfig + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfig(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubject(des, initial *CertificateAuthorityConfigSubjectConfigSubject, opts ...dcl.ApplyOption) *CertificateAuthorityConfigSubjectConfigSubject { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigSubjectConfigSubject{} + + if dcl.StringCanonicalize(des.CommonName, initial.CommonName) || dcl.IsZeroValue(des.CommonName) { + cDes.CommonName = initial.CommonName + } else { + cDes.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, initial.CountryCode) || dcl.IsZeroValue(des.CountryCode) { + cDes.CountryCode = initial.CountryCode + } else { + cDes.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, initial.Organization) || dcl.IsZeroValue(des.Organization) { + cDes.Organization = initial.Organization + } else { + cDes.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, initial.OrganizationalUnit) || dcl.IsZeroValue(des.OrganizationalUnit) { + cDes.OrganizationalUnit = initial.OrganizationalUnit + } else { + cDes.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, initial.Locality) || dcl.IsZeroValue(des.Locality) { + cDes.Locality = initial.Locality + } else { + cDes.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, initial.Province) || dcl.IsZeroValue(des.Province) { + cDes.Province = initial.Province + } else { + cDes.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, initial.StreetAddress) || dcl.IsZeroValue(des.StreetAddress) { + cDes.StreetAddress = initial.StreetAddress + } else { + cDes.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, initial.PostalCode) || dcl.IsZeroValue(des.PostalCode) { + cDes.PostalCode = initial.PostalCode + } else { + cDes.PostalCode = des.PostalCode + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectSlice(des, initial []CertificateAuthorityConfigSubjectConfigSubject, opts ...dcl.ApplyOption) []CertificateAuthorityConfigSubjectConfigSubject { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigSubjectConfigSubject, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubject(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubject, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubject(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubject(c *Client, des, nw *CertificateAuthorityConfigSubjectConfigSubject) *CertificateAuthorityConfigSubjectConfigSubject { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigSubjectConfigSubject while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.CommonName, nw.CommonName) { + nw.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, nw.CountryCode) { + nw.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, nw.Organization) { + nw.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, nw.OrganizationalUnit) { + nw.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, nw.Locality) { + nw.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, nw.Province) { + nw.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, nw.StreetAddress) { + nw.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, nw.PostalCode) { + nw.PostalCode = des.PostalCode + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectSet(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubject) []CertificateAuthorityConfigSubjectConfigSubject { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigSubjectConfigSubject + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigSubjectConfigSubjectNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubject(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectSlice(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubject) []CertificateAuthorityConfigSubjectConfigSubject { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigSubjectConfigSubject + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubject(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltName(des, initial *CertificateAuthorityConfigSubjectConfigSubjectAltName, opts ...dcl.ApplyOption) *CertificateAuthorityConfigSubjectConfigSubjectAltName { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigSubjectConfigSubjectAltName{} + + if dcl.StringArrayCanonicalize(des.DnsNames, initial.DnsNames) { + cDes.DnsNames = initial.DnsNames + } else { + cDes.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, initial.Uris) { + cDes.Uris = initial.Uris + } else { + cDes.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, initial.EmailAddresses) { + cDes.EmailAddresses = initial.EmailAddresses + } else { + cDes.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, initial.IPAddresses) { + cDes.IPAddresses = initial.IPAddresses + } else { + cDes.IPAddresses = des.IPAddresses + } + cDes.CustomSans = canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(des.CustomSans, initial.CustomSans, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameSlice(des, initial []CertificateAuthorityConfigSubjectConfigSubjectAltName, opts ...dcl.ApplyOption) []CertificateAuthorityConfigSubjectConfigSubjectAltName { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltName, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltName(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltName, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltName(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltName(c *Client, des, nw *CertificateAuthorityConfigSubjectConfigSubjectAltName) *CertificateAuthorityConfigSubjectConfigSubjectAltName { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigSubjectConfigSubjectAltName while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DnsNames, nw.DnsNames) { + nw.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, nw.Uris) { + nw.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, nw.EmailAddresses) { + nw.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, nw.IPAddresses) { + nw.IPAddresses = des.IPAddresses + } + nw.CustomSans = canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(c, des.CustomSans, nw.CustomSans) + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameSet(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubjectAltName) []CertificateAuthorityConfigSubjectConfigSubjectAltName { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigSubjectConfigSubjectAltName + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigSubjectConfigSubjectAltNameNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltName(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameSlice(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubjectAltName) []CertificateAuthorityConfigSubjectConfigSubjectAltName { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigSubjectConfigSubjectAltName + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltName(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(des, initial *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, opts ...dcl.ApplyOption) *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{} + + cDes.ObjectId = canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(des, initial []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, opts ...dcl.ApplyOption) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c *Client, des, nw *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSet(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(des, initial *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, opts ...dcl.ApplyOption) *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSlice(des, initial []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, opts ...dcl.ApplyOption) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c *Client, des, nw *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSet(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSlice(c *Client, des, nw []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509Config(des, initial *CertificateAuthorityConfigX509Config, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509Config { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509Config{} + + cDes.KeyUsage = canonicalizeCertificateAuthorityConfigX509ConfigKeyUsage(des.KeyUsage, initial.KeyUsage, opts...) + cDes.CaOptions = canonicalizeCertificateAuthorityConfigX509ConfigCaOptions(des.CaOptions, initial.CaOptions, opts...) + cDes.PolicyIds = canonicalizeCertificateAuthorityConfigX509ConfigPolicyIdsSlice(des.PolicyIds, initial.PolicyIds, opts...) + cDes.AdditionalExtensions = canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigSlice(des, initial []CertificateAuthorityConfigX509Config, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509Config { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509Config, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509Config(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509Config, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509Config(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509Config(c *Client, des, nw *CertificateAuthorityConfigX509Config) *CertificateAuthorityConfigX509Config { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509Config while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.KeyUsage = canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsage(c, des.KeyUsage, nw.KeyUsage) + nw.CaOptions = canonicalizeNewCertificateAuthorityConfigX509ConfigCaOptions(c, des.CaOptions, nw.CaOptions) + nw.PolicyIds = canonicalizeNewCertificateAuthorityConfigX509ConfigPolicyIdsSlice(c, des.PolicyIds, nw.PolicyIds) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, nw.AiaOcspServers) { + nw.AiaOcspServers = des.AiaOcspServers + } + nw.AdditionalExtensions = canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigSet(c *Client, des, nw []CertificateAuthorityConfigX509Config) []CertificateAuthorityConfigX509Config { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509Config + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509Config(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigSlice(c *Client, des, nw []CertificateAuthorityConfigX509Config) []CertificateAuthorityConfigX509Config { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509Config + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509Config(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsage(des, initial *CertificateAuthorityConfigX509ConfigKeyUsage, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigKeyUsage{} + + cDes.BaseKeyUsage = canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(des.BaseKeyUsage, initial.BaseKeyUsage, opts...) + cDes.ExtendedKeyUsage = canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(des.ExtendedKeyUsage, initial.ExtendedKeyUsage, opts...) + cDes.UnknownExtendedKeyUsages = canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(des.UnknownExtendedKeyUsages, initial.UnknownExtendedKeyUsages, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageSlice(des, initial []CertificateAuthorityConfigX509ConfigKeyUsage, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsage(c *Client, des, nw *CertificateAuthorityConfigX509ConfigKeyUsage) *CertificateAuthorityConfigX509ConfigKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.BaseKeyUsage = canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, des.BaseKeyUsage, nw.BaseKeyUsage) + nw.ExtendedKeyUsage = canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, des.ExtendedKeyUsage, nw.ExtendedKeyUsage) + nw.UnknownExtendedKeyUsages = canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c, des.UnknownExtendedKeyUsages, nw.UnknownExtendedKeyUsages) + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsage) []CertificateAuthorityConfigX509ConfigKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsage) []CertificateAuthorityConfigX509ConfigKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(des, initial *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + + if dcl.BoolCanonicalize(des.DigitalSignature, initial.DigitalSignature) || dcl.IsZeroValue(des.DigitalSignature) { + cDes.DigitalSignature = initial.DigitalSignature + } else { + cDes.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, initial.ContentCommitment) || dcl.IsZeroValue(des.ContentCommitment) { + cDes.ContentCommitment = initial.ContentCommitment + } else { + cDes.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, initial.KeyEncipherment) || dcl.IsZeroValue(des.KeyEncipherment) { + cDes.KeyEncipherment = initial.KeyEncipherment + } else { + cDes.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, initial.DataEncipherment) || dcl.IsZeroValue(des.DataEncipherment) { + cDes.DataEncipherment = initial.DataEncipherment + } else { + cDes.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, initial.KeyAgreement) || dcl.IsZeroValue(des.KeyAgreement) { + cDes.KeyAgreement = initial.KeyAgreement + } else { + cDes.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, initial.CertSign) || dcl.IsZeroValue(des.CertSign) { + cDes.CertSign = initial.CertSign + } else { + cDes.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, initial.CrlSign) || dcl.IsZeroValue(des.CrlSign) { + cDes.CrlSign = initial.CrlSign + } else { + cDes.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, initial.EncipherOnly) || dcl.IsZeroValue(des.EncipherOnly) { + cDes.EncipherOnly = initial.EncipherOnly + } else { + cDes.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, initial.DecipherOnly) || dcl.IsZeroValue(des.DecipherOnly) { + cDes.DecipherOnly = initial.DecipherOnly + } else { + cDes.DecipherOnly = des.DecipherOnly + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSlice(des, initial []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c *Client, des, nw *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.DigitalSignature, nw.DigitalSignature) { + nw.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, nw.ContentCommitment) { + nw.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, nw.KeyEncipherment) { + nw.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, nw.DataEncipherment) { + nw.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, nw.KeyAgreement) { + nw.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, nw.CertSign) { + nw.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, nw.CrlSign) { + nw.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, nw.EncipherOnly) { + nw.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, nw.DecipherOnly) { + nw.DecipherOnly = des.DecipherOnly + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(des, initial *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + + if dcl.BoolCanonicalize(des.ServerAuth, initial.ServerAuth) || dcl.IsZeroValue(des.ServerAuth) { + cDes.ServerAuth = initial.ServerAuth + } else { + cDes.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, initial.ClientAuth) || dcl.IsZeroValue(des.ClientAuth) { + cDes.ClientAuth = initial.ClientAuth + } else { + cDes.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, initial.CodeSigning) || dcl.IsZeroValue(des.CodeSigning) { + cDes.CodeSigning = initial.CodeSigning + } else { + cDes.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, initial.EmailProtection) || dcl.IsZeroValue(des.EmailProtection) { + cDes.EmailProtection = initial.EmailProtection + } else { + cDes.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, initial.TimeStamping) || dcl.IsZeroValue(des.TimeStamping) { + cDes.TimeStamping = initial.TimeStamping + } else { + cDes.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, initial.OcspSigning) || dcl.IsZeroValue(des.OcspSigning) { + cDes.OcspSigning = initial.OcspSigning + } else { + cDes.OcspSigning = des.OcspSigning + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSlice(des, initial []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c *Client, des, nw *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.ServerAuth, nw.ServerAuth) { + nw.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, nw.ClientAuth) { + nw.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, nw.CodeSigning) { + nw.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, nw.EmailProtection) { + nw.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, nw.TimeStamping) { + nw.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, nw.OcspSigning) { + nw.OcspSigning = des.OcspSigning + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(des, initial *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(des, initial []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c *Client, des, nw *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigCaOptions(des, initial *CertificateAuthorityConfigX509ConfigCaOptions, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigCaOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigCaOptions{} + + if dcl.BoolCanonicalize(des.IsCa, initial.IsCa) || dcl.IsZeroValue(des.IsCa) { + cDes.IsCa = initial.IsCa + } else { + cDes.IsCa = des.IsCa + } + if dcl.IsZeroValue(des.MaxIssuerPathLength) || (dcl.IsEmptyValueIndirect(des.MaxIssuerPathLength) && dcl.IsEmptyValueIndirect(initial.MaxIssuerPathLength)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxIssuerPathLength = initial.MaxIssuerPathLength + } else { + cDes.MaxIssuerPathLength = des.MaxIssuerPathLength + } + if dcl.BoolCanonicalize(des.ZeroMaxIssuerPathLength, initial.ZeroMaxIssuerPathLength) || dcl.IsZeroValue(des.ZeroMaxIssuerPathLength) { + cDes.ZeroMaxIssuerPathLength = initial.ZeroMaxIssuerPathLength + } else { + cDes.ZeroMaxIssuerPathLength = des.ZeroMaxIssuerPathLength + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigCaOptionsSlice(des, initial []CertificateAuthorityConfigX509ConfigCaOptions, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigCaOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigCaOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigCaOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigCaOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigCaOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigCaOptions(c *Client, des, nw *CertificateAuthorityConfigX509ConfigCaOptions) *CertificateAuthorityConfigX509ConfigCaOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigCaOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.IsCa, nw.IsCa) { + nw.IsCa = des.IsCa + } + if dcl.BoolCanonicalize(des.ZeroMaxIssuerPathLength, nw.ZeroMaxIssuerPathLength) { + nw.ZeroMaxIssuerPathLength = des.ZeroMaxIssuerPathLength + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigCaOptionsSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigCaOptions) []CertificateAuthorityConfigX509ConfigCaOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigCaOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigCaOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigCaOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigCaOptionsSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigCaOptions) []CertificateAuthorityConfigX509ConfigCaOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigCaOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigCaOptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigPolicyIds(des, initial *CertificateAuthorityConfigX509ConfigPolicyIds, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigPolicyIds { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigPolicyIds{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigPolicyIdsSlice(des, initial []CertificateAuthorityConfigX509ConfigPolicyIds, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigPolicyIds { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigPolicyIds, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigPolicyIds(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigPolicyIds, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigPolicyIds(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigPolicyIds(c *Client, des, nw *CertificateAuthorityConfigX509ConfigPolicyIds) *CertificateAuthorityConfigX509ConfigPolicyIds { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigPolicyIds while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigPolicyIdsSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigPolicyIds) []CertificateAuthorityConfigX509ConfigPolicyIds { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigPolicyIds + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigPolicyIdsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigPolicyIds(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigPolicyIdsSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigPolicyIds) []CertificateAuthorityConfigX509ConfigPolicyIds { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigPolicyIds + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigPolicyIds(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensions(des, initial *CertificateAuthorityConfigX509ConfigAdditionalExtensions, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigAdditionalExtensions{} + + cDes.ObjectId = canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(des, initial []CertificateAuthorityConfigX509ConfigAdditionalExtensions, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensions(c *Client, des, nw *CertificateAuthorityConfigX509ConfigAdditionalExtensions) *CertificateAuthorityConfigX509ConfigAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigAdditionalExtensions) []CertificateAuthorityConfigX509ConfigAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigAdditionalExtensions) []CertificateAuthorityConfigX509ConfigAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(des, initial *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSlice(des, initial []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c *Client, des, nw *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSet(c *Client, des, nw []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSlice(c *Client, des, nw []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityConfigPublicKey(des, initial *CertificateAuthorityConfigPublicKey, opts ...dcl.ApplyOption) *CertificateAuthorityConfigPublicKey { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityConfigPublicKey{} + + if dcl.StringCanonicalize(des.Key, initial.Key) || dcl.IsZeroValue(des.Key) { + cDes.Key = initial.Key + } else { + cDes.Key = des.Key + } + if dcl.IsZeroValue(des.Format) || (dcl.IsEmptyValueIndirect(des.Format) && dcl.IsEmptyValueIndirect(initial.Format)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Format = initial.Format + } else { + cDes.Format = des.Format + } + + return cDes +} + +func canonicalizeCertificateAuthorityConfigPublicKeySlice(des, initial []CertificateAuthorityConfigPublicKey, opts ...dcl.ApplyOption) []CertificateAuthorityConfigPublicKey { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityConfigPublicKey, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityConfigPublicKey(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityConfigPublicKey, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityConfigPublicKey(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityConfigPublicKey(c *Client, des, nw *CertificateAuthorityConfigPublicKey) *CertificateAuthorityConfigPublicKey { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityConfigPublicKey while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Key, nw.Key) { + nw.Key = des.Key + } + + return nw +} + +func canonicalizeNewCertificateAuthorityConfigPublicKeySet(c *Client, des, nw []CertificateAuthorityConfigPublicKey) []CertificateAuthorityConfigPublicKey { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityConfigPublicKey + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityConfigPublicKeyNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityConfigPublicKey(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityConfigPublicKeySlice(c *Client, des, nw []CertificateAuthorityConfigPublicKey) []CertificateAuthorityConfigPublicKey { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityConfigPublicKey + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityConfigPublicKey(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityKeySpec(des, initial *CertificateAuthorityKeySpec, opts ...dcl.ApplyOption) *CertificateAuthorityKeySpec { + if des == nil { + return initial + } + if des.empty { + return des + } + + if des.CloudKmsKeyVersion != nil || (initial != nil && initial.CloudKmsKeyVersion != nil) { + // Check if anything else is set. + if dcl.AnySet(des.Algorithm) { + des.CloudKmsKeyVersion = nil + if initial != nil { + initial.CloudKmsKeyVersion = nil + } + } + } + + if des.Algorithm != nil || (initial != nil && initial.Algorithm != nil) { + // Check if anything else is set. + if dcl.AnySet(des.CloudKmsKeyVersion) { + des.Algorithm = nil + if initial != nil { + initial.Algorithm = nil + } + } + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityKeySpec{} + + if dcl.IsZeroValue(des.CloudKmsKeyVersion) || (dcl.IsEmptyValueIndirect(des.CloudKmsKeyVersion) && dcl.IsEmptyValueIndirect(initial.CloudKmsKeyVersion)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.CloudKmsKeyVersion = initial.CloudKmsKeyVersion + } else { + cDes.CloudKmsKeyVersion = des.CloudKmsKeyVersion + } + if dcl.IsZeroValue(des.Algorithm) || (dcl.IsEmptyValueIndirect(des.Algorithm) && dcl.IsEmptyValueIndirect(initial.Algorithm)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Algorithm = initial.Algorithm + } else { + cDes.Algorithm = des.Algorithm + } + + return cDes +} + +func canonicalizeCertificateAuthorityKeySpecSlice(des, initial []CertificateAuthorityKeySpec, opts ...dcl.ApplyOption) []CertificateAuthorityKeySpec { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityKeySpec, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityKeySpec(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityKeySpec, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityKeySpec(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityKeySpec(c *Client, des, nw *CertificateAuthorityKeySpec) *CertificateAuthorityKeySpec { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityKeySpec while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityKeySpecSet(c *Client, des, nw []CertificateAuthorityKeySpec) []CertificateAuthorityKeySpec { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityKeySpec + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityKeySpecNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityKeySpec(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityKeySpecSlice(c *Client, des, nw []CertificateAuthorityKeySpec) []CertificateAuthorityKeySpec { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityKeySpec + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityKeySpec(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthoritySubordinateConfig(des, initial *CertificateAuthoritySubordinateConfig, opts ...dcl.ApplyOption) *CertificateAuthoritySubordinateConfig { + if des == nil { + return initial + } + if des.empty { + return des + } + + if des.CertificateAuthority != nil || (initial != nil && initial.CertificateAuthority != nil) { + // Check if anything else is set. + if dcl.AnySet(des.PemIssuerChain) { + des.CertificateAuthority = nil + if initial != nil { + initial.CertificateAuthority = nil + } + } + } + + if des.PemIssuerChain != nil || (initial != nil && initial.PemIssuerChain != nil) { + // Check if anything else is set. + if dcl.AnySet(des.CertificateAuthority) { + des.PemIssuerChain = nil + if initial != nil { + initial.PemIssuerChain = nil + } + } + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthoritySubordinateConfig{} + + if dcl.IsZeroValue(des.CertificateAuthority) || (dcl.IsEmptyValueIndirect(des.CertificateAuthority) && dcl.IsEmptyValueIndirect(initial.CertificateAuthority)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.CertificateAuthority = initial.CertificateAuthority + } else { + cDes.CertificateAuthority = des.CertificateAuthority + } + cDes.PemIssuerChain = canonicalizeCertificateAuthoritySubordinateConfigPemIssuerChain(des.PemIssuerChain, initial.PemIssuerChain, opts...) + + return cDes +} + +func canonicalizeCertificateAuthoritySubordinateConfigSlice(des, initial []CertificateAuthoritySubordinateConfig, opts ...dcl.ApplyOption) []CertificateAuthoritySubordinateConfig { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthoritySubordinateConfig, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthoritySubordinateConfig(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthoritySubordinateConfig, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthoritySubordinateConfig(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthoritySubordinateConfig(c *Client, des, nw *CertificateAuthoritySubordinateConfig) *CertificateAuthoritySubordinateConfig { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthoritySubordinateConfig while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.PemIssuerChain = canonicalizeNewCertificateAuthoritySubordinateConfigPemIssuerChain(c, des.PemIssuerChain, nw.PemIssuerChain) + + return nw +} + +func canonicalizeNewCertificateAuthoritySubordinateConfigSet(c *Client, des, nw []CertificateAuthoritySubordinateConfig) []CertificateAuthoritySubordinateConfig { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthoritySubordinateConfig + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthoritySubordinateConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthoritySubordinateConfig(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthoritySubordinateConfigSlice(c *Client, des, nw []CertificateAuthoritySubordinateConfig) []CertificateAuthoritySubordinateConfig { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthoritySubordinateConfig + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthoritySubordinateConfig(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthoritySubordinateConfigPemIssuerChain(des, initial *CertificateAuthoritySubordinateConfigPemIssuerChain, opts ...dcl.ApplyOption) *CertificateAuthoritySubordinateConfigPemIssuerChain { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthoritySubordinateConfigPemIssuerChain{} + + if dcl.StringArrayCanonicalize(des.PemCertificates, initial.PemCertificates) { + cDes.PemCertificates = initial.PemCertificates + } else { + cDes.PemCertificates = des.PemCertificates + } + + return cDes +} + +func canonicalizeCertificateAuthoritySubordinateConfigPemIssuerChainSlice(des, initial []CertificateAuthoritySubordinateConfigPemIssuerChain, opts ...dcl.ApplyOption) []CertificateAuthoritySubordinateConfigPemIssuerChain { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthoritySubordinateConfigPemIssuerChain, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthoritySubordinateConfigPemIssuerChain(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthoritySubordinateConfigPemIssuerChain, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthoritySubordinateConfigPemIssuerChain(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthoritySubordinateConfigPemIssuerChain(c *Client, des, nw *CertificateAuthoritySubordinateConfigPemIssuerChain) *CertificateAuthoritySubordinateConfigPemIssuerChain { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthoritySubordinateConfigPemIssuerChain while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.PemCertificates, nw.PemCertificates) { + nw.PemCertificates = des.PemCertificates + } + + return nw +} + +func canonicalizeNewCertificateAuthoritySubordinateConfigPemIssuerChainSet(c *Client, des, nw []CertificateAuthoritySubordinateConfigPemIssuerChain) []CertificateAuthoritySubordinateConfigPemIssuerChain { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthoritySubordinateConfigPemIssuerChain + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthoritySubordinateConfigPemIssuerChainNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthoritySubordinateConfigPemIssuerChain(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthoritySubordinateConfigPemIssuerChainSlice(c *Client, des, nw []CertificateAuthoritySubordinateConfigPemIssuerChain) []CertificateAuthoritySubordinateConfigPemIssuerChain { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthoritySubordinateConfigPemIssuerChain + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthoritySubordinateConfigPemIssuerChain(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptions(des, initial *CertificateAuthorityCaCertificateDescriptions, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptions{} + + cDes.SubjectDescription = canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescription(des.SubjectDescription, initial.SubjectDescription, opts...) + cDes.X509Description = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509Description(des.X509Description, initial.X509Description, opts...) + cDes.PublicKey = canonicalizeCertificateAuthorityCaCertificateDescriptionsPublicKey(des.PublicKey, initial.PublicKey, opts...) + cDes.SubjectKeyId = canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(des.SubjectKeyId, initial.SubjectKeyId, opts...) + cDes.AuthorityKeyId = canonicalizeCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(des.AuthorityKeyId, initial.AuthorityKeyId, opts...) + if dcl.StringArrayCanonicalize(des.CrlDistributionPoints, initial.CrlDistributionPoints) { + cDes.CrlDistributionPoints = initial.CrlDistributionPoints + } else { + cDes.CrlDistributionPoints = des.CrlDistributionPoints + } + if dcl.StringArrayCanonicalize(des.AiaIssuingCertificateUrls, initial.AiaIssuingCertificateUrls) { + cDes.AiaIssuingCertificateUrls = initial.AiaIssuingCertificateUrls + } else { + cDes.AiaIssuingCertificateUrls = des.AiaIssuingCertificateUrls + } + cDes.CertFingerprint = canonicalizeCertificateAuthorityCaCertificateDescriptionsCertFingerprint(des.CertFingerprint, initial.CertFingerprint, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSlice(des, initial []CertificateAuthorityCaCertificateDescriptions, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptions(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptions) *CertificateAuthorityCaCertificateDescriptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.SubjectDescription = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, des.SubjectDescription, nw.SubjectDescription) + nw.X509Description = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509Description(c, des.X509Description, nw.X509Description) + nw.PublicKey = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsPublicKey(c, des.PublicKey, nw.PublicKey) + nw.SubjectKeyId = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, des.SubjectKeyId, nw.SubjectKeyId) + nw.AuthorityKeyId = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, des.AuthorityKeyId, nw.AuthorityKeyId) + if dcl.StringArrayCanonicalize(des.CrlDistributionPoints, nw.CrlDistributionPoints) { + nw.CrlDistributionPoints = des.CrlDistributionPoints + } + if dcl.StringArrayCanonicalize(des.AiaIssuingCertificateUrls, nw.AiaIssuingCertificateUrls) { + nw.AiaIssuingCertificateUrls = des.AiaIssuingCertificateUrls + } + nw.CertFingerprint = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, des.CertFingerprint, nw.CertFingerprint) + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptions) []CertificateAuthorityCaCertificateDescriptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptions) []CertificateAuthorityCaCertificateDescriptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescription(des, initial *CertificateAuthorityCaCertificateDescriptionsSubjectDescription, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + + cDes.Subject = canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(des.Subject, initial.Subject, opts...) + cDes.SubjectAltName = canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(des.SubjectAltName, initial.SubjectAltName, opts...) + if dcl.StringCanonicalize(des.HexSerialNumber, initial.HexSerialNumber) || dcl.IsZeroValue(des.HexSerialNumber) { + cDes.HexSerialNumber = initial.HexSerialNumber + } else { + cDes.HexSerialNumber = des.HexSerialNumber + } + if dcl.StringCanonicalize(des.Lifetime, initial.Lifetime) || dcl.IsZeroValue(des.Lifetime) { + cDes.Lifetime = initial.Lifetime + } else { + cDes.Lifetime = des.Lifetime + } + if dcl.IsZeroValue(des.NotBeforeTime) || (dcl.IsEmptyValueIndirect(des.NotBeforeTime) && dcl.IsEmptyValueIndirect(initial.NotBeforeTime)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.NotBeforeTime = initial.NotBeforeTime + } else { + cDes.NotBeforeTime = des.NotBeforeTime + } + if dcl.IsZeroValue(des.NotAfterTime) || (dcl.IsEmptyValueIndirect(des.NotAfterTime) && dcl.IsEmptyValueIndirect(initial.NotAfterTime)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.NotAfterTime = initial.NotAfterTime + } else { + cDes.NotAfterTime = des.NotAfterTime + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsSubjectDescription, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescription, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescription(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescription, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescription(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) *CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsSubjectDescription while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Subject = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, des.Subject, nw.Subject) + nw.SubjectAltName = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, des.SubjectAltName, nw.SubjectAltName) + if dcl.StringCanonicalize(des.HexSerialNumber, nw.HexSerialNumber) { + nw.HexSerialNumber = des.HexSerialNumber + } + if dcl.StringCanonicalize(des.Lifetime, nw.Lifetime) { + nw.Lifetime = des.Lifetime + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescription) []CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescription + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescription) []CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescription + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(des, initial *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + + if dcl.StringCanonicalize(des.CommonName, initial.CommonName) || dcl.IsZeroValue(des.CommonName) { + cDes.CommonName = initial.CommonName + } else { + cDes.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, initial.CountryCode) || dcl.IsZeroValue(des.CountryCode) { + cDes.CountryCode = initial.CountryCode + } else { + cDes.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, initial.Organization) || dcl.IsZeroValue(des.Organization) { + cDes.Organization = initial.Organization + } else { + cDes.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, initial.OrganizationalUnit) || dcl.IsZeroValue(des.OrganizationalUnit) { + cDes.OrganizationalUnit = initial.OrganizationalUnit + } else { + cDes.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, initial.Locality) || dcl.IsZeroValue(des.Locality) { + cDes.Locality = initial.Locality + } else { + cDes.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, initial.Province) || dcl.IsZeroValue(des.Province) { + cDes.Province = initial.Province + } else { + cDes.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, initial.StreetAddress) || dcl.IsZeroValue(des.StreetAddress) { + cDes.StreetAddress = initial.StreetAddress + } else { + cDes.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, initial.PostalCode) || dcl.IsZeroValue(des.PostalCode) { + cDes.PostalCode = initial.PostalCode + } else { + cDes.PostalCode = des.PostalCode + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.CommonName, nw.CommonName) { + nw.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, nw.CountryCode) { + nw.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, nw.Organization) { + nw.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, nw.OrganizationalUnit) { + nw.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, nw.Locality) { + nw.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, nw.Province) { + nw.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, nw.StreetAddress) { + nw.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, nw.PostalCode) { + nw.PostalCode = des.PostalCode + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(des, initial *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + + if dcl.StringArrayCanonicalize(des.DnsNames, initial.DnsNames) { + cDes.DnsNames = initial.DnsNames + } else { + cDes.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, initial.Uris) { + cDes.Uris = initial.Uris + } else { + cDes.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, initial.EmailAddresses) { + cDes.EmailAddresses = initial.EmailAddresses + } else { + cDes.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, initial.IPAddresses) { + cDes.IPAddresses = initial.IPAddresses + } else { + cDes.IPAddresses = des.IPAddresses + } + cDes.CustomSans = canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(des.CustomSans, initial.CustomSans, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DnsNames, nw.DnsNames) { + nw.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, nw.Uris) { + nw.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, nw.EmailAddresses) { + nw.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, nw.IPAddresses) { + nw.IPAddresses = des.IPAddresses + } + nw.CustomSans = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(c, des.CustomSans, nw.CustomSans) + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(des, initial *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{} + + cDes.ObjectId = canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(des, initial *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509Description(des, initial *CertificateAuthorityCaCertificateDescriptionsX509Description, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509Description { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509Description{} + + cDes.KeyUsage = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(des.KeyUsage, initial.KeyUsage, opts...) + cDes.CaOptions = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(des.CaOptions, initial.CaOptions, opts...) + cDes.PolicyIds = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(des.PolicyIds, initial.PolicyIds, opts...) + cDes.AdditionalExtensions = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509Description, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509Description { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509Description, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509Description(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509Description, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509Description(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509Description(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509Description) *CertificateAuthorityCaCertificateDescriptionsX509Description { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509Description while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.KeyUsage = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, des.KeyUsage, nw.KeyUsage) + nw.CaOptions = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, des.CaOptions, nw.CaOptions) + nw.PolicyIds = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(c, des.PolicyIds, nw.PolicyIds) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, nw.AiaOcspServers) { + nw.AiaOcspServers = des.AiaOcspServers + } + nw.AdditionalExtensions = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509Description) []CertificateAuthorityCaCertificateDescriptionsX509Description { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509Description + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509Description(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509Description) []CertificateAuthorityCaCertificateDescriptionsX509Description { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509Description + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509Description(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + + cDes.BaseKeyUsage = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(des.BaseKeyUsage, initial.BaseKeyUsage, opts...) + cDes.ExtendedKeyUsage = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(des.ExtendedKeyUsage, initial.ExtendedKeyUsage, opts...) + cDes.UnknownExtendedKeyUsages = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(des.UnknownExtendedKeyUsages, initial.UnknownExtendedKeyUsages, opts...) + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.BaseKeyUsage = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, des.BaseKeyUsage, nw.BaseKeyUsage) + nw.ExtendedKeyUsage = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, des.ExtendedKeyUsage, nw.ExtendedKeyUsage) + nw.UnknownExtendedKeyUsages = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c, des.UnknownExtendedKeyUsages, nw.UnknownExtendedKeyUsages) + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + + if dcl.BoolCanonicalize(des.DigitalSignature, initial.DigitalSignature) || dcl.IsZeroValue(des.DigitalSignature) { + cDes.DigitalSignature = initial.DigitalSignature + } else { + cDes.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, initial.ContentCommitment) || dcl.IsZeroValue(des.ContentCommitment) { + cDes.ContentCommitment = initial.ContentCommitment + } else { + cDes.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, initial.KeyEncipherment) || dcl.IsZeroValue(des.KeyEncipherment) { + cDes.KeyEncipherment = initial.KeyEncipherment + } else { + cDes.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, initial.DataEncipherment) || dcl.IsZeroValue(des.DataEncipherment) { + cDes.DataEncipherment = initial.DataEncipherment + } else { + cDes.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, initial.KeyAgreement) || dcl.IsZeroValue(des.KeyAgreement) { + cDes.KeyAgreement = initial.KeyAgreement + } else { + cDes.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, initial.CertSign) || dcl.IsZeroValue(des.CertSign) { + cDes.CertSign = initial.CertSign + } else { + cDes.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, initial.CrlSign) || dcl.IsZeroValue(des.CrlSign) { + cDes.CrlSign = initial.CrlSign + } else { + cDes.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, initial.EncipherOnly) || dcl.IsZeroValue(des.EncipherOnly) { + cDes.EncipherOnly = initial.EncipherOnly + } else { + cDes.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, initial.DecipherOnly) || dcl.IsZeroValue(des.DecipherOnly) { + cDes.DecipherOnly = initial.DecipherOnly + } else { + cDes.DecipherOnly = des.DecipherOnly + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.DigitalSignature, nw.DigitalSignature) { + nw.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, nw.ContentCommitment) { + nw.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, nw.KeyEncipherment) { + nw.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, nw.DataEncipherment) { + nw.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, nw.KeyAgreement) { + nw.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, nw.CertSign) { + nw.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, nw.CrlSign) { + nw.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, nw.EncipherOnly) { + nw.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, nw.DecipherOnly) { + nw.DecipherOnly = des.DecipherOnly + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + + if dcl.BoolCanonicalize(des.ServerAuth, initial.ServerAuth) || dcl.IsZeroValue(des.ServerAuth) { + cDes.ServerAuth = initial.ServerAuth + } else { + cDes.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, initial.ClientAuth) || dcl.IsZeroValue(des.ClientAuth) { + cDes.ClientAuth = initial.ClientAuth + } else { + cDes.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, initial.CodeSigning) || dcl.IsZeroValue(des.CodeSigning) { + cDes.CodeSigning = initial.CodeSigning + } else { + cDes.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, initial.EmailProtection) || dcl.IsZeroValue(des.EmailProtection) { + cDes.EmailProtection = initial.EmailProtection + } else { + cDes.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, initial.TimeStamping) || dcl.IsZeroValue(des.TimeStamping) { + cDes.TimeStamping = initial.TimeStamping + } else { + cDes.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, initial.OcspSigning) || dcl.IsZeroValue(des.OcspSigning) { + cDes.OcspSigning = initial.OcspSigning + } else { + cDes.OcspSigning = des.OcspSigning + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.ServerAuth, nw.ServerAuth) { + nw.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, nw.ClientAuth) { + nw.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, nw.CodeSigning) { + nw.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, nw.EmailProtection) { + nw.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, nw.TimeStamping) { + nw.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, nw.OcspSigning) { + nw.OcspSigning = des.OcspSigning + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + + if dcl.BoolCanonicalize(des.IsCa, initial.IsCa) || dcl.IsZeroValue(des.IsCa) { + cDes.IsCa = initial.IsCa + } else { + cDes.IsCa = des.IsCa + } + if dcl.IsZeroValue(des.MaxIssuerPathLength) || (dcl.IsEmptyValueIndirect(des.MaxIssuerPathLength) && dcl.IsEmptyValueIndirect(initial.MaxIssuerPathLength)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxIssuerPathLength = initial.MaxIssuerPathLength + } else { + cDes.MaxIssuerPathLength = des.MaxIssuerPathLength + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.IsCa, nw.IsCa) { + nw.IsCa = des.IsCa + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{} + + cDes.ObjectId = canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(des, initial *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsPublicKey(des, initial *CertificateAuthorityCaCertificateDescriptionsPublicKey, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsPublicKey { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsPublicKey{} + + if dcl.StringCanonicalize(des.Key, initial.Key) || dcl.IsZeroValue(des.Key) { + cDes.Key = initial.Key + } else { + cDes.Key = des.Key + } + if dcl.IsZeroValue(des.Format) || (dcl.IsEmptyValueIndirect(des.Format) && dcl.IsEmptyValueIndirect(initial.Format)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Format = initial.Format + } else { + cDes.Format = des.Format + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsPublicKeySlice(des, initial []CertificateAuthorityCaCertificateDescriptionsPublicKey, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsPublicKey { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsPublicKey, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsPublicKey(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsPublicKey, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsPublicKey(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsPublicKey(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsPublicKey) *CertificateAuthorityCaCertificateDescriptionsPublicKey { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsPublicKey while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Key, nw.Key) { + nw.Key = des.Key + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsPublicKeySet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsPublicKey) []CertificateAuthorityCaCertificateDescriptionsPublicKey { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsPublicKey + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsPublicKeyNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsPublicKey(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsPublicKeySlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsPublicKey) []CertificateAuthorityCaCertificateDescriptionsPublicKey { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsPublicKey + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsPublicKey(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(des, initial *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + + if dcl.StringCanonicalize(des.KeyId, initial.KeyId) || dcl.IsZeroValue(des.KeyId) { + cDes.KeyId = initial.KeyId + } else { + cDes.KeyId = des.KeyId + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsSubjectKeyId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.KeyId, nw.KeyId) { + nw.KeyId = des.KeyId + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(des, initial *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + + if dcl.StringCanonicalize(des.KeyId, initial.KeyId) || dcl.IsZeroValue(des.KeyId) { + cDes.KeyId = initial.KeyId + } else { + cDes.KeyId = des.KeyId + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.KeyId, nw.KeyId) { + nw.KeyId = des.KeyId + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsCertFingerprint(des, initial *CertificateAuthorityCaCertificateDescriptionsCertFingerprint, opts ...dcl.ApplyOption) *CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + + if dcl.StringCanonicalize(des.Sha256Hash, initial.Sha256Hash) || dcl.IsZeroValue(des.Sha256Hash) { + cDes.Sha256Hash = initial.Sha256Hash + } else { + cDes.Sha256Hash = des.Sha256Hash + } + + return cDes +} + +func canonicalizeCertificateAuthorityCaCertificateDescriptionsCertFingerprintSlice(des, initial []CertificateAuthorityCaCertificateDescriptionsCertFingerprint, opts ...dcl.ApplyOption) []CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityCaCertificateDescriptionsCertFingerprint, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsCertFingerprint(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsCertFingerprint, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityCaCertificateDescriptionsCertFingerprint(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c *Client, des, nw *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) *CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityCaCertificateDescriptionsCertFingerprint while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Sha256Hash, nw.Sha256Hash) { + nw.Sha256Hash = des.Sha256Hash + } + + return nw +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsCertFingerprintSet(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsCertFingerprint) []CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityCaCertificateDescriptionsCertFingerprint + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityCaCertificateDescriptionsCertFingerprintNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityCaCertificateDescriptionsCertFingerprintSlice(c *Client, des, nw []CertificateAuthorityCaCertificateDescriptionsCertFingerprint) []CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityCaCertificateDescriptionsCertFingerprint + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateAuthorityAccessUrls(des, initial *CertificateAuthorityAccessUrls, opts ...dcl.ApplyOption) *CertificateAuthorityAccessUrls { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateAuthorityAccessUrls{} + + if dcl.StringCanonicalize(des.CaCertificateAccessUrl, initial.CaCertificateAccessUrl) || dcl.IsZeroValue(des.CaCertificateAccessUrl) { + cDes.CaCertificateAccessUrl = initial.CaCertificateAccessUrl + } else { + cDes.CaCertificateAccessUrl = des.CaCertificateAccessUrl + } + if dcl.StringArrayCanonicalize(des.CrlAccessUrls, initial.CrlAccessUrls) { + cDes.CrlAccessUrls = initial.CrlAccessUrls + } else { + cDes.CrlAccessUrls = des.CrlAccessUrls + } + + return cDes +} + +func canonicalizeCertificateAuthorityAccessUrlsSlice(des, initial []CertificateAuthorityAccessUrls, opts ...dcl.ApplyOption) []CertificateAuthorityAccessUrls { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateAuthorityAccessUrls, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateAuthorityAccessUrls(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateAuthorityAccessUrls, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateAuthorityAccessUrls(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateAuthorityAccessUrls(c *Client, des, nw *CertificateAuthorityAccessUrls) *CertificateAuthorityAccessUrls { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateAuthorityAccessUrls while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.CaCertificateAccessUrl, nw.CaCertificateAccessUrl) { + nw.CaCertificateAccessUrl = des.CaCertificateAccessUrl + } + if dcl.StringArrayCanonicalize(des.CrlAccessUrls, nw.CrlAccessUrls) { + nw.CrlAccessUrls = des.CrlAccessUrls + } + + return nw +} + +func canonicalizeNewCertificateAuthorityAccessUrlsSet(c *Client, des, nw []CertificateAuthorityAccessUrls) []CertificateAuthorityAccessUrls { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateAuthorityAccessUrls + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateAuthorityAccessUrlsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateAuthorityAccessUrls(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateAuthorityAccessUrlsSlice(c *Client, des, nw []CertificateAuthorityAccessUrls) []CertificateAuthorityAccessUrls { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateAuthorityAccessUrls + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateAuthorityAccessUrls(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffCertificateAuthority(c *Client, desired, actual *CertificateAuthority, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Type, actual.Type, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Type")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Config, actual.Config, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigNewStyle, EmptyObject: EmptyCertificateAuthorityConfig, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Config")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Lifetime, actual.Lifetime, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Lifetime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeySpec, actual.KeySpec, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityKeySpecNewStyle, EmptyObject: EmptyCertificateAuthorityKeySpec, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeySpec")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubordinateConfig, actual.SubordinateConfig, dcl.DiffInfo{OutputOnly: true, ObjectFunction: compareCertificateAuthoritySubordinateConfigNewStyle, EmptyObject: EmptyCertificateAuthoritySubordinateConfig, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubordinateConfig")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Tier, actual.Tier, dcl.DiffInfo{OutputOnly: true, Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Tier")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.State, actual.State, dcl.DiffInfo{OutputOnly: true, Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("State")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PemCaCertificates, actual.PemCaCertificates, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PemCaCertificates")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaCertificateDescriptions, actual.CaCertificateDescriptions, dcl.DiffInfo{OutputOnly: true, ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaCertificateDescriptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.GcsBucket, actual.GcsBucket, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("GcsBucket")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.AccessUrls, actual.AccessUrls, dcl.DiffInfo{OutputOnly: true, ObjectFunction: compareCertificateAuthorityAccessUrlsNewStyle, EmptyObject: EmptyCertificateAuthorityAccessUrls, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AccessUrls")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.DeleteTime, actual.DeleteTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DeleteTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExpireTime, actual.ExpireTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ExpireTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaPool, actual.CaPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaPool")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareCertificateAuthorityConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfig) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfig or *CertificateAuthorityConfig", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfig) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfig", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.SubjectConfig, actual.SubjectConfig, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigSubjectConfigNewStyle, EmptyObject: EmptyCertificateAuthorityConfigSubjectConfig, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectConfig")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.X509Config, actual.X509Config, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509Config, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("X509Config")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PublicKey, actual.PublicKey, dcl.DiffInfo{OutputOnly: true, ObjectFunction: compareCertificateAuthorityConfigPublicKeyNewStyle, EmptyObject: EmptyCertificateAuthorityConfigPublicKey, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PublicKey")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigSubjectConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigSubjectConfig) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigSubjectConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfig or *CertificateAuthorityConfigSubjectConfig", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigSubjectConfig) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigSubjectConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfig", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Subject, actual.Subject, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigSubjectConfigSubjectNewStyle, EmptyObject: EmptyCertificateAuthorityConfigSubjectConfigSubject, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Subject")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectAltName, actual.SubjectAltName, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigSubjectConfigSubjectAltNameNewStyle, EmptyObject: EmptyCertificateAuthorityConfigSubjectConfigSubjectAltName, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectAltName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigSubjectConfigSubjectNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigSubjectConfigSubject) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigSubjectConfigSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubject or *CertificateAuthorityConfigSubjectConfigSubject", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigSubjectConfigSubject) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigSubjectConfigSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubject", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CommonName, actual.CommonName, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CommonName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CountryCode, actual.CountryCode, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CountryCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Organization, actual.Organization, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Organization")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OrganizationalUnit, actual.OrganizationalUnit, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("OrganizationalUnit")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Locality, actual.Locality, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Locality")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Province, actual.Province, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Province")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.StreetAddress, actual.StreetAddress, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("StreetAddress")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PostalCode, actual.PostalCode, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PostalCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigSubjectConfigSubjectAltNameNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigSubjectConfigSubjectAltName) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigSubjectConfigSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubjectAltName or *CertificateAuthorityConfigSubjectConfigSubjectAltName", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigSubjectConfigSubjectAltName) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigSubjectConfigSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubjectAltName", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DnsNames, actual.DnsNames, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DnsNames")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Uris, actual.Uris, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uris")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailAddresses, actual.EmailAddresses, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EmailAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.IPAddresses, actual.IPAddresses, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IpAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CustomSans, actual.CustomSans, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansNewStyle, EmptyObject: EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CustomSans")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans or *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdNewStyle, EmptyObject: EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId or *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509Config) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509Config) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509Config or *CertificateAuthorityConfigX509Config", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509Config) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509Config) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509Config", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyUsage, actual.KeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigKeyUsageNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaOptions, actual.CaOptions, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigCaOptionsNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigCaOptions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PolicyIds, actual.PolicyIds, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigPolicyIdsNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigPolicyIds, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PolicyIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaOcspServers, actual.AiaOcspServers, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AiaOcspServers")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigAdditionalExtensionsNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsage or *CertificateAuthorityConfigX509ConfigKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.BaseKeyUsage, actual.BaseKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("BaseKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExtendedKeyUsage, actual.ExtendedKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ExtendedKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UnknownExtendedKeyUsages, actual.UnknownExtendedKeyUsages, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UnknownExtendedKeyUsages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage or *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DigitalSignature, actual.DigitalSignature, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DigitalSignature")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ContentCommitment, actual.ContentCommitment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ContentCommitment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyEncipherment, actual.KeyEncipherment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DataEncipherment, actual.DataEncipherment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DataEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyAgreement, actual.KeyAgreement, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyAgreement")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertSign, actual.CertSign, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlSign, actual.CrlSign, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CrlSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EncipherOnly, actual.EncipherOnly, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EncipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DecipherOnly, actual.DecipherOnly, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DecipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage or *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ServerAuth, actual.ServerAuth, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ServerAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ClientAuth, actual.ClientAuth, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ClientAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CodeSigning, actual.CodeSigning, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CodeSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailProtection, actual.EmailProtection, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EmailProtection")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.TimeStamping, actual.TimeStamping, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TimeStamping")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OcspSigning, actual.OcspSigning, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("OcspSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages or *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigCaOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigCaOptions) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigCaOptions or *CertificateAuthorityConfigX509ConfigCaOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigCaOptions) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigCaOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.IsCa, actual.IsCa, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IsCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxIssuerPathLength, actual.MaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("MaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ZeroMaxIssuerPathLength, actual.ZeroMaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ZeroMaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigPolicyIdsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigPolicyIds) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigPolicyIds or *CertificateAuthorityConfigX509ConfigPolicyIds", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigPolicyIds) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigPolicyIds", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigAdditionalExtensions or *CertificateAuthorityConfigX509ConfigAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdNewStyle, EmptyObject: EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId or *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityConfigPublicKeyNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityConfigPublicKey) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityConfigPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigPublicKey or *CertificateAuthorityConfigPublicKey", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityConfigPublicKey) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityConfigPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityConfigPublicKey", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Key, actual.Key, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Key")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Format, actual.Format, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Format")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityKeySpecNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityKeySpec) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityKeySpec) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityKeySpec or *CertificateAuthorityKeySpec", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityKeySpec) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityKeySpec) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityKeySpec", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CloudKmsKeyVersion, actual.CloudKmsKeyVersion, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CloudKmsKeyVersion")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Algorithm, actual.Algorithm, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Algorithm")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthoritySubordinateConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthoritySubordinateConfig) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthoritySubordinateConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthoritySubordinateConfig or *CertificateAuthoritySubordinateConfig", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthoritySubordinateConfig) + if !ok { + actualNotPointer, ok := a.(CertificateAuthoritySubordinateConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthoritySubordinateConfig", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CertificateAuthority, actual.CertificateAuthority, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertificateAuthority")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PemIssuerChain, actual.PemIssuerChain, dcl.DiffInfo{ObjectFunction: compareCertificateAuthoritySubordinateConfigPemIssuerChainNewStyle, EmptyObject: EmptyCertificateAuthoritySubordinateConfigPemIssuerChain, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PemIssuerChain")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthoritySubordinateConfigPemIssuerChainNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthoritySubordinateConfigPemIssuerChain) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthoritySubordinateConfigPemIssuerChain) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthoritySubordinateConfigPemIssuerChain or *CertificateAuthoritySubordinateConfigPemIssuerChain", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthoritySubordinateConfigPemIssuerChain) + if !ok { + actualNotPointer, ok := a.(CertificateAuthoritySubordinateConfigPemIssuerChain) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthoritySubordinateConfigPemIssuerChain", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.PemCertificates, actual.PemCertificates, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PemCertificates")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptions) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptions or *CertificateAuthorityCaCertificateDescriptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptions) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.SubjectDescription, actual.SubjectDescription, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescription, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("SubjectDescription")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.X509Description, actual.X509Description, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509Description, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("X509Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PublicKey, actual.PublicKey, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsPublicKeyNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsPublicKey, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("PublicKey")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectKeyId, actual.SubjectKeyId, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsSubjectKeyId, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("SubjectKeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AuthorityKeyId, actual.AuthorityKeyId, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("AuthorityKeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlDistributionPoints, actual.CrlDistributionPoints, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CrlDistributionPoints")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaIssuingCertificateUrls, actual.AiaIssuingCertificateUrls, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("AiaIssuingCertificateUrls")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertFingerprint, actual.CertFingerprint, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsCertFingerprintNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsCertFingerprint, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CertFingerprint")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescription) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsSubjectDescription) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescription or *CertificateAuthorityCaCertificateDescriptionsSubjectDescription", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescription) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsSubjectDescription) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescription", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Subject, actual.Subject, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Subject")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectAltName, actual.SubjectAltName, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("SubjectAltName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.HexSerialNumber, actual.HexSerialNumber, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("HexSerialNumber")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Lifetime, actual.Lifetime, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Lifetime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.NotBeforeTime, actual.NotBeforeTime, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("NotBeforeTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.NotAfterTime, actual.NotAfterTime, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("NotAfterTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject or *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CommonName, actual.CommonName, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CommonName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CountryCode, actual.CountryCode, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CountryCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Organization, actual.Organization, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Organization")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OrganizationalUnit, actual.OrganizationalUnit, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("OrganizationalUnit")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Locality, actual.Locality, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Locality")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Province, actual.Province, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Province")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.StreetAddress, actual.StreetAddress, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("StreetAddress")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PostalCode, actual.PostalCode, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("PostalCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName or *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DnsNames, actual.DnsNames, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("DnsNames")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Uris, actual.Uris, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Uris")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailAddresses, actual.EmailAddresses, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("EmailAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.IPAddresses, actual.IPAddresses, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("IpAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CustomSans, actual.CustomSans, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CustomSans")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans or *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId or *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509Description) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509Description) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509Description or *CertificateAuthorityCaCertificateDescriptionsX509Description", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509Description) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509Description) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509Description", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyUsage, actual.KeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("KeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaOptions, actual.CaOptions, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CaOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PolicyIds, actual.PolicyIds, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("PolicyIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaOcspServers, actual.AiaOcspServers, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AiaOcspServers")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.BaseKeyUsage, actual.BaseKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("BaseKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExtendedKeyUsage, actual.ExtendedKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ExtendedKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UnknownExtendedKeyUsages, actual.UnknownExtendedKeyUsages, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("UnknownExtendedKeyUsages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DigitalSignature, actual.DigitalSignature, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("DigitalSignature")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ContentCommitment, actual.ContentCommitment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ContentCommitment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyEncipherment, actual.KeyEncipherment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("KeyEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DataEncipherment, actual.DataEncipherment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("DataEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyAgreement, actual.KeyAgreement, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("KeyAgreement")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertSign, actual.CertSign, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CertSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlSign, actual.CrlSign, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CrlSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EncipherOnly, actual.EncipherOnly, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("EncipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DecipherOnly, actual.DecipherOnly, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("DecipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ServerAuth, actual.ServerAuth, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ServerAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ClientAuth, actual.ClientAuth, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ClientAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CodeSigning, actual.CodeSigning, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("CodeSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailProtection, actual.EmailProtection, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("EmailProtection")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.TimeStamping, actual.TimeStamping, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("TimeStamping")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OcspSigning, actual.OcspSigning, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("OcspSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.IsCa, actual.IsCa, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("IsCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxIssuerPathLength, actual.MaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("MaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdNewStyle, EmptyObject: EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId or *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsPublicKeyNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsPublicKey) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsPublicKey or *CertificateAuthorityCaCertificateDescriptionsPublicKey", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsPublicKey) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsPublicKey", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Key, actual.Key, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Key")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Format, actual.Format, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Format")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectKeyId or *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsSubjectKeyId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyId, actual.KeyId, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("KeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId or *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyId, actual.KeyId, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("KeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityCaCertificateDescriptionsCertFingerprintNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityCaCertificateDescriptionsCertFingerprint) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityCaCertificateDescriptionsCertFingerprint) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsCertFingerprint or *CertificateAuthorityCaCertificateDescriptionsCertFingerprint", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityCaCertificateDescriptionsCertFingerprint) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityCaCertificateDescriptionsCertFingerprint) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityCaCertificateDescriptionsCertFingerprint", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Sha256Hash, actual.Sha256Hash, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateAuthorityUpdateCertificateAuthorityOperation")}, fn.AddNest("Sha256Hash")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateAuthorityAccessUrlsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateAuthorityAccessUrls) + if !ok { + desiredNotPointer, ok := d.(CertificateAuthorityAccessUrls) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityAccessUrls or *CertificateAuthorityAccessUrls", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateAuthorityAccessUrls) + if !ok { + actualNotPointer, ok := a.(CertificateAuthorityAccessUrls) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateAuthorityAccessUrls", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CaCertificateAccessUrl, actual.CaCertificateAccessUrl, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaCertificateAccessUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlAccessUrls, actual.CrlAccessUrls, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CrlAccessUrls")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *CertificateAuthority) urlNormalized() *CertificateAuthority { + normalized := dcl.Copy(*r).(CertificateAuthority) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.Lifetime = dcl.SelfLinkToName(r.Lifetime) + normalized.GcsBucket = dcl.SelfLinkToName(r.GcsBucket) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + normalized.CaPool = dcl.SelfLinkToName(r.CaPool) + return &normalized +} + +func (r *CertificateAuthority) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateCertificateAuthority" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificateAuthorities/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the CertificateAuthority resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *CertificateAuthority) marshal(c *Client) ([]byte, error) { + m, err := expandCertificateAuthority(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling CertificateAuthority: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalCertificateAuthority decodes JSON responses into the CertificateAuthority resource schema. +func unmarshalCertificateAuthority(b []byte, c *Client, res *CertificateAuthority) (*CertificateAuthority, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapCertificateAuthority(m, c, res) +} + +func unmarshalMapCertificateAuthority(m map[string]interface{}, c *Client, res *CertificateAuthority) (*CertificateAuthority, error) { + + flattened := flattenCertificateAuthority(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandCertificateAuthority expands CertificateAuthority into a JSON request object. +func expandCertificateAuthority(c *Client, f *CertificateAuthority) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.DeriveField("projects/%s/locations/%s/caPools/%s/certificateAuthorities/%s", f.Name, dcl.SelfLinkToName(f.Project), dcl.SelfLinkToName(f.Location), dcl.SelfLinkToName(f.CaPool), dcl.SelfLinkToName(f.Name)); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.Type; dcl.ValueShouldBeSent(v) { + m["type"] = v + } + if v, err := expandCertificateAuthorityConfig(c, f.Config, res); err != nil { + return nil, fmt.Errorf("error expanding Config into config: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["config"] = v + } + if v := f.Lifetime; dcl.ValueShouldBeSent(v) { + m["lifetime"] = v + } + if v, err := expandCertificateAuthorityKeySpec(c, f.KeySpec, res); err != nil { + return nil, fmt.Errorf("error expanding KeySpec into keySpec: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keySpec"] = v + } + if v := f.GcsBucket; dcl.ValueShouldBeSent(v) { + m["gcsBucket"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding CaPool into caPool: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caPool"] = v + } + + return m, nil +} + +// flattenCertificateAuthority flattens CertificateAuthority from a JSON request object into the +// CertificateAuthority type. +func flattenCertificateAuthority(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthority { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &CertificateAuthority{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.Type = flattenCertificateAuthorityTypeEnum(m["type"]) + resultRes.Config = flattenCertificateAuthorityConfig(c, m["config"], res) + resultRes.Lifetime = dcl.FlattenString(m["lifetime"]) + resultRes.KeySpec = flattenCertificateAuthorityKeySpec(c, m["keySpec"], res) + resultRes.SubordinateConfig = flattenCertificateAuthoritySubordinateConfig(c, m["subordinateConfig"], res) + resultRes.Tier = flattenCertificateAuthorityTierEnum(m["tier"]) + resultRes.State = flattenCertificateAuthorityStateEnum(m["state"]) + resultRes.PemCaCertificates = dcl.FlattenStringSlice(m["pemCaCertificates"]) + resultRes.CaCertificateDescriptions = flattenCertificateAuthorityCaCertificateDescriptionsSlice(c, m["caCertificateDescriptions"], res) + resultRes.GcsBucket = dcl.FlattenString(m["gcsBucket"]) + resultRes.AccessUrls = flattenCertificateAuthorityAccessUrls(c, m["accessUrls"], res) + resultRes.CreateTime = dcl.FlattenString(m["createTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.DeleteTime = dcl.FlattenString(m["deleteTime"]) + resultRes.ExpireTime = dcl.FlattenString(m["expireTime"]) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + resultRes.CaPool = dcl.FlattenString(m["caPool"]) + + return resultRes +} + +// expandCertificateAuthorityConfigMap expands the contents of CertificateAuthorityConfig into a JSON +// request object. +func expandCertificateAuthorityConfigMap(c *Client, f map[string]CertificateAuthorityConfig, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfig(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigSlice expands the contents of CertificateAuthorityConfig into a JSON +// request object. +func expandCertificateAuthorityConfigSlice(c *Client, f []CertificateAuthorityConfig, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfig(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigMap flattens the contents of CertificateAuthorityConfig from a JSON +// response object. +func flattenCertificateAuthorityConfigMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfig { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfig{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfig{} + } + + items := make(map[string]CertificateAuthorityConfig) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfig(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigSlice flattens the contents of CertificateAuthorityConfig from a JSON +// response object. +func flattenCertificateAuthorityConfigSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfig { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfig{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfig{} + } + + items := make([]CertificateAuthorityConfig, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfig(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfig expands an instance of CertificateAuthorityConfig into a JSON +// request object. +func expandCertificateAuthorityConfig(c *Client, f *CertificateAuthorityConfig, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityConfigSubjectConfig(c, f.SubjectConfig, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectConfig into subjectConfig: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectConfig"] = v + } + if v, err := expandCertificateAuthorityConfigX509Config(c, f.X509Config, res); err != nil { + return nil, fmt.Errorf("error expanding X509Config into x509Config: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["x509Config"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfig flattens an instance of CertificateAuthorityConfig from a JSON +// response object. +func flattenCertificateAuthorityConfig(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfig { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfig{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfig + } + r.SubjectConfig = flattenCertificateAuthorityConfigSubjectConfig(c, m["subjectConfig"], res) + r.X509Config = flattenCertificateAuthorityConfigX509Config(c, m["x509Config"], res) + r.PublicKey = flattenCertificateAuthorityConfigPublicKey(c, m["publicKey"], res) + + return r +} + +// expandCertificateAuthorityConfigSubjectConfigMap expands the contents of CertificateAuthorityConfigSubjectConfig into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigMap(c *Client, f map[string]CertificateAuthorityConfigSubjectConfig, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfig(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigSubjectConfigSlice expands the contents of CertificateAuthorityConfigSubjectConfig into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSlice(c *Client, f []CertificateAuthorityConfigSubjectConfig, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfig(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigMap flattens the contents of CertificateAuthorityConfigSubjectConfig from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigSubjectConfig { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigSubjectConfig{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigSubjectConfig{} + } + + items := make(map[string]CertificateAuthorityConfigSubjectConfig) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigSubjectConfig(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigSubjectConfigSlice flattens the contents of CertificateAuthorityConfigSubjectConfig from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigSubjectConfig { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigSubjectConfig{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigSubjectConfig{} + } + + items := make([]CertificateAuthorityConfigSubjectConfig, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigSubjectConfig(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigSubjectConfig expands an instance of CertificateAuthorityConfigSubjectConfig into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfig(c *Client, f *CertificateAuthorityConfigSubjectConfig, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityConfigSubjectConfigSubject(c, f.Subject, res); err != nil { + return nil, fmt.Errorf("error expanding Subject into subject: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subject"] = v + } + if v, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltName(c, f.SubjectAltName, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectAltName into subjectAltName: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectAltName"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigSubjectConfig flattens an instance of CertificateAuthorityConfigSubjectConfig from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfig(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigSubjectConfig { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigSubjectConfig{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigSubjectConfig + } + r.Subject = flattenCertificateAuthorityConfigSubjectConfigSubject(c, m["subject"], res) + r.SubjectAltName = flattenCertificateAuthorityConfigSubjectConfigSubjectAltName(c, m["subjectAltName"], res) + + return r +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectMap expands the contents of CertificateAuthorityConfigSubjectConfigSubject into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectMap(c *Client, f map[string]CertificateAuthorityConfigSubjectConfigSubject, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubject(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectSlice expands the contents of CertificateAuthorityConfigSubjectConfigSubject into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectSlice(c *Client, f []CertificateAuthorityConfigSubjectConfigSubject, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubject(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectMap flattens the contents of CertificateAuthorityConfigSubjectConfigSubject from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigSubjectConfigSubject { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigSubjectConfigSubject{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigSubjectConfigSubject{} + } + + items := make(map[string]CertificateAuthorityConfigSubjectConfigSubject) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigSubjectConfigSubject(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectSlice flattens the contents of CertificateAuthorityConfigSubjectConfigSubject from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigSubjectConfigSubject { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigSubjectConfigSubject{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigSubjectConfigSubject{} + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubject, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigSubjectConfigSubject(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigSubjectConfigSubject expands an instance of CertificateAuthorityConfigSubjectConfigSubject into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubject(c *Client, f *CertificateAuthorityConfigSubjectConfigSubject, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CommonName; !dcl.IsEmptyValueIndirect(v) { + m["commonName"] = v + } + if v := f.CountryCode; !dcl.IsEmptyValueIndirect(v) { + m["countryCode"] = v + } + if v := f.Organization; !dcl.IsEmptyValueIndirect(v) { + m["organization"] = v + } + if v := f.OrganizationalUnit; !dcl.IsEmptyValueIndirect(v) { + m["organizationalUnit"] = v + } + if v := f.Locality; !dcl.IsEmptyValueIndirect(v) { + m["locality"] = v + } + if v := f.Province; !dcl.IsEmptyValueIndirect(v) { + m["province"] = v + } + if v := f.StreetAddress; !dcl.IsEmptyValueIndirect(v) { + m["streetAddress"] = v + } + if v := f.PostalCode; !dcl.IsEmptyValueIndirect(v) { + m["postalCode"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubject flattens an instance of CertificateAuthorityConfigSubjectConfigSubject from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubject(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigSubjectConfigSubject { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigSubjectConfigSubject{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigSubjectConfigSubject + } + r.CommonName = dcl.FlattenString(m["commonName"]) + r.CountryCode = dcl.FlattenString(m["countryCode"]) + r.Organization = dcl.FlattenString(m["organization"]) + r.OrganizationalUnit = dcl.FlattenString(m["organizationalUnit"]) + r.Locality = dcl.FlattenString(m["locality"]) + r.Province = dcl.FlattenString(m["province"]) + r.StreetAddress = dcl.FlattenString(m["streetAddress"]) + r.PostalCode = dcl.FlattenString(m["postalCode"]) + + return r +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameMap expands the contents of CertificateAuthorityConfigSubjectConfigSubjectAltName into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameMap(c *Client, f map[string]CertificateAuthorityConfigSubjectConfigSubjectAltName, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameSlice expands the contents of CertificateAuthorityConfigSubjectConfigSubjectAltName into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameSlice(c *Client, f []CertificateAuthorityConfigSubjectConfigSubjectAltName, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameMap flattens the contents of CertificateAuthorityConfigSubjectConfigSubjectAltName from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigSubjectConfigSubjectAltName { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigSubjectConfigSubjectAltName{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigSubjectConfigSubjectAltName{} + } + + items := make(map[string]CertificateAuthorityConfigSubjectConfigSubjectAltName) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigSubjectConfigSubjectAltName(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameSlice flattens the contents of CertificateAuthorityConfigSubjectConfigSubjectAltName from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigSubjectConfigSubjectAltName { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigSubjectConfigSubjectAltName{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigSubjectConfigSubjectAltName{} + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltName, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigSubjectConfigSubjectAltName(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltName expands an instance of CertificateAuthorityConfigSubjectConfigSubjectAltName into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltName(c *Client, f *CertificateAuthorityConfigSubjectConfigSubjectAltName, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DnsNames; v != nil { + m["dnsNames"] = v + } + if v := f.Uris; v != nil { + m["uris"] = v + } + if v := f.EmailAddresses; v != nil { + m["emailAddresses"] = v + } + if v := f.IPAddresses; v != nil { + m["ipAddresses"] = v + } + if v, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(c, f.CustomSans, res); err != nil { + return nil, fmt.Errorf("error expanding CustomSans into customSans: %w", err) + } else if v != nil { + m["customSans"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltName flattens an instance of CertificateAuthorityConfigSubjectConfigSubjectAltName from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltName(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigSubjectConfigSubjectAltName { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigSubjectConfigSubjectAltName{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigSubjectConfigSubjectAltName + } + r.DnsNames = dcl.FlattenStringSlice(m["dnsNames"]) + r.Uris = dcl.FlattenStringSlice(m["uris"]) + r.EmailAddresses = dcl.FlattenStringSlice(m["emailAddresses"]) + r.IPAddresses = dcl.FlattenStringSlice(m["ipAddresses"]) + r.CustomSans = flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(c, m["customSans"], res) + + return r +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansMap expands the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansMap(c *Client, f map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice expands the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(c *Client, f []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansMap flattens the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{} + } + + items := make(map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice flattens the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{} + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans expands an instance of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c *Client, f *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans flattens an instance of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans + } + r.ObjectId = flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdMap expands the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdMap(c *Client, f map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSlice expands the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSlice(c *Client, f []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdMap flattens the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + } + + items := make(map[string]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSlice flattens the contents of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + } + + items := make([]CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId expands an instance of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c *Client, f *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId flattens an instance of CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigMap expands the contents of CertificateAuthorityConfigX509Config into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigMap(c *Client, f map[string]CertificateAuthorityConfigX509Config, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509Config(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigSlice expands the contents of CertificateAuthorityConfigX509Config into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigSlice(c *Client, f []CertificateAuthorityConfigX509Config, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509Config(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigMap flattens the contents of CertificateAuthorityConfigX509Config from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509Config { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509Config{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509Config{} + } + + items := make(map[string]CertificateAuthorityConfigX509Config) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509Config(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigSlice flattens the contents of CertificateAuthorityConfigX509Config from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509Config { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509Config{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509Config{} + } + + items := make([]CertificateAuthorityConfigX509Config, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509Config(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509Config expands an instance of CertificateAuthorityConfigX509Config into a JSON +// request object. +func expandCertificateAuthorityConfigX509Config(c *Client, f *CertificateAuthorityConfigX509Config, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityConfigX509ConfigKeyUsage(c, f.KeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding KeyUsage into keyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keyUsage"] = v + } + if v, err := expandCertificateAuthorityConfigX509ConfigCAOptions(c, f.CaOptions, res); err != nil { + return nil, fmt.Errorf("error expanding CaOptions into caOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caOptions"] = v + } + if v, err := expandCertificateAuthorityConfigX509ConfigPolicyIdsSlice(c, f.PolicyIds, res); err != nil { + return nil, fmt.Errorf("error expanding PolicyIds into policyIds: %w", err) + } else if v != nil { + m["policyIds"] = v + } + if v, err := expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509Config flattens an instance of CertificateAuthorityConfigX509Config from a JSON +// response object. +func flattenCertificateAuthorityConfigX509Config(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509Config { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509Config{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509Config + } + r.KeyUsage = flattenCertificateAuthorityConfigX509ConfigKeyUsage(c, m["keyUsage"], res) + r.CaOptions = flattenCertificateAuthorityConfigX509ConfigCAOptions(c, m["caOptions"], res) + r.PolicyIds = flattenCertificateAuthorityConfigX509ConfigPolicyIdsSlice(c, m["policyIds"], res) + r.AiaOcspServers = dcl.FlattenStringSlice(m["aiaOcspServers"]) + r.AdditionalExtensions = flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageMap expands the contents of CertificateAuthorityConfigX509ConfigKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageSlice expands the contents of CertificateAuthorityConfigX509ConfigKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageSlice(c *Client, f []CertificateAuthorityConfigX509ConfigKeyUsage, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageMap flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsage{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageSlice flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigKeyUsage{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigKeyUsage{} + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsage expands an instance of CertificateAuthorityConfigX509ConfigKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsage(c *Client, f *CertificateAuthorityConfigX509ConfigKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, f.BaseKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding BaseKeyUsage into baseKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baseKeyUsage"] = v + } + if v, err := expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, f.ExtendedKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding ExtendedKeyUsage into extendedKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["extendedKeyUsage"] = v + } + if v, err := expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c, f.UnknownExtendedKeyUsages, res); err != nil { + return nil, fmt.Errorf("error expanding UnknownExtendedKeyUsages into unknownExtendedKeyUsages: %w", err) + } else if v != nil { + m["unknownExtendedKeyUsages"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsage flattens an instance of CertificateAuthorityConfigX509ConfigKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsage(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigKeyUsage + } + r.BaseKeyUsage = flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, m["baseKeyUsage"], res) + r.ExtendedKeyUsage = flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, m["extendedKeyUsage"], res) + r.UnknownExtendedKeyUsages = flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c, m["unknownExtendedKeyUsages"], res) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageMap expands the contents of CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSlice expands the contents of CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSlice(c *Client, f []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageMap flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSlice flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage expands an instance of CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c *Client, f *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DigitalSignature; !dcl.IsEmptyValueIndirect(v) { + m["digitalSignature"] = v + } + if v := f.ContentCommitment; !dcl.IsEmptyValueIndirect(v) { + m["contentCommitment"] = v + } + if v := f.KeyEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["keyEncipherment"] = v + } + if v := f.DataEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["dataEncipherment"] = v + } + if v := f.KeyAgreement; !dcl.IsEmptyValueIndirect(v) { + m["keyAgreement"] = v + } + if v := f.CertSign; !dcl.IsEmptyValueIndirect(v) { + m["certSign"] = v + } + if v := f.CrlSign; !dcl.IsEmptyValueIndirect(v) { + m["crlSign"] = v + } + if v := f.EncipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["encipherOnly"] = v + } + if v := f.DecipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["decipherOnly"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage flattens an instance of CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageMap expands the contents of CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSlice expands the contents of CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSlice(c *Client, f []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageMap flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSlice flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage expands an instance of CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c *Client, f *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ServerAuth; !dcl.IsEmptyValueIndirect(v) { + m["serverAuth"] = v + } + if v := f.ClientAuth; !dcl.IsEmptyValueIndirect(v) { + m["clientAuth"] = v + } + if v := f.CodeSigning; !dcl.IsEmptyValueIndirect(v) { + m["codeSigning"] = v + } + if v := f.EmailProtection; !dcl.IsEmptyValueIndirect(v) { + m["emailProtection"] = v + } + if v := f.TimeStamping; !dcl.IsEmptyValueIndirect(v) { + m["timeStamping"] = v + } + if v := f.OcspSigning; !dcl.IsEmptyValueIndirect(v) { + m["ocspSigning"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage flattens an instance of CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap expands the contents of CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice expands the contents of CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, f []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice flattens the contents of CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + items := make([]CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages expands an instance of CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c *Client, f *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages flattens an instance of CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigCaOptionsMap expands the contents of CertificateAuthorityConfigX509ConfigCaOptions into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigCaOptionsMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigCaOptions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigCaOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigCaOptionsSlice expands the contents of CertificateAuthorityConfigX509ConfigCaOptions into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigCaOptionsSlice(c *Client, f []CertificateAuthorityConfigX509ConfigCaOptions, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigCaOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigCaOptionsMap flattens the contents of CertificateAuthorityConfigX509ConfigCaOptions from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigCaOptionsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigCaOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigCaOptions{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigCaOptions{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigCaOptions) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigCaOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigCaOptionsSlice flattens the contents of CertificateAuthorityConfigX509ConfigCaOptions from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigCaOptionsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigCaOptions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigCaOptions{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigCaOptions{} + } + + items := make([]CertificateAuthorityConfigX509ConfigCaOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigCaOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigCaOptions expands an instance of CertificateAuthorityConfigX509ConfigCaOptions into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigCaOptions(c *Client, f *CertificateAuthorityConfigX509ConfigCaOptions, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + if v := f.MaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["maxIssuerPathLength"] = v + } + if v := f.ZeroMaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["zeroMaxIssuerPathLength"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigCaOptions flattens an instance of CertificateAuthorityConfigX509ConfigCaOptions from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigCaOptions(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigCaOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigCaOptions + } + r.IsCa = dcl.FlattenBool(m["isCa"]) + r.MaxIssuerPathLength = dcl.FlattenInteger(m["maxIssuerPathLength"]) + r.ZeroMaxIssuerPathLength = dcl.FlattenBool(m["zeroMaxIssuerPathLength"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigPolicyIdsMap expands the contents of CertificateAuthorityConfigX509ConfigPolicyIds into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigPolicyIdsMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigPolicyIds, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigPolicyIdsSlice expands the contents of CertificateAuthorityConfigX509ConfigPolicyIds into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigPolicyIdsSlice(c *Client, f []CertificateAuthorityConfigX509ConfigPolicyIds, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigPolicyIdsMap flattens the contents of CertificateAuthorityConfigX509ConfigPolicyIds from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigPolicyIdsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigPolicyIds { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigPolicyIds{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigPolicyIds{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigPolicyIds) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigPolicyIds(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigPolicyIdsSlice flattens the contents of CertificateAuthorityConfigX509ConfigPolicyIds from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigPolicyIdsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigPolicyIds { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigPolicyIds{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigPolicyIds{} + } + + items := make([]CertificateAuthorityConfigX509ConfigPolicyIds, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigPolicyIds(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigPolicyIds expands an instance of CertificateAuthorityConfigX509ConfigPolicyIds into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigPolicyIds(c *Client, f *CertificateAuthorityConfigX509ConfigPolicyIds, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigPolicyIds flattens an instance of CertificateAuthorityConfigX509ConfigPolicyIds from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigPolicyIds(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigPolicyIds { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigPolicyIds{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigPolicyIds + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsMap expands the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensions into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice expands the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensions into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(c *Client, f []CertificateAuthorityConfigX509ConfigAdditionalExtensions, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsMap flattens the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensions from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensions{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice flattens the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensions from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigAdditionalExtensions{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigAdditionalExtensions{} + } + + items := make([]CertificateAuthorityConfigX509ConfigAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigAdditionalExtensions expands an instance of CertificateAuthorityConfigX509ConfigAdditionalExtensions into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigAdditionalExtensions(c *Client, f *CertificateAuthorityConfigX509ConfigAdditionalExtensions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigAdditionalExtensions flattens an instance of CertificateAuthorityConfigX509ConfigAdditionalExtensions from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigAdditionalExtensions(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensions + } + r.ObjectId = flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdMap expands the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdMap(c *Client, f map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSlice expands the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSlice(c *Client, f []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdMap flattens the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + } + + items := make(map[string]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSlice flattens the contents of CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + } + + items := make([]CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId expands an instance of CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c *Client, f *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId flattens an instance of CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityConfigPublicKeyMap expands the contents of CertificateAuthorityConfigPublicKey into a JSON +// request object. +func expandCertificateAuthorityConfigPublicKeyMap(c *Client, f map[string]CertificateAuthorityConfigPublicKey, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityConfigPublicKey(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityConfigPublicKeySlice expands the contents of CertificateAuthorityConfigPublicKey into a JSON +// request object. +func expandCertificateAuthorityConfigPublicKeySlice(c *Client, f []CertificateAuthorityConfigPublicKey, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityConfigPublicKey(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityConfigPublicKeyMap flattens the contents of CertificateAuthorityConfigPublicKey from a JSON +// response object. +func flattenCertificateAuthorityConfigPublicKeyMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigPublicKey { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigPublicKey{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigPublicKey{} + } + + items := make(map[string]CertificateAuthorityConfigPublicKey) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigPublicKey(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityConfigPublicKeySlice flattens the contents of CertificateAuthorityConfigPublicKey from a JSON +// response object. +func flattenCertificateAuthorityConfigPublicKeySlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigPublicKey { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigPublicKey{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigPublicKey{} + } + + items := make([]CertificateAuthorityConfigPublicKey, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigPublicKey(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityConfigPublicKey expands an instance of CertificateAuthorityConfigPublicKey into a JSON +// request object. +func expandCertificateAuthorityConfigPublicKey(c *Client, f *CertificateAuthorityConfigPublicKey, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Key; !dcl.IsEmptyValueIndirect(v) { + m["key"] = v + } + if v := f.Format; !dcl.IsEmptyValueIndirect(v) { + m["format"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityConfigPublicKey flattens an instance of CertificateAuthorityConfigPublicKey from a JSON +// response object. +func flattenCertificateAuthorityConfigPublicKey(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityConfigPublicKey { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigPublicKey{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigPublicKey + } + r.Key = dcl.FlattenString(m["key"]) + r.Format = flattenCertificateAuthorityConfigPublicKeyFormatEnum(m["format"]) + + return r +} + +// expandCertificateAuthorityKeySpecMap expands the contents of CertificateAuthorityKeySpec into a JSON +// request object. +func expandCertificateAuthorityKeySpecMap(c *Client, f map[string]CertificateAuthorityKeySpec, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityKeySpec(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityKeySpecSlice expands the contents of CertificateAuthorityKeySpec into a JSON +// request object. +func expandCertificateAuthorityKeySpecSlice(c *Client, f []CertificateAuthorityKeySpec, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityKeySpec(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityKeySpecMap flattens the contents of CertificateAuthorityKeySpec from a JSON +// response object. +func flattenCertificateAuthorityKeySpecMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityKeySpec { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityKeySpec{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityKeySpec{} + } + + items := make(map[string]CertificateAuthorityKeySpec) + for k, item := range a { + items[k] = *flattenCertificateAuthorityKeySpec(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityKeySpecSlice flattens the contents of CertificateAuthorityKeySpec from a JSON +// response object. +func flattenCertificateAuthorityKeySpecSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityKeySpec { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityKeySpec{} + } + + if len(a) == 0 { + return []CertificateAuthorityKeySpec{} + } + + items := make([]CertificateAuthorityKeySpec, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityKeySpec(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityKeySpec expands an instance of CertificateAuthorityKeySpec into a JSON +// request object. +func expandCertificateAuthorityKeySpec(c *Client, f *CertificateAuthorityKeySpec, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CloudKmsKeyVersion; !dcl.IsEmptyValueIndirect(v) { + m["cloudKmsKeyVersion"] = v + } + if v := f.Algorithm; !dcl.IsEmptyValueIndirect(v) { + m["algorithm"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityKeySpec flattens an instance of CertificateAuthorityKeySpec from a JSON +// response object. +func flattenCertificateAuthorityKeySpec(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityKeySpec { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityKeySpec{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityKeySpec + } + r.CloudKmsKeyVersion = dcl.FlattenString(m["cloudKmsKeyVersion"]) + r.Algorithm = flattenCertificateAuthorityKeySpecAlgorithmEnum(m["algorithm"]) + + return r +} + +// expandCertificateAuthoritySubordinateConfigMap expands the contents of CertificateAuthoritySubordinateConfig into a JSON +// request object. +func expandCertificateAuthoritySubordinateConfigMap(c *Client, f map[string]CertificateAuthoritySubordinateConfig, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthoritySubordinateConfig(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthoritySubordinateConfigSlice expands the contents of CertificateAuthoritySubordinateConfig into a JSON +// request object. +func expandCertificateAuthoritySubordinateConfigSlice(c *Client, f []CertificateAuthoritySubordinateConfig, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthoritySubordinateConfig(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthoritySubordinateConfigMap flattens the contents of CertificateAuthoritySubordinateConfig from a JSON +// response object. +func flattenCertificateAuthoritySubordinateConfigMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthoritySubordinateConfig { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthoritySubordinateConfig{} + } + + if len(a) == 0 { + return map[string]CertificateAuthoritySubordinateConfig{} + } + + items := make(map[string]CertificateAuthoritySubordinateConfig) + for k, item := range a { + items[k] = *flattenCertificateAuthoritySubordinateConfig(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthoritySubordinateConfigSlice flattens the contents of CertificateAuthoritySubordinateConfig from a JSON +// response object. +func flattenCertificateAuthoritySubordinateConfigSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthoritySubordinateConfig { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthoritySubordinateConfig{} + } + + if len(a) == 0 { + return []CertificateAuthoritySubordinateConfig{} + } + + items := make([]CertificateAuthoritySubordinateConfig, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthoritySubordinateConfig(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthoritySubordinateConfig expands an instance of CertificateAuthoritySubordinateConfig into a JSON +// request object. +func expandCertificateAuthoritySubordinateConfig(c *Client, f *CertificateAuthoritySubordinateConfig, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CertificateAuthority; !dcl.IsEmptyValueIndirect(v) { + m["certificateAuthority"] = v + } + if v, err := expandCertificateAuthoritySubordinateConfigPemIssuerChain(c, f.PemIssuerChain, res); err != nil { + return nil, fmt.Errorf("error expanding PemIssuerChain into pemIssuerChain: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["pemIssuerChain"] = v + } + + return m, nil +} + +// flattenCertificateAuthoritySubordinateConfig flattens an instance of CertificateAuthoritySubordinateConfig from a JSON +// response object. +func flattenCertificateAuthoritySubordinateConfig(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthoritySubordinateConfig { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthoritySubordinateConfig{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthoritySubordinateConfig + } + r.CertificateAuthority = dcl.FlattenString(m["certificateAuthority"]) + r.PemIssuerChain = flattenCertificateAuthoritySubordinateConfigPemIssuerChain(c, m["pemIssuerChain"], res) + + return r +} + +// expandCertificateAuthoritySubordinateConfigPemIssuerChainMap expands the contents of CertificateAuthoritySubordinateConfigPemIssuerChain into a JSON +// request object. +func expandCertificateAuthoritySubordinateConfigPemIssuerChainMap(c *Client, f map[string]CertificateAuthoritySubordinateConfigPemIssuerChain, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthoritySubordinateConfigPemIssuerChain(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthoritySubordinateConfigPemIssuerChainSlice expands the contents of CertificateAuthoritySubordinateConfigPemIssuerChain into a JSON +// request object. +func expandCertificateAuthoritySubordinateConfigPemIssuerChainSlice(c *Client, f []CertificateAuthoritySubordinateConfigPemIssuerChain, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthoritySubordinateConfigPemIssuerChain(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthoritySubordinateConfigPemIssuerChainMap flattens the contents of CertificateAuthoritySubordinateConfigPemIssuerChain from a JSON +// response object. +func flattenCertificateAuthoritySubordinateConfigPemIssuerChainMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthoritySubordinateConfigPemIssuerChain { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthoritySubordinateConfigPemIssuerChain{} + } + + if len(a) == 0 { + return map[string]CertificateAuthoritySubordinateConfigPemIssuerChain{} + } + + items := make(map[string]CertificateAuthoritySubordinateConfigPemIssuerChain) + for k, item := range a { + items[k] = *flattenCertificateAuthoritySubordinateConfigPemIssuerChain(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthoritySubordinateConfigPemIssuerChainSlice flattens the contents of CertificateAuthoritySubordinateConfigPemIssuerChain from a JSON +// response object. +func flattenCertificateAuthoritySubordinateConfigPemIssuerChainSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthoritySubordinateConfigPemIssuerChain { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthoritySubordinateConfigPemIssuerChain{} + } + + if len(a) == 0 { + return []CertificateAuthoritySubordinateConfigPemIssuerChain{} + } + + items := make([]CertificateAuthoritySubordinateConfigPemIssuerChain, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthoritySubordinateConfigPemIssuerChain(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthoritySubordinateConfigPemIssuerChain expands an instance of CertificateAuthoritySubordinateConfigPemIssuerChain into a JSON +// request object. +func expandCertificateAuthoritySubordinateConfigPemIssuerChain(c *Client, f *CertificateAuthoritySubordinateConfigPemIssuerChain, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.PemCertificates; v != nil { + m["pemCertificates"] = v + } + + return m, nil +} + +// flattenCertificateAuthoritySubordinateConfigPemIssuerChain flattens an instance of CertificateAuthoritySubordinateConfigPemIssuerChain from a JSON +// response object. +func flattenCertificateAuthoritySubordinateConfigPemIssuerChain(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthoritySubordinateConfigPemIssuerChain { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthoritySubordinateConfigPemIssuerChain{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthoritySubordinateConfigPemIssuerChain + } + r.PemCertificates = dcl.FlattenStringSlice(m["pemCertificates"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsMap expands the contents of CertificateAuthorityCaCertificateDescriptions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSlice expands the contents of CertificateAuthorityCaCertificateDescriptions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptions, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsMap flattens the contents of CertificateAuthorityCaCertificateDescriptions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptions{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptions{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptions) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSlice flattens the contents of CertificateAuthorityCaCertificateDescriptions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptions{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptions{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptions expands an instance of CertificateAuthorityCaCertificateDescriptions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptions(c *Client, f *CertificateAuthorityCaCertificateDescriptions, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, f.SubjectDescription, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectDescription into subjectDescription: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectDescription"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509Description(c, f.X509Description, res); err != nil { + return nil, fmt.Errorf("error expanding X509Description into x509Description: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["x509Description"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsPublicKey(c, f.PublicKey, res); err != nil { + return nil, fmt.Errorf("error expanding PublicKey into publicKey: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["publicKey"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, f.SubjectKeyId, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectKeyId into subjectKeyId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectKeyId"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, f.AuthorityKeyId, res); err != nil { + return nil, fmt.Errorf("error expanding AuthorityKeyId into authorityKeyId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["authorityKeyId"] = v + } + if v := f.CrlDistributionPoints; v != nil { + m["crlDistributionPoints"] = v + } + if v := f.AiaIssuingCertificateUrls; v != nil { + m["aiaIssuingCertificateUrls"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, f.CertFingerprint, res); err != nil { + return nil, fmt.Errorf("error expanding CertFingerprint into certFingerprint: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["certFingerprint"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptions flattens an instance of CertificateAuthorityCaCertificateDescriptions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptions(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptions + } + r.SubjectDescription = flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, m["subjectDescription"], res) + r.X509Description = flattenCertificateAuthorityCaCertificateDescriptionsX509Description(c, m["x509Description"], res) + r.PublicKey = flattenCertificateAuthorityCaCertificateDescriptionsPublicKey(c, m["publicKey"], res) + r.SubjectKeyId = flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, m["subjectKeyId"], res) + r.AuthorityKeyId = flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, m["authorityKeyId"], res) + r.CrlDistributionPoints = dcl.FlattenStringSlice(m["crlDistributionPoints"]) + r.AiaIssuingCertificateUrls = dcl.FlattenStringSlice(m["aiaIssuingCertificateUrls"]) + r.CertFingerprint = flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, m["certFingerprint"], res) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionMap expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescription into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescription, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescription into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsSubjectDescription, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescription from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescription) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescription from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescription, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescription expands an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescription into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c *Client, f *CertificateAuthorityCaCertificateDescriptionsSubjectDescription, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, f.Subject, res); err != nil { + return nil, fmt.Errorf("error expanding Subject into subject: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subject"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, f.SubjectAltName, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectAltName into subjectAltName: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectAltName"] = v + } + if v := f.HexSerialNumber; !dcl.IsEmptyValueIndirect(v) { + m["hexSerialNumber"] = v + } + if v := f.Lifetime; !dcl.IsEmptyValueIndirect(v) { + m["lifetime"] = v + } + if v := f.NotBeforeTime; !dcl.IsEmptyValueIndirect(v) { + m["notBeforeTime"] = v + } + if v := f.NotAfterTime; !dcl.IsEmptyValueIndirect(v) { + m["notAfterTime"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescription flattens an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescription from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescription(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsSubjectDescription { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescription + } + r.Subject = flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, m["subject"], res) + r.SubjectAltName = flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, m["subjectAltName"], res) + r.HexSerialNumber = dcl.FlattenString(m["hexSerialNumber"]) + r.Lifetime = dcl.FlattenString(m["lifetime"]) + r.NotBeforeTime = dcl.FlattenString(m["notBeforeTime"]) + r.NotAfterTime = dcl.FlattenString(m["notAfterTime"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectMap expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject expands an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c *Client, f *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CommonName; !dcl.IsEmptyValueIndirect(v) { + m["commonName"] = v + } + if v := f.CountryCode; !dcl.IsEmptyValueIndirect(v) { + m["countryCode"] = v + } + if v := f.Organization; !dcl.IsEmptyValueIndirect(v) { + m["organization"] = v + } + if v := f.OrganizationalUnit; !dcl.IsEmptyValueIndirect(v) { + m["organizationalUnit"] = v + } + if v := f.Locality; !dcl.IsEmptyValueIndirect(v) { + m["locality"] = v + } + if v := f.Province; !dcl.IsEmptyValueIndirect(v) { + m["province"] = v + } + if v := f.StreetAddress; !dcl.IsEmptyValueIndirect(v) { + m["streetAddress"] = v + } + if v := f.PostalCode; !dcl.IsEmptyValueIndirect(v) { + m["postalCode"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject flattens an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject + } + r.CommonName = dcl.FlattenString(m["commonName"]) + r.CountryCode = dcl.FlattenString(m["countryCode"]) + r.Organization = dcl.FlattenString(m["organization"]) + r.OrganizationalUnit = dcl.FlattenString(m["organizationalUnit"]) + r.Locality = dcl.FlattenString(m["locality"]) + r.Province = dcl.FlattenString(m["province"]) + r.StreetAddress = dcl.FlattenString(m["streetAddress"]) + r.PostalCode = dcl.FlattenString(m["postalCode"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameMap expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName expands an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c *Client, f *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DnsNames; v != nil { + m["dnsNames"] = v + } + if v := f.Uris; v != nil { + m["uris"] = v + } + if v := f.EmailAddresses; v != nil { + m["emailAddresses"] = v + } + if v := f.IPAddresses; v != nil { + m["ipAddresses"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(c, f.CustomSans, res); err != nil { + return nil, fmt.Errorf("error expanding CustomSans into customSans: %w", err) + } else if v != nil { + m["customSans"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName flattens an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName + } + r.DnsNames = dcl.FlattenStringSlice(m["dnsNames"]) + r.Uris = dcl.FlattenStringSlice(m["uris"]) + r.EmailAddresses = dcl.FlattenStringSlice(m["emailAddresses"]) + r.IPAddresses = dcl.FlattenStringSlice(m["ipAddresses"]) + r.CustomSans = flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(c, m["customSans"], res) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansMap expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans expands an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c *Client, f *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans flattens an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans + } + r.ObjectId = flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdMap expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId expands an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c *Client, f *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId flattens an instance of CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509Description into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509Description, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509Description(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509Description into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509Description, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509Description(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509Description from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509Description { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509Description{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509Description{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509Description) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509Description(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509Description from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509Description { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509Description{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509Description{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509Description, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509Description(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509Description expands an instance of CertificateAuthorityCaCertificateDescriptionsX509Description into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509Description(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509Description, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, f.KeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding KeyUsage into keyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keyUsage"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, f.CaOptions, res); err != nil { + return nil, fmt.Errorf("error expanding CaOptions into caOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caOptions"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(c, f.PolicyIds, res); err != nil { + return nil, fmt.Errorf("error expanding PolicyIds into policyIds: %w", err) + } else if v != nil { + m["policyIds"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509Description flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509Description from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509Description(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509Description { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509Description{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509Description + } + r.KeyUsage = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, m["keyUsage"], res) + r.CaOptions = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, m["caOptions"], res) + r.PolicyIds = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(c, m["policyIds"], res) + r.AiaOcspServers = dcl.FlattenStringSlice(m["aiaOcspServers"]) + r.AdditionalExtensions = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, f.BaseKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding BaseKeyUsage into baseKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baseKeyUsage"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, f.ExtendedKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding ExtendedKeyUsage into extendedKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["extendedKeyUsage"] = v + } + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c, f.UnknownExtendedKeyUsages, res); err != nil { + return nil, fmt.Errorf("error expanding UnknownExtendedKeyUsages into unknownExtendedKeyUsages: %w", err) + } else if v != nil { + m["unknownExtendedKeyUsages"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage + } + r.BaseKeyUsage = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, m["baseKeyUsage"], res) + r.ExtendedKeyUsage = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, m["extendedKeyUsage"], res) + r.UnknownExtendedKeyUsages = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c, m["unknownExtendedKeyUsages"], res) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DigitalSignature; !dcl.IsEmptyValueIndirect(v) { + m["digitalSignature"] = v + } + if v := f.ContentCommitment; !dcl.IsEmptyValueIndirect(v) { + m["contentCommitment"] = v + } + if v := f.KeyEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["keyEncipherment"] = v + } + if v := f.DataEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["dataEncipherment"] = v + } + if v := f.KeyAgreement; !dcl.IsEmptyValueIndirect(v) { + m["keyAgreement"] = v + } + if v := f.CertSign; !dcl.IsEmptyValueIndirect(v) { + m["certSign"] = v + } + if v := f.CrlSign; !dcl.IsEmptyValueIndirect(v) { + m["crlSign"] = v + } + if v := f.EncipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["encipherOnly"] = v + } + if v := f.DecipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["decipherOnly"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ServerAuth; !dcl.IsEmptyValueIndirect(v) { + m["serverAuth"] = v + } + if v := f.ClientAuth; !dcl.IsEmptyValueIndirect(v) { + m["clientAuth"] = v + } + if v := f.CodeSigning; !dcl.IsEmptyValueIndirect(v) { + m["codeSigning"] = v + } + if v := f.EmailProtection; !dcl.IsEmptyValueIndirect(v) { + m["emailProtection"] = v + } + if v := f.TimeStamping; !dcl.IsEmptyValueIndirect(v) { + m["timeStamping"] = v + } + if v := f.OcspSigning; !dcl.IsEmptyValueIndirect(v) { + m["ocspSigning"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + if v := f.MaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["maxIssuerPathLength"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions + } + r.IsCa = dcl.FlattenBool(m["isCa"]) + r.MaxIssuerPathLength = dcl.FlattenInteger(m["maxIssuerPathLength"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions + } + r.ObjectId = flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdMap expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId expands an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c *Client, f *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId flattens an instance of CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsPublicKeyMap expands the contents of CertificateAuthorityCaCertificateDescriptionsPublicKey into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsPublicKeyMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsPublicKey, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsPublicKey(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsPublicKeySlice expands the contents of CertificateAuthorityCaCertificateDescriptionsPublicKey into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsPublicKeySlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsPublicKey, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsPublicKey(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsPublicKey from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsPublicKey { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsPublicKey{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsPublicKey{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsPublicKey) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsPublicKey(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsPublicKeySlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsPublicKey from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsPublicKeySlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsPublicKey { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsPublicKey{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsPublicKey{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsPublicKey, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsPublicKey(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsPublicKey expands an instance of CertificateAuthorityCaCertificateDescriptionsPublicKey into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsPublicKey(c *Client, f *CertificateAuthorityCaCertificateDescriptionsPublicKey, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Key; !dcl.IsEmptyValueIndirect(v) { + m["key"] = v + } + if v := f.Format; !dcl.IsEmptyValueIndirect(v) { + m["format"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsPublicKey flattens an instance of CertificateAuthorityCaCertificateDescriptionsPublicKey from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsPublicKey(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsPublicKey { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsPublicKey{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsPublicKey + } + r.Key = dcl.FlattenString(m["key"]) + r.Format = flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum(m["format"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdMap expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectKeyId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsSubjectKeyId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectKeyId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsSubjectKeyId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyId expands an instance of CertificateAuthorityCaCertificateDescriptionsSubjectKeyId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c *Client, f *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.KeyId; !dcl.IsEmptyValueIndirect(v) { + m["keyId"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyId flattens an instance of CertificateAuthorityCaCertificateDescriptionsSubjectKeyId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsSubjectKeyId(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsSubjectKeyId + } + r.KeyId = dcl.FlattenString(m["keyId"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdMap expands the contents of CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId expands an instance of CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c *Client, f *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.KeyId; !dcl.IsEmptyValueIndirect(v) { + m["keyId"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId flattens an instance of CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsAuthorityKeyId + } + r.KeyId = dcl.FlattenString(m["keyId"]) + + return r +} + +// expandCertificateAuthorityCaCertificateDescriptionsCertFingerprintMap expands the contents of CertificateAuthorityCaCertificateDescriptionsCertFingerprint into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsCertFingerprintMap(c *Client, f map[string]CertificateAuthorityCaCertificateDescriptionsCertFingerprint, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityCaCertificateDescriptionsCertFingerprintSlice expands the contents of CertificateAuthorityCaCertificateDescriptionsCertFingerprint into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsCertFingerprintSlice(c *Client, f []CertificateAuthorityCaCertificateDescriptionsCertFingerprint, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprintMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsCertFingerprint from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprintMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsCertFingerprint) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprintSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsCertFingerprint from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprintSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsCertFingerprint, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityCaCertificateDescriptionsCertFingerprint expands an instance of CertificateAuthorityCaCertificateDescriptionsCertFingerprint into a JSON +// request object. +func expandCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c *Client, f *CertificateAuthorityCaCertificateDescriptionsCertFingerprint, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Sha256Hash; !dcl.IsEmptyValueIndirect(v) { + m["sha256Hash"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprint flattens an instance of CertificateAuthorityCaCertificateDescriptionsCertFingerprint from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsCertFingerprint(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityCaCertificateDescriptionsCertFingerprint { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityCaCertificateDescriptionsCertFingerprint + } + r.Sha256Hash = dcl.FlattenString(m["sha256Hash"]) + + return r +} + +// expandCertificateAuthorityAccessUrlsMap expands the contents of CertificateAuthorityAccessUrls into a JSON +// request object. +func expandCertificateAuthorityAccessUrlsMap(c *Client, f map[string]CertificateAuthorityAccessUrls, res *CertificateAuthority) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateAuthorityAccessUrls(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateAuthorityAccessUrlsSlice expands the contents of CertificateAuthorityAccessUrls into a JSON +// request object. +func expandCertificateAuthorityAccessUrlsSlice(c *Client, f []CertificateAuthorityAccessUrls, res *CertificateAuthority) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateAuthorityAccessUrls(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateAuthorityAccessUrlsMap flattens the contents of CertificateAuthorityAccessUrls from a JSON +// response object. +func flattenCertificateAuthorityAccessUrlsMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityAccessUrls { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityAccessUrls{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityAccessUrls{} + } + + items := make(map[string]CertificateAuthorityAccessUrls) + for k, item := range a { + items[k] = *flattenCertificateAuthorityAccessUrls(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateAuthorityAccessUrlsSlice flattens the contents of CertificateAuthorityAccessUrls from a JSON +// response object. +func flattenCertificateAuthorityAccessUrlsSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityAccessUrls { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityAccessUrls{} + } + + if len(a) == 0 { + return []CertificateAuthorityAccessUrls{} + } + + items := make([]CertificateAuthorityAccessUrls, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityAccessUrls(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateAuthorityAccessUrls expands an instance of CertificateAuthorityAccessUrls into a JSON +// request object. +func expandCertificateAuthorityAccessUrls(c *Client, f *CertificateAuthorityAccessUrls, res *CertificateAuthority) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CaCertificateAccessUrl; !dcl.IsEmptyValueIndirect(v) { + m["caCertificateAccessUrl"] = v + } + if v := f.CrlAccessUrls; v != nil { + m["crlAccessUrls"] = v + } + + return m, nil +} + +// flattenCertificateAuthorityAccessUrls flattens an instance of CertificateAuthorityAccessUrls from a JSON +// response object. +func flattenCertificateAuthorityAccessUrls(c *Client, i interface{}, res *CertificateAuthority) *CertificateAuthorityAccessUrls { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateAuthorityAccessUrls{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityAccessUrls + } + r.CaCertificateAccessUrl = dcl.FlattenString(m["caCertificateAccessUrl"]) + r.CrlAccessUrls = dcl.FlattenStringSlice(m["crlAccessUrls"]) + + return r +} + +// flattenCertificateAuthorityTypeEnumMap flattens the contents of CertificateAuthorityTypeEnum from a JSON +// response object. +func flattenCertificateAuthorityTypeEnumMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityTypeEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityTypeEnum{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityTypeEnum{} + } + + items := make(map[string]CertificateAuthorityTypeEnum) + for k, item := range a { + items[k] = *flattenCertificateAuthorityTypeEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateAuthorityTypeEnumSlice flattens the contents of CertificateAuthorityTypeEnum from a JSON +// response object. +func flattenCertificateAuthorityTypeEnumSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityTypeEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityTypeEnum{} + } + + if len(a) == 0 { + return []CertificateAuthorityTypeEnum{} + } + + items := make([]CertificateAuthorityTypeEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityTypeEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateAuthorityTypeEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateAuthorityTypeEnum with the same value as that string. +func flattenCertificateAuthorityTypeEnum(i interface{}) *CertificateAuthorityTypeEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateAuthorityTypeEnumRef(s) +} + +// flattenCertificateAuthorityConfigPublicKeyFormatEnumMap flattens the contents of CertificateAuthorityConfigPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateAuthorityConfigPublicKeyFormatEnumMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityConfigPublicKeyFormatEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityConfigPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityConfigPublicKeyFormatEnum{} + } + + items := make(map[string]CertificateAuthorityConfigPublicKeyFormatEnum) + for k, item := range a { + items[k] = *flattenCertificateAuthorityConfigPublicKeyFormatEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateAuthorityConfigPublicKeyFormatEnumSlice flattens the contents of CertificateAuthorityConfigPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateAuthorityConfigPublicKeyFormatEnumSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityConfigPublicKeyFormatEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityConfigPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return []CertificateAuthorityConfigPublicKeyFormatEnum{} + } + + items := make([]CertificateAuthorityConfigPublicKeyFormatEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityConfigPublicKeyFormatEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateAuthorityConfigPublicKeyFormatEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateAuthorityConfigPublicKeyFormatEnum with the same value as that string. +func flattenCertificateAuthorityConfigPublicKeyFormatEnum(i interface{}) *CertificateAuthorityConfigPublicKeyFormatEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateAuthorityConfigPublicKeyFormatEnumRef(s) +} + +// flattenCertificateAuthorityKeySpecAlgorithmEnumMap flattens the contents of CertificateAuthorityKeySpecAlgorithmEnum from a JSON +// response object. +func flattenCertificateAuthorityKeySpecAlgorithmEnumMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityKeySpecAlgorithmEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityKeySpecAlgorithmEnum{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityKeySpecAlgorithmEnum{} + } + + items := make(map[string]CertificateAuthorityKeySpecAlgorithmEnum) + for k, item := range a { + items[k] = *flattenCertificateAuthorityKeySpecAlgorithmEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateAuthorityKeySpecAlgorithmEnumSlice flattens the contents of CertificateAuthorityKeySpecAlgorithmEnum from a JSON +// response object. +func flattenCertificateAuthorityKeySpecAlgorithmEnumSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityKeySpecAlgorithmEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityKeySpecAlgorithmEnum{} + } + + if len(a) == 0 { + return []CertificateAuthorityKeySpecAlgorithmEnum{} + } + + items := make([]CertificateAuthorityKeySpecAlgorithmEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityKeySpecAlgorithmEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateAuthorityKeySpecAlgorithmEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateAuthorityKeySpecAlgorithmEnum with the same value as that string. +func flattenCertificateAuthorityKeySpecAlgorithmEnum(i interface{}) *CertificateAuthorityKeySpecAlgorithmEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateAuthorityKeySpecAlgorithmEnumRef(s) +} + +// flattenCertificateAuthorityTierEnumMap flattens the contents of CertificateAuthorityTierEnum from a JSON +// response object. +func flattenCertificateAuthorityTierEnumMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityTierEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityTierEnum{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityTierEnum{} + } + + items := make(map[string]CertificateAuthorityTierEnum) + for k, item := range a { + items[k] = *flattenCertificateAuthorityTierEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateAuthorityTierEnumSlice flattens the contents of CertificateAuthorityTierEnum from a JSON +// response object. +func flattenCertificateAuthorityTierEnumSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityTierEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityTierEnum{} + } + + if len(a) == 0 { + return []CertificateAuthorityTierEnum{} + } + + items := make([]CertificateAuthorityTierEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityTierEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateAuthorityTierEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateAuthorityTierEnum with the same value as that string. +func flattenCertificateAuthorityTierEnum(i interface{}) *CertificateAuthorityTierEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateAuthorityTierEnumRef(s) +} + +// flattenCertificateAuthorityStateEnumMap flattens the contents of CertificateAuthorityStateEnum from a JSON +// response object. +func flattenCertificateAuthorityStateEnumMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityStateEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityStateEnum{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityStateEnum{} + } + + items := make(map[string]CertificateAuthorityStateEnum) + for k, item := range a { + items[k] = *flattenCertificateAuthorityStateEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateAuthorityStateEnumSlice flattens the contents of CertificateAuthorityStateEnum from a JSON +// response object. +func flattenCertificateAuthorityStateEnumSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityStateEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityStateEnum{} + } + + if len(a) == 0 { + return []CertificateAuthorityStateEnum{} + } + + items := make([]CertificateAuthorityStateEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityStateEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateAuthorityStateEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateAuthorityStateEnum with the same value as that string. +func flattenCertificateAuthorityStateEnum(i interface{}) *CertificateAuthorityStateEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateAuthorityStateEnumRef(s) +} + +// flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumMap flattens the contents of CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumMap(c *Client, i interface{}, res *CertificateAuthority) map[string]CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return map[string]CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum{} + } + + items := make(map[string]CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum) + for k, item := range a { + items[k] = *flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumSlice flattens the contents of CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumSlice(c *Client, i interface{}, res *CertificateAuthority) []CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return []CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum{} + } + + items := make([]CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum with the same value as that string. +func flattenCertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum(i interface{}) *CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnumRef(s) +} + +// This function returns a matcher that checks whether a serialized resource matches this resource +// in its parameters (as defined by the fields in a Get, which definitionally define resource +// identity). This is useful in extracting the element from a List call. +func (r *CertificateAuthority) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalCertificateAuthority(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if nr.Project == nil && ncr.Project == nil { + c.Config.Logger.Info("Both Project fields null - considering equal.") + } else if nr.Project == nil || ncr.Project == nil { + c.Config.Logger.Info("Only one Project field is null - considering unequal.") + return false + } else if *nr.Project != *ncr.Project { + return false + } + if nr.Location == nil && ncr.Location == nil { + c.Config.Logger.Info("Both Location fields null - considering equal.") + } else if nr.Location == nil || ncr.Location == nil { + c.Config.Logger.Info("Only one Location field is null - considering unequal.") + return false + } else if *nr.Location != *ncr.Location { + return false + } + if nr.CaPool == nil && ncr.CaPool == nil { + c.Config.Logger.Info("Both CaPool fields null - considering equal.") + } else if nr.CaPool == nil || ncr.CaPool == nil { + c.Config.Logger.Info("Only one CaPool field is null - considering unequal.") + return false + } else if *nr.CaPool != *ncr.CaPool { + return false + } + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + return true + } +} + +type certificateAuthorityDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp certificateAuthorityApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToCertificateAuthorityDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]certificateAuthorityDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []certificateAuthorityDiff + // For each operation name, create a certificateAuthorityDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := certificateAuthorityDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToCertificateAuthorityApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToCertificateAuthorityApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (certificateAuthorityApiOperation, error) { + switch opName { + + case "updateCertificateAuthorityUpdateCertificateAuthorityOperation": + return &updateCertificateAuthorityUpdateCertificateAuthorityOperation{FieldDiffs: fieldDiffs}, nil + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractCertificateAuthorityFields(r *CertificateAuthority) error { + vConfig := r.Config + if vConfig == nil { + // note: explicitly not the empty object. + vConfig = &CertificateAuthorityConfig{} + } + if err := extractCertificateAuthorityConfigFields(r, vConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vConfig) { + r.Config = vConfig + } + vKeySpec := r.KeySpec + if vKeySpec == nil { + // note: explicitly not the empty object. + vKeySpec = &CertificateAuthorityKeySpec{} + } + if err := extractCertificateAuthorityKeySpecFields(r, vKeySpec); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeySpec) { + r.KeySpec = vKeySpec + } + vSubordinateConfig := r.SubordinateConfig + if vSubordinateConfig == nil { + // note: explicitly not the empty object. + vSubordinateConfig = &CertificateAuthoritySubordinateConfig{} + } + if err := extractCertificateAuthoritySubordinateConfigFields(r, vSubordinateConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubordinateConfig) { + r.SubordinateConfig = vSubordinateConfig + } + vAccessUrls := r.AccessUrls + if vAccessUrls == nil { + // note: explicitly not the empty object. + vAccessUrls = &CertificateAuthorityAccessUrls{} + } + if err := extractCertificateAuthorityAccessUrlsFields(r, vAccessUrls); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAccessUrls) { + r.AccessUrls = vAccessUrls + } + return nil +} +func extractCertificateAuthorityConfigFields(r *CertificateAuthority, o *CertificateAuthorityConfig) error { + vSubjectConfig := o.SubjectConfig + if vSubjectConfig == nil { + // note: explicitly not the empty object. + vSubjectConfig = &CertificateAuthorityConfigSubjectConfig{} + } + if err := extractCertificateAuthorityConfigSubjectConfigFields(r, vSubjectConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectConfig) { + o.SubjectConfig = vSubjectConfig + } + vX509Config := o.X509Config + if vX509Config == nil { + // note: explicitly not the empty object. + vX509Config = &CertificateAuthorityConfigX509Config{} + } + if err := extractCertificateAuthorityConfigX509ConfigFields(r, vX509Config); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Config) { + o.X509Config = vX509Config + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateAuthorityConfigPublicKey{} + } + if err := extractCertificateAuthorityConfigPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + return nil +} +func extractCertificateAuthorityConfigSubjectConfigFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfig) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateAuthorityConfigSubjectConfigSubject{} + } + if err := extractCertificateAuthorityConfigSubjectConfigSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateAuthorityConfigSubjectConfigSubjectAltName{} + } + if err := extractCertificateAuthorityConfigSubjectConfigSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func extractCertificateAuthorityConfigSubjectConfigSubjectFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubject) error { + return nil +} +func extractCertificateAuthorityConfigSubjectConfigSubjectAltNameFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubjectAltName) error { + return nil +} +func extractCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + } + if err := extractCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) error { + return nil +} +func extractCertificateAuthorityConfigX509ConfigFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509Config) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsage{} + } + if err := extractCertificateAuthorityConfigX509ConfigKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateAuthorityConfigX509ConfigCaOptions{} + } + if err := extractCertificateAuthorityConfigX509ConfigCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func extractCertificateAuthorityConfigX509ConfigKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + } + if err := extractCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func extractCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) error { + return nil +} +func extractCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) error { + return nil +} +func extractCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func extractCertificateAuthorityConfigX509ConfigCaOptionsFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigCaOptions) error { + return nil +} +func extractCertificateAuthorityConfigX509ConfigPolicyIdsFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigPolicyIds) error { + return nil +} +func extractCertificateAuthorityConfigX509ConfigAdditionalExtensionsFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + } + if err := extractCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) error { + return nil +} +func extractCertificateAuthorityConfigPublicKeyFields(r *CertificateAuthority, o *CertificateAuthorityConfigPublicKey) error { + return nil +} +func extractCertificateAuthorityKeySpecFields(r *CertificateAuthority, o *CertificateAuthorityKeySpec) error { + return nil +} +func extractCertificateAuthoritySubordinateConfigFields(r *CertificateAuthority, o *CertificateAuthoritySubordinateConfig) error { + vPemIssuerChain := o.PemIssuerChain + if vPemIssuerChain == nil { + // note: explicitly not the empty object. + vPemIssuerChain = &CertificateAuthoritySubordinateConfigPemIssuerChain{} + } + if err := extractCertificateAuthoritySubordinateConfigPemIssuerChainFields(r, vPemIssuerChain); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPemIssuerChain) { + o.PemIssuerChain = vPemIssuerChain + } + return nil +} +func extractCertificateAuthoritySubordinateConfigPemIssuerChainFields(r *CertificateAuthority, o *CertificateAuthoritySubordinateConfigPemIssuerChain) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptions) error { + vSubjectDescription := o.SubjectDescription + if vSubjectDescription == nil { + // note: explicitly not the empty object. + vSubjectDescription = &CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionFields(r, vSubjectDescription); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectDescription) { + o.SubjectDescription = vSubjectDescription + } + vX509Description := o.X509Description + if vX509Description == nil { + // note: explicitly not the empty object. + vX509Description = &CertificateAuthorityCaCertificateDescriptionsX509Description{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionFields(r, vX509Description); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Description) { + o.X509Description = vX509Description + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateAuthorityCaCertificateDescriptionsPublicKey{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + vSubjectKeyId := o.SubjectKeyId + if vSubjectKeyId == nil { + // note: explicitly not the empty object. + vSubjectKeyId = &CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdFields(r, vSubjectKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectKeyId) { + o.SubjectKeyId = vSubjectKeyId + } + vAuthorityKeyId := o.AuthorityKeyId + if vAuthorityKeyId == nil { + // note: explicitly not the empty object. + vAuthorityKeyId = &CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdFields(r, vAuthorityKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAuthorityKeyId) { + o.AuthorityKeyId = vAuthorityKeyId + } + vCertFingerprint := o.CertFingerprint + if vCertFingerprint == nil { + // note: explicitly not the empty object. + vCertFingerprint = &CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsCertFingerprintFields(r, vCertFingerprint); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCertFingerprint) { + o.CertFingerprint = vCertFingerprint + } + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509Description) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsPublicKeyFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsPublicKey) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) error { + return nil +} +func extractCertificateAuthorityCaCertificateDescriptionsCertFingerprintFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) error { + return nil +} +func extractCertificateAuthorityAccessUrlsFields(r *CertificateAuthority, o *CertificateAuthorityAccessUrls) error { + return nil +} + +func postReadExtractCertificateAuthorityFields(r *CertificateAuthority) error { + vConfig := r.Config + if vConfig == nil { + // note: explicitly not the empty object. + vConfig = &CertificateAuthorityConfig{} + } + if err := postReadExtractCertificateAuthorityConfigFields(r, vConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vConfig) { + r.Config = vConfig + } + vKeySpec := r.KeySpec + if vKeySpec == nil { + // note: explicitly not the empty object. + vKeySpec = &CertificateAuthorityKeySpec{} + } + if err := postReadExtractCertificateAuthorityKeySpecFields(r, vKeySpec); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeySpec) { + r.KeySpec = vKeySpec + } + vSubordinateConfig := r.SubordinateConfig + if vSubordinateConfig == nil { + // note: explicitly not the empty object. + vSubordinateConfig = &CertificateAuthoritySubordinateConfig{} + } + if err := postReadExtractCertificateAuthoritySubordinateConfigFields(r, vSubordinateConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubordinateConfig) { + r.SubordinateConfig = vSubordinateConfig + } + vAccessUrls := r.AccessUrls + if vAccessUrls == nil { + // note: explicitly not the empty object. + vAccessUrls = &CertificateAuthorityAccessUrls{} + } + if err := postReadExtractCertificateAuthorityAccessUrlsFields(r, vAccessUrls); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAccessUrls) { + r.AccessUrls = vAccessUrls + } + return nil +} +func postReadExtractCertificateAuthorityConfigFields(r *CertificateAuthority, o *CertificateAuthorityConfig) error { + vSubjectConfig := o.SubjectConfig + if vSubjectConfig == nil { + // note: explicitly not the empty object. + vSubjectConfig = &CertificateAuthorityConfigSubjectConfig{} + } + if err := extractCertificateAuthorityConfigSubjectConfigFields(r, vSubjectConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectConfig) { + o.SubjectConfig = vSubjectConfig + } + vX509Config := o.X509Config + if vX509Config == nil { + // note: explicitly not the empty object. + vX509Config = &CertificateAuthorityConfigX509Config{} + } + if err := extractCertificateAuthorityConfigX509ConfigFields(r, vX509Config); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Config) { + o.X509Config = vX509Config + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateAuthorityConfigPublicKey{} + } + if err := extractCertificateAuthorityConfigPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + return nil +} +func postReadExtractCertificateAuthorityConfigSubjectConfigFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfig) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateAuthorityConfigSubjectConfigSubject{} + } + if err := extractCertificateAuthorityConfigSubjectConfigSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateAuthorityConfigSubjectConfigSubjectAltName{} + } + if err := extractCertificateAuthorityConfigSubjectConfigSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func postReadExtractCertificateAuthorityConfigSubjectConfigSubjectFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubject) error { + return nil +} +func postReadExtractCertificateAuthorityConfigSubjectConfigSubjectAltNameFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubjectAltName) error { + return nil +} +func postReadExtractCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId{} + } + if err := extractCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId) error { + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509Config) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsage{} + } + if err := extractCertificateAuthorityConfigX509ConfigKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateAuthorityConfigX509ConfigCaOptions{} + } + if err := extractCertificateAuthorityConfigX509ConfigCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage{} + } + if err := extractCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage) error { + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage) error { + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigCaOptionsFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigCaOptions) error { + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigPolicyIdsFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigPolicyIds) error { + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigAdditionalExtensionsFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId{} + } + if err := extractCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId) error { + return nil +} +func postReadExtractCertificateAuthorityConfigPublicKeyFields(r *CertificateAuthority, o *CertificateAuthorityConfigPublicKey) error { + return nil +} +func postReadExtractCertificateAuthorityKeySpecFields(r *CertificateAuthority, o *CertificateAuthorityKeySpec) error { + return nil +} +func postReadExtractCertificateAuthoritySubordinateConfigFields(r *CertificateAuthority, o *CertificateAuthoritySubordinateConfig) error { + vPemIssuerChain := o.PemIssuerChain + if vPemIssuerChain == nil { + // note: explicitly not the empty object. + vPemIssuerChain = &CertificateAuthoritySubordinateConfigPemIssuerChain{} + } + if err := extractCertificateAuthoritySubordinateConfigPemIssuerChainFields(r, vPemIssuerChain); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPemIssuerChain) { + o.PemIssuerChain = vPemIssuerChain + } + return nil +} +func postReadExtractCertificateAuthoritySubordinateConfigPemIssuerChainFields(r *CertificateAuthority, o *CertificateAuthoritySubordinateConfigPemIssuerChain) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptions) error { + vSubjectDescription := o.SubjectDescription + if vSubjectDescription == nil { + // note: explicitly not the empty object. + vSubjectDescription = &CertificateAuthorityCaCertificateDescriptionsSubjectDescription{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionFields(r, vSubjectDescription); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectDescription) { + o.SubjectDescription = vSubjectDescription + } + vX509Description := o.X509Description + if vX509Description == nil { + // note: explicitly not the empty object. + vX509Description = &CertificateAuthorityCaCertificateDescriptionsX509Description{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionFields(r, vX509Description); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Description) { + o.X509Description = vX509Description + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateAuthorityCaCertificateDescriptionsPublicKey{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + vSubjectKeyId := o.SubjectKeyId + if vSubjectKeyId == nil { + // note: explicitly not the empty object. + vSubjectKeyId = &CertificateAuthorityCaCertificateDescriptionsSubjectKeyId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdFields(r, vSubjectKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectKeyId) { + o.SubjectKeyId = vSubjectKeyId + } + vAuthorityKeyId := o.AuthorityKeyId + if vAuthorityKeyId == nil { + // note: explicitly not the empty object. + vAuthorityKeyId = &CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdFields(r, vAuthorityKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAuthorityKeyId) { + o.AuthorityKeyId = vAuthorityKeyId + } + vCertFingerprint := o.CertFingerprint + if vCertFingerprint == nil { + // note: explicitly not the empty object. + vCertFingerprint = &CertificateAuthorityCaCertificateDescriptionsCertFingerprint{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsCertFingerprintFields(r, vCertFingerprint); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCertFingerprint) { + o.CertFingerprint = vCertFingerprint + } + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescription) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509Description) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsageFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsagesFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptionsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIdsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId{} + } + if err := extractCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsPublicKeyFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsPublicKey) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsSubjectKeyIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsSubjectKeyId) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsAuthorityKeyIdFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId) error { + return nil +} +func postReadExtractCertificateAuthorityCaCertificateDescriptionsCertFingerprintFields(r *CertificateAuthority, o *CertificateAuthorityCaCertificateDescriptionsCertFingerprint) error { + return nil +} +func postReadExtractCertificateAuthorityAccessUrlsFields(r *CertificateAuthority, o *CertificateAuthorityAccessUrls) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_schema.go new file mode 100644 index 00000000000..0d862244fa9 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_schema.go @@ -0,0 +1,1443 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLCertificateAuthoritySchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "Privateca/CertificateAuthority", + Description: "The Privateca CertificateAuthority resource", + StructName: "CertificateAuthority", + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a CertificateAuthority", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificateAuthority", + Required: true, + Description: "A full instance of a CertificateAuthority", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a CertificateAuthority", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificateAuthority", + Required: true, + Description: "A full instance of a CertificateAuthority", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a CertificateAuthority", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificateAuthority", + Required: true, + Description: "A full instance of a CertificateAuthority", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all CertificateAuthority", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "caPool", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many CertificateAuthority", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "caPool", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "CertificateAuthority": &dcl.Component{ + Title: "CertificateAuthority", + ID: "projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificateAuthorities/{{name}}", + ParentContainer: "project", + LabelsField: "labels", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "name", + "type", + "config", + "lifetime", + "keySpec", + "project", + "location", + "caPool", + }, + Properties: map[string]*dcl.Property{ + "accessUrls": &dcl.Property{ + Type: "object", + GoName: "AccessUrls", + GoType: "CertificateAuthorityAccessUrls", + ReadOnly: true, + Description: "Output only. URLs for accessing content published by this CA, such as the CA certificate and CRLs.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "caCertificateAccessUrl": &dcl.Property{ + Type: "string", + GoName: "CaCertificateAccessUrl", + Description: "The URL where this CertificateAuthority's CA certificate is published. This will only be set for CAs that have been activated.", + Immutable: true, + }, + "crlAccessUrls": &dcl.Property{ + Type: "array", + GoName: "CrlAccessUrls", + Description: "The URLs where this CertificateAuthority's CRLs are published. This will only be set for CAs that have been activated.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + "caCertificateDescriptions": &dcl.Property{ + Type: "array", + GoName: "CaCertificateDescriptions", + ReadOnly: true, + Description: "Output only. A structured description of this CertificateAuthority's CA certificate and its issuers. Ordered as self-to-root.", + Immutable: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityCaCertificateDescriptions", + Properties: map[string]*dcl.Property{ + "aiaIssuingCertificateUrls": &dcl.Property{ + Type: "array", + GoName: "AiaIssuingCertificateUrls", + Description: "Describes lists of issuer CA certificate URLs that appear in the \"Authority Information Access\" extension in the certificate.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "authorityKeyId": &dcl.Property{ + Type: "object", + GoName: "AuthorityKeyId", + GoType: "CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId", + Description: "Identifies the subject_key_id of the parent certificate, per https://tools.ietf.org/html/rfc5280#section-4.2.1.1", + Properties: map[string]*dcl.Property{ + "keyId": &dcl.Property{ + Type: "string", + GoName: "KeyId", + Description: "Optional. The value of this KeyId encoded in lowercase hexadecimal. This is most likely the 160 bit SHA-1 hash of the public key.", + }, + }, + }, + "certFingerprint": &dcl.Property{ + Type: "object", + GoName: "CertFingerprint", + GoType: "CertificateAuthorityCaCertificateDescriptionsCertFingerprint", + Description: "The hash of the x.509 certificate.", + Properties: map[string]*dcl.Property{ + "sha256Hash": &dcl.Property{ + Type: "string", + GoName: "Sha256Hash", + Description: "The SHA 256 hash, encoded in hexadecimal, of the DER x509 certificate.", + }, + }, + }, + "crlDistributionPoints": &dcl.Property{ + Type: "array", + GoName: "CrlDistributionPoints", + Description: "Describes a list of locations to obtain CRL information, i.e. the DistributionPoint.fullName described by https://tools.ietf.org/html/rfc5280#section-4.2.1.13", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "publicKey": &dcl.Property{ + Type: "object", + GoName: "PublicKey", + GoType: "CertificateAuthorityCaCertificateDescriptionsPublicKey", + Description: "The public key that corresponds to an issued certificate.", + Required: []string{ + "key", + "format", + }, + Properties: map[string]*dcl.Property{ + "format": &dcl.Property{ + Type: "string", + GoName: "Format", + GoType: "CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum", + Description: "Required. The format of the public key. Possible values: PEM", + Enum: []string{ + "PEM", + }, + }, + "key": &dcl.Property{ + Type: "string", + GoName: "Key", + Description: "Required. A public key. The padding and encoding must match with the `KeyFormat` value specified for the `format` field.", + }, + }, + }, + "subjectDescription": &dcl.Property{ + Type: "object", + GoName: "SubjectDescription", + GoType: "CertificateAuthorityCaCertificateDescriptionsSubjectDescription", + Description: "Describes some of the values in a certificate that are related to the subject and lifetime.", + Properties: map[string]*dcl.Property{ + "hexSerialNumber": &dcl.Property{ + Type: "string", + GoName: "HexSerialNumber", + Description: "The serial number encoded in lowercase hexadecimal.", + }, + "lifetime": &dcl.Property{ + Type: "string", + GoName: "Lifetime", + Description: "For convenience, the actual lifetime of an issued certificate.", + }, + "notAfterTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "NotAfterTime", + Description: "The time after which the certificate is expired. Per RFC 5280, the validity period for a certificate is the period of time from not_before_time through not_after_time, inclusive. Corresponds to 'not_before_time' + 'lifetime' - 1 second.", + }, + "notBeforeTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "NotBeforeTime", + Description: "The time at which the certificate becomes valid.", + }, + "subject": &dcl.Property{ + Type: "object", + GoName: "Subject", + GoType: "CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject", + Description: "Contains distinguished name fields such as the common name, location and organization.", + Properties: map[string]*dcl.Property{ + "commonName": &dcl.Property{ + Type: "string", + GoName: "CommonName", + Description: "The \"common name\" of the subject.", + }, + "countryCode": &dcl.Property{ + Type: "string", + GoName: "CountryCode", + Description: "The country code of the subject.", + }, + "locality": &dcl.Property{ + Type: "string", + GoName: "Locality", + Description: "The locality or city of the subject.", + }, + "organization": &dcl.Property{ + Type: "string", + GoName: "Organization", + Description: "The organization of the subject.", + }, + "organizationalUnit": &dcl.Property{ + Type: "string", + GoName: "OrganizationalUnit", + Description: "The organizational_unit of the subject.", + }, + "postalCode": &dcl.Property{ + Type: "string", + GoName: "PostalCode", + Description: "The postal code of the subject.", + }, + "province": &dcl.Property{ + Type: "string", + GoName: "Province", + Description: "The province, territory, or regional state of the subject.", + }, + "streetAddress": &dcl.Property{ + Type: "string", + GoName: "StreetAddress", + Description: "The street address of the subject.", + }, + }, + }, + "subjectAltName": &dcl.Property{ + Type: "object", + GoName: "SubjectAltName", + GoType: "CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName", + Description: "The subject alternative name fields.", + Properties: map[string]*dcl.Property{ + "customSans": &dcl.Property{ + Type: "array", + GoName: "CustomSans", + Description: "Contains additional subject alternative name values.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans", + Required: []string{ + "objectId", + "critical", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId", + Description: "Required. The OID for this X.509 extension.", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + }, + }, + }, + }, + "dnsNames": &dcl.Property{ + Type: "array", + GoName: "DnsNames", + Description: "Contains only valid, fully-qualified host names.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "emailAddresses": &dcl.Property{ + Type: "array", + GoName: "EmailAddresses", + Description: "Contains only valid RFC 2822 E-mail addresses.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "ipAddresses": &dcl.Property{ + Type: "array", + GoName: "IPAddresses", + Description: "Contains only valid 32-bit IPv4 addresses or RFC 4291 IPv6 addresses.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "uris": &dcl.Property{ + Type: "array", + GoName: "Uris", + Description: "Contains only valid RFC 3986 URIs.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + "subjectKeyId": &dcl.Property{ + Type: "object", + GoName: "SubjectKeyId", + GoType: "CertificateAuthorityCaCertificateDescriptionsSubjectKeyId", + Description: "Provides a means of identifiying certificates that contain a particular public key, per https://tools.ietf.org/html/rfc5280#section-4.2.1.2.", + Properties: map[string]*dcl.Property{ + "keyId": &dcl.Property{ + Type: "string", + GoName: "KeyId", + Description: "Optional. The value of this KeyId encoded in lowercase hexadecimal. This is most likely the 160 bit SHA-1 hash of the public key.", + }, + }, + }, + "x509Description": &dcl.Property{ + Type: "object", + GoName: "X509Description", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509Description", + Description: "Describes some of the technical X.509 fields in a certificate.", + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. Describes custom X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions", + Required: []string{ + "objectId", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId", + Description: "Required. The OID for this X.509 extension.", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + }, + }, + }, + }, + "aiaOcspServers": &dcl.Property{ + Type: "array", + GoName: "AiaOcspServers", + ReadOnly: true, + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + Immutable: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "caOptions": &dcl.Property{ + Type: "object", + GoName: "CaOptions", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions", + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + Properties: map[string]*dcl.Property{ + "isCa": &dcl.Property{ + Type: "boolean", + GoName: "IsCa", + Description: "Optional. Refers to the \"CA\" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.", + }, + "maxIssuerPathLength": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxIssuerPathLength", + Description: "Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.", + }, + }, + }, + "keyUsage": &dcl.Property{ + Type: "object", + GoName: "KeyUsage", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage", + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + Properties: map[string]*dcl.Property{ + "baseKeyUsage": &dcl.Property{ + Type: "object", + GoName: "BaseKeyUsage", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage", + Description: "Describes high-level ways in which a key may be used.", + Properties: map[string]*dcl.Property{ + "certSign": &dcl.Property{ + Type: "boolean", + GoName: "CertSign", + Description: "The key may be used to sign certificates.", + }, + "contentCommitment": &dcl.Property{ + Type: "boolean", + GoName: "ContentCommitment", + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + }, + "crlSign": &dcl.Property{ + Type: "boolean", + GoName: "CrlSign", + Description: "The key may be used sign certificate revocation lists.", + }, + "dataEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "DataEncipherment", + Description: "The key may be used to encipher data.", + }, + "decipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "DecipherOnly", + Description: "The key may be used to decipher only.", + }, + "digitalSignature": &dcl.Property{ + Type: "boolean", + GoName: "DigitalSignature", + Description: "The key may be used for digital signatures.", + }, + "encipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "EncipherOnly", + Description: "The key may be used to encipher only.", + }, + "keyAgreement": &dcl.Property{ + Type: "boolean", + GoName: "KeyAgreement", + Description: "The key may be used in a key agreement protocol.", + }, + "keyEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "KeyEncipherment", + Description: "The key may be used to encipher other keys.", + }, + }, + }, + "extendedKeyUsage": &dcl.Property{ + Type: "object", + GoName: "ExtendedKeyUsage", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage", + Description: "Detailed scenarios in which a key may be used.", + Properties: map[string]*dcl.Property{ + "clientAuth": &dcl.Property{ + Type: "boolean", + GoName: "ClientAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + }, + "codeSigning": &dcl.Property{ + Type: "boolean", + GoName: "CodeSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + }, + "emailProtection": &dcl.Property{ + Type: "boolean", + GoName: "EmailProtection", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + }, + "ocspSigning": &dcl.Property{ + Type: "boolean", + GoName: "OcspSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + }, + "serverAuth": &dcl.Property{ + Type: "boolean", + GoName: "ServerAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + }, + "timeStamping": &dcl.Property{ + Type: "boolean", + GoName: "TimeStamping", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + }, + }, + }, + "unknownExtendedKeyUsages": &dcl.Property{ + Type: "array", + GoName: "UnknownExtendedKeyUsages", + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "policyIds": &dcl.Property{ + Type: "array", + GoName: "PolicyIds", + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + }, + }, + }, + "caPool": &dcl.Property{ + Type: "string", + GoName: "CaPool", + Description: "The caPool for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Privateca/CaPool", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "config": &dcl.Property{ + Type: "object", + GoName: "Config", + GoType: "CertificateAuthorityConfig", + Description: "Required. Immutable. The config used to create a self-signed X.509 certificate or CSR.", + Immutable: true, + Required: []string{ + "subjectConfig", + "x509Config", + }, + Properties: map[string]*dcl.Property{ + "publicKey": &dcl.Property{ + Type: "object", + GoName: "PublicKey", + GoType: "CertificateAuthorityConfigPublicKey", + ReadOnly: true, + Description: "Optional. The public key that corresponds to this config. This is, for example, used when issuing Certificates, but not when creating a self-signed CertificateAuthority or CertificateAuthority CSR.", + Immutable: true, + Required: []string{ + "key", + "format", + }, + Properties: map[string]*dcl.Property{ + "format": &dcl.Property{ + Type: "string", + GoName: "Format", + GoType: "CertificateAuthorityConfigPublicKeyFormatEnum", + Description: "Required. The format of the public key. Possible values: PEM", + Immutable: true, + Enum: []string{ + "PEM", + }, + }, + "key": &dcl.Property{ + Type: "string", + GoName: "Key", + Description: "Required. A public key. The padding and encoding must match with the `KeyFormat` value specified for the `format` field.", + Immutable: true, + }, + }, + }, + "subjectConfig": &dcl.Property{ + Type: "object", + GoName: "SubjectConfig", + GoType: "CertificateAuthorityConfigSubjectConfig", + Description: "Required. Specifies some of the values in a certificate that are related to the subject.", + Immutable: true, + Required: []string{ + "subject", + }, + Properties: map[string]*dcl.Property{ + "subject": &dcl.Property{ + Type: "object", + GoName: "Subject", + GoType: "CertificateAuthorityConfigSubjectConfigSubject", + Description: "Required. Contains distinguished name fields such as the common name, location and organization.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "commonName": &dcl.Property{ + Type: "string", + GoName: "CommonName", + Description: "The \"common name\" of the subject.", + Immutable: true, + }, + "countryCode": &dcl.Property{ + Type: "string", + GoName: "CountryCode", + Description: "The country code of the subject.", + Immutable: true, + }, + "locality": &dcl.Property{ + Type: "string", + GoName: "Locality", + Description: "The locality or city of the subject.", + Immutable: true, + }, + "organization": &dcl.Property{ + Type: "string", + GoName: "Organization", + Description: "The organization of the subject.", + Immutable: true, + }, + "organizationalUnit": &dcl.Property{ + Type: "string", + GoName: "OrganizationalUnit", + Description: "The organizational_unit of the subject.", + Immutable: true, + }, + "postalCode": &dcl.Property{ + Type: "string", + GoName: "PostalCode", + Description: "The postal code of the subject.", + Immutable: true, + }, + "province": &dcl.Property{ + Type: "string", + GoName: "Province", + Description: "The province, territory, or regional state of the subject.", + Immutable: true, + }, + "streetAddress": &dcl.Property{ + Type: "string", + GoName: "StreetAddress", + Description: "The street address of the subject.", + Immutable: true, + }, + }, + }, + "subjectAltName": &dcl.Property{ + Type: "object", + GoName: "SubjectAltName", + GoType: "CertificateAuthorityConfigSubjectConfigSubjectAltName", + Description: "Optional. The subject alternative name fields.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "customSans": &dcl.Property{ + Type: "array", + GoName: "CustomSans", + Description: "Contains additional subject alternative name values.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans", + Required: []string{ + "objectId", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + Immutable: true, + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId", + Description: "Required. The OID for this X.509 extension.", + Immutable: true, + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + Immutable: true, + }, + }, + }, + }, + "dnsNames": &dcl.Property{ + Type: "array", + GoName: "DnsNames", + Description: "Contains only valid, fully-qualified host names.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "emailAddresses": &dcl.Property{ + Type: "array", + GoName: "EmailAddresses", + Description: "Contains only valid RFC 2822 E-mail addresses.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "ipAddresses": &dcl.Property{ + Type: "array", + GoName: "IPAddresses", + Description: "Contains only valid 32-bit IPv4 addresses or RFC 4291 IPv6 addresses.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "uris": &dcl.Property{ + Type: "array", + GoName: "Uris", + Description: "Contains only valid RFC 3986 URIs.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + "x509Config": &dcl.Property{ + Type: "object", + GoName: "X509Config", + GoType: "CertificateAuthorityConfigX509Config", + Description: "Required. Describes how some of the technical X.509 fields in a certificate should be populated.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. Describes custom X.509 extensions.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityConfigX509ConfigAdditionalExtensions", + Required: []string{ + "objectId", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + Immutable: true, + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId", + Description: "Required. The OID for this X.509 extension.", + Immutable: true, + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + Immutable: true, + }, + }, + }, + }, + "aiaOcspServers": &dcl.Property{ + Type: "array", + GoName: "AiaOcspServers", + ReadOnly: true, + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + Immutable: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "caOptions": &dcl.Property{ + Type: "object", + GoName: "CaOptions", + GoType: "CertificateAuthorityConfigX509ConfigCaOptions", + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "isCa": &dcl.Property{ + Type: "boolean", + GoName: "IsCa", + Description: "Optional. Refers to the \"CA\" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.", + Immutable: true, + }, + "maxIssuerPathLength": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxIssuerPathLength", + Description: "Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.", + Immutable: true, + }, + "zeroMaxIssuerPathLength": &dcl.Property{ + Type: "boolean", + GoName: "ZeroMaxIssuerPathLength", + Description: "Optional. When true, the \"path length constraint\" in Basic Constraints extension will be set to 0. if both max_issuer_path_length and zero_max_issuer_path_length are unset, the max path length will be omitted from the CA certificate.", + Immutable: true, + }, + }, + }, + "keyUsage": &dcl.Property{ + Type: "object", + GoName: "KeyUsage", + GoType: "CertificateAuthorityConfigX509ConfigKeyUsage", + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "baseKeyUsage": &dcl.Property{ + Type: "object", + GoName: "BaseKeyUsage", + GoType: "CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage", + Description: "Describes high-level ways in which a key may be used.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "certSign": &dcl.Property{ + Type: "boolean", + GoName: "CertSign", + Description: "The key may be used to sign certificates.", + Immutable: true, + }, + "contentCommitment": &dcl.Property{ + Type: "boolean", + GoName: "ContentCommitment", + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + Immutable: true, + }, + "crlSign": &dcl.Property{ + Type: "boolean", + GoName: "CrlSign", + Description: "The key may be used sign certificate revocation lists.", + Immutable: true, + }, + "dataEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "DataEncipherment", + Description: "The key may be used to encipher data.", + Immutable: true, + }, + "decipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "DecipherOnly", + Description: "The key may be used to decipher only.", + Immutable: true, + }, + "digitalSignature": &dcl.Property{ + Type: "boolean", + GoName: "DigitalSignature", + Description: "The key may be used for digital signatures.", + Immutable: true, + }, + "encipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "EncipherOnly", + Description: "The key may be used to encipher only.", + Immutable: true, + }, + "keyAgreement": &dcl.Property{ + Type: "boolean", + GoName: "KeyAgreement", + Description: "The key may be used in a key agreement protocol.", + Immutable: true, + }, + "keyEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "KeyEncipherment", + Description: "The key may be used to encipher other keys.", + Immutable: true, + }, + }, + }, + "extendedKeyUsage": &dcl.Property{ + Type: "object", + GoName: "ExtendedKeyUsage", + GoType: "CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage", + Description: "Detailed scenarios in which a key may be used.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "clientAuth": &dcl.Property{ + Type: "boolean", + GoName: "ClientAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + Immutable: true, + }, + "codeSigning": &dcl.Property{ + Type: "boolean", + GoName: "CodeSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + Immutable: true, + }, + "emailProtection": &dcl.Property{ + Type: "boolean", + GoName: "EmailProtection", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + Immutable: true, + }, + "ocspSigning": &dcl.Property{ + Type: "boolean", + GoName: "OcspSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + Immutable: true, + }, + "serverAuth": &dcl.Property{ + Type: "boolean", + GoName: "ServerAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + Immutable: true, + }, + "timeStamping": &dcl.Property{ + Type: "boolean", + GoName: "TimeStamping", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + Immutable: true, + }, + }, + }, + "unknownExtendedKeyUsages": &dcl.Property{ + Type: "array", + GoName: "UnknownExtendedKeyUsages", + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "policyIds": &dcl.Property{ + Type: "array", + GoName: "PolicyIds", + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateAuthorityConfigX509ConfigPolicyIds", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + }, + }, + "createTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "CreateTime", + ReadOnly: true, + Description: "Output only. The time at which this CertificateAuthority was created.", + Immutable: true, + }, + "deleteTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "DeleteTime", + ReadOnly: true, + Description: "Output only. The time at which this CertificateAuthority was soft deleted, if it is in the DELETED state.", + Immutable: true, + }, + "expireTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "ExpireTime", + ReadOnly: true, + Description: "Output only. The time at which this CertificateAuthority will be permanently purged, if it is in the DELETED state.", + Immutable: true, + }, + "gcsBucket": &dcl.Property{ + Type: "string", + GoName: "GcsBucket", + Description: "Immutable. The name of a Cloud Storage bucket where this CertificateAuthority will publish content, such as the CA certificate and CRLs. This must be a bucket name, without any prefixes (such as `gs://`) or suffixes (such as `.googleapis.com`). For example, to use a bucket named `my-bucket`, you would simply specify `my-bucket`. If not specified, a managed bucket will be created.", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Storage/Bucket", + Field: "name", + }, + }, + }, + "keySpec": &dcl.Property{ + Type: "object", + GoName: "KeySpec", + GoType: "CertificateAuthorityKeySpec", + Description: "Required. Immutable. Used when issuing certificates for this CertificateAuthority. If this CertificateAuthority is a self-signed CertificateAuthority, this key is also used to sign the self-signed CA certificate. Otherwise, it is used to sign a CSR.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "algorithm": &dcl.Property{ + Type: "string", + GoName: "Algorithm", + GoType: "CertificateAuthorityKeySpecAlgorithmEnum", + Description: "The algorithm to use for creating a managed Cloud KMS key for a for a simplified experience. All managed keys will be have their ProtectionLevel as `HSM`. Possible values: RSA_PSS_2048_SHA256, RSA_PSS_3072_SHA256, RSA_PSS_4096_SHA256, RSA_PKCS1_2048_SHA256, RSA_PKCS1_3072_SHA256, RSA_PKCS1_4096_SHA256, EC_P256_SHA256, EC_P384_SHA384", + Immutable: true, + Conflicts: []string{ + "cloudKmsKeyVersion", + }, + Enum: []string{ + "RSA_PSS_2048_SHA256", + "RSA_PSS_3072_SHA256", + "RSA_PSS_4096_SHA256", + "RSA_PKCS1_2048_SHA256", + "RSA_PKCS1_3072_SHA256", + "RSA_PKCS1_4096_SHA256", + "EC_P256_SHA256", + "EC_P384_SHA384", + }, + }, + "cloudKmsKeyVersion": &dcl.Property{ + Type: "string", + GoName: "CloudKmsKeyVersion", + Description: "The resource name for an existing Cloud KMS CryptoKeyVersion in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`. This option enables full flexibility in the key's capabilities and properties.", + Immutable: true, + Conflicts: []string{ + "algorithm", + }, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudkms/CryptoKeyVersion", + Field: "name", + }, + }, + }, + }, + }, + "labels": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "string", + }, + GoName: "Labels", + Description: "Optional. Labels with user-defined metadata.", + }, + "lifetime": &dcl.Property{ + Type: "string", + GoName: "Lifetime", + Description: "Required. The desired lifetime of the CA certificate. Used to create the \"not_before_time\" and \"not_after_time\" fields inside an X.509 certificate.", + Immutable: true, + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "The location for the resource", + Immutable: true, + Parameter: true, + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "The resource name for this CertificateAuthority in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`.", + Immutable: true, + HasLongForm: true, + }, + "pemCaCertificates": &dcl.Property{ + Type: "array", + GoName: "PemCaCertificates", + ReadOnly: true, + Description: "Output only. This CertificateAuthority's certificate chain, including the current CertificateAuthority's certificate. Ordered such that the root issuer is the final element (consistent with RFC 5246). For a self-signed CA, this will only list the current CertificateAuthority's certificate.", + Immutable: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "project": &dcl.Property{ + Type: "string", + GoName: "Project", + Description: "The project for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "state": &dcl.Property{ + Type: "string", + GoName: "State", + GoType: "CertificateAuthorityStateEnum", + ReadOnly: true, + Description: "Output only. The State for this CertificateAuthority. Possible values: ENABLED, DISABLED, STAGED, AWAITING_USER_ACTIVATION, DELETED", + Immutable: true, + Enum: []string{ + "ENABLED", + "DISABLED", + "STAGED", + "AWAITING_USER_ACTIVATION", + "DELETED", + }, + }, + "subordinateConfig": &dcl.Property{ + Type: "object", + GoName: "SubordinateConfig", + GoType: "CertificateAuthoritySubordinateConfig", + ReadOnly: true, + Description: "Optional. If this is a subordinate CertificateAuthority, this field will be set with the subordinate configuration, which describes its issuers. This may be updated, but this CertificateAuthority must continue to validate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "certificateAuthority": &dcl.Property{ + Type: "string", + GoName: "CertificateAuthority", + Description: "Required. This can refer to a CertificateAuthority in the same project that was used to create a subordinate CertificateAuthority. This field is used for information and usability purposes only. The resource name is in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`.", + Immutable: true, + Conflicts: []string{ + "pemIssuerChain", + }, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Privateca/CertificateAuthority", + Field: "selfLink", + }, + }, + }, + "pemIssuerChain": &dcl.Property{ + Type: "object", + GoName: "PemIssuerChain", + GoType: "CertificateAuthoritySubordinateConfigPemIssuerChain", + Description: "Required. Contains the PEM certificate chain for the issuers of this CertificateAuthority, but not pem certificate for this CA itself.", + Immutable: true, + Conflicts: []string{ + "certificateAuthority", + }, + Required: []string{ + "pemCertificates", + }, + Properties: map[string]*dcl.Property{ + "pemCertificates": &dcl.Property{ + Type: "array", + GoName: "PemCertificates", + Description: "Required. Expected to be in leaf-to-root order according to RFC 5246.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + "tier": &dcl.Property{ + Type: "string", + GoName: "Tier", + GoType: "CertificateAuthorityTierEnum", + ReadOnly: true, + Description: "Output only. The CaPool.Tier of the CaPool that includes this CertificateAuthority. Possible values: ENTERPRISE, DEVOPS", + Immutable: true, + Enum: []string{ + "ENTERPRISE", + "DEVOPS", + }, + }, + "type": &dcl.Property{ + Type: "string", + GoName: "Type", + GoType: "CertificateAuthorityTypeEnum", + Description: "Required. Immutable. The Type of this CertificateAuthority. Possible values: SELF_SIGNED, SUBORDINATE", + Immutable: true, + Enum: []string{ + "SELF_SIGNED", + "SUBORDINATE", + }, + }, + "updateTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "UpdateTime", + ReadOnly: true, + Description: "Output only. The time at which this CertificateAuthority was last updated.", + Immutable: true, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_yaml_embed.go new file mode 100644 index 00000000000..664eac02a0c --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_authority_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package privateca -var YAML_certificate_authority blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/certificate_authority.yaml + +package privateca + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/certificate_authority.yaml +var YAML_certificate_authority = []byte("info:\n title: Privateca/CertificateAuthority\n description: The Privateca CertificateAuthority resource\n x-dcl-struct-name: CertificateAuthority\n x-dcl-has-iam: false\npaths:\n get:\n description: The function used to get information about a CertificateAuthority\n parameters:\n - name: certificateAuthority\n required: true\n description: A full instance of a CertificateAuthority\n apply:\n description: The function used to apply information about a CertificateAuthority\n parameters:\n - name: certificateAuthority\n required: true\n description: A full instance of a CertificateAuthority\n delete:\n description: The function used to delete a CertificateAuthority\n parameters:\n - name: certificateAuthority\n required: true\n description: A full instance of a CertificateAuthority\n deleteAll:\n description: The function used to delete all CertificateAuthority\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n - name: caPool\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many CertificateAuthority\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n - name: caPool\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n CertificateAuthority:\n title: CertificateAuthority\n x-dcl-id: projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificateAuthorities/{{name}}\n x-dcl-parent-container: project\n x-dcl-labels: labels\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - type\n - config\n - lifetime\n - keySpec\n - project\n - location\n - caPool\n properties:\n accessUrls:\n type: object\n x-dcl-go-name: AccessUrls\n x-dcl-go-type: CertificateAuthorityAccessUrls\n readOnly: true\n description: Output only. URLs for accessing content published by this CA,\n such as the CA certificate and CRLs.\n x-kubernetes-immutable: true\n properties:\n caCertificateAccessUrl:\n type: string\n x-dcl-go-name: CaCertificateAccessUrl\n description: The URL where this CertificateAuthority's CA certificate\n is published. This will only be set for CAs that have been activated.\n x-kubernetes-immutable: true\n crlAccessUrls:\n type: array\n x-dcl-go-name: CrlAccessUrls\n description: The URLs where this CertificateAuthority's CRLs are published.\n This will only be set for CAs that have been activated.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caCertificateDescriptions:\n type: array\n x-dcl-go-name: CaCertificateDescriptions\n readOnly: true\n description: Output only. A structured description of this CertificateAuthority's\n CA certificate and its issuers. Ordered as self-to-root.\n x-kubernetes-immutable: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptions\n properties:\n aiaIssuingCertificateUrls:\n type: array\n x-dcl-go-name: AiaIssuingCertificateUrls\n description: Describes lists of issuer CA certificate URLs that appear\n in the \"Authority Information Access\" extension in the certificate.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n authorityKeyId:\n type: object\n x-dcl-go-name: AuthorityKeyId\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsAuthorityKeyId\n description: Identifies the subject_key_id of the parent certificate,\n per https://tools.ietf.org/html/rfc5280#section-4.2.1.1\n properties:\n keyId:\n type: string\n x-dcl-go-name: KeyId\n description: Optional. The value of this KeyId encoded in lowercase\n hexadecimal. This is most likely the 160 bit SHA-1 hash of the\n public key.\n certFingerprint:\n type: object\n x-dcl-go-name: CertFingerprint\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsCertFingerprint\n description: The hash of the x.509 certificate.\n properties:\n sha256Hash:\n type: string\n x-dcl-go-name: Sha256Hash\n description: The SHA 256 hash, encoded in hexadecimal, of the\n DER x509 certificate.\n crlDistributionPoints:\n type: array\n x-dcl-go-name: CrlDistributionPoints\n description: Describes a list of locations to obtain CRL information,\n i.e. the DistributionPoint.fullName described by https://tools.ietf.org/html/rfc5280#section-4.2.1.13\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n publicKey:\n type: object\n x-dcl-go-name: PublicKey\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsPublicKey\n description: The public key that corresponds to an issued certificate.\n required:\n - key\n - format\n properties:\n format:\n type: string\n x-dcl-go-name: Format\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsPublicKeyFormatEnum\n description: 'Required. The format of the public key. Possible\n values: PEM'\n enum:\n - PEM\n key:\n type: string\n x-dcl-go-name: Key\n description: Required. A public key. The padding and encoding\n must match with the `KeyFormat` value specified for the `format`\n field.\n subjectDescription:\n type: object\n x-dcl-go-name: SubjectDescription\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescription\n description: Describes some of the values in a certificate that are\n related to the subject and lifetime.\n properties:\n hexSerialNumber:\n type: string\n x-dcl-go-name: HexSerialNumber\n description: The serial number encoded in lowercase hexadecimal.\n lifetime:\n type: string\n x-dcl-go-name: Lifetime\n description: For convenience, the actual lifetime of an issued\n certificate.\n notAfterTime:\n type: string\n format: date-time\n x-dcl-go-name: NotAfterTime\n description: The time after which the certificate is expired.\n Per RFC 5280, the validity period for a certificate is the period\n of time from not_before_time through not_after_time, inclusive.\n Corresponds to 'not_before_time' + 'lifetime' - 1 second.\n notBeforeTime:\n type: string\n format: date-time\n x-dcl-go-name: NotBeforeTime\n description: The time at which the certificate becomes valid.\n subject:\n type: object\n x-dcl-go-name: Subject\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubject\n description: Contains distinguished name fields such as the common\n name, location and organization.\n properties:\n commonName:\n type: string\n x-dcl-go-name: CommonName\n description: The \"common name\" of the subject.\n countryCode:\n type: string\n x-dcl-go-name: CountryCode\n description: The country code of the subject.\n locality:\n type: string\n x-dcl-go-name: Locality\n description: The locality or city of the subject.\n organization:\n type: string\n x-dcl-go-name: Organization\n description: The organization of the subject.\n organizationalUnit:\n type: string\n x-dcl-go-name: OrganizationalUnit\n description: The organizational_unit of the subject.\n postalCode:\n type: string\n x-dcl-go-name: PostalCode\n description: The postal code of the subject.\n province:\n type: string\n x-dcl-go-name: Province\n description: The province, territory, or regional state of\n the subject.\n streetAddress:\n type: string\n x-dcl-go-name: StreetAddress\n description: The street address of the subject.\n subjectAltName:\n type: object\n x-dcl-go-name: SubjectAltName\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltName\n description: The subject alternative name fields.\n properties:\n customSans:\n type: array\n x-dcl-go-name: CustomSans\n description: Contains additional subject alternative name\n values.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSans\n required:\n - objectId\n - critical\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this\n extension is critical (i.e., if the client does not\n know how to handle this extension, the client should\n consider this to be an error).\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectDescriptionSubjectAltNameCustomSansObjectId\n description: Required. The OID for this X.509 extension.\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path.\n The most significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n dnsNames:\n type: array\n x-dcl-go-name: DnsNames\n description: Contains only valid, fully-qualified host names.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n emailAddresses:\n type: array\n x-dcl-go-name: EmailAddresses\n description: Contains only valid RFC 2822 E-mail addresses.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n ipAddresses:\n type: array\n x-dcl-go-name: IPAddresses\n description: Contains only valid 32-bit IPv4 addresses or\n RFC 4291 IPv6 addresses.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n uris:\n type: array\n x-dcl-go-name: Uris\n description: Contains only valid RFC 3986 URIs.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n subjectKeyId:\n type: object\n x-dcl-go-name: SubjectKeyId\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsSubjectKeyId\n description: Provides a means of identifiying certificates that contain\n a particular public key, per https://tools.ietf.org/html/rfc5280#section-4.2.1.2.\n properties:\n keyId:\n type: string\n x-dcl-go-name: KeyId\n description: Optional. The value of this KeyId encoded in lowercase\n hexadecimal. This is most likely the 160 bit SHA-1 hash of the\n public key.\n x509Description:\n type: object\n x-dcl-go-name: X509Description\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509Description\n description: Describes some of the technical X.509 fields in a certificate.\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. Describes custom X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensions\n required:\n - objectId\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to\n handle this extension, the client should consider this\n to be an error).\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionAdditionalExtensionsObjectId\n description: Required. The OID for this X.509 extension.\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The\n most significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n aiaOcspServers:\n type: array\n x-dcl-go-name: AiaOcspServers\n readOnly: true\n description: Optional. Describes Online Certificate Status Protocol\n (OCSP) endpoint addresses that appear in the \"Authority Information\n Access\" extension in the certificate.\n x-kubernetes-immutable: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caOptions:\n type: object\n x-dcl-go-name: CaOptions\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionCaOptions\n description: Optional. Describes options in this X509Parameters\n that are relevant in a CA certificate.\n properties:\n isCa:\n type: boolean\n x-dcl-go-name: IsCa\n description: Optional. Refers to the \"CA\" X.509 extension,\n which is a boolean value. When this value is missing, the\n extension will be omitted from the CA certificate.\n maxIssuerPathLength:\n type: integer\n format: int64\n x-dcl-go-name: MaxIssuerPathLength\n description: Optional. Refers to the path length restriction\n X.509 extension. For a CA certificate, this value describes\n the depth of subordinate CA certificates that are allowed.\n If this value is less than 0, the request will fail. If\n this value is missing, the max path length will be omitted\n from the CA certificate.\n keyUsage:\n type: object\n x-dcl-go-name: KeyUsage\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsage\n description: Optional. Indicates the intended use for keys that\n correspond to a certificate.\n properties:\n baseKeyUsage:\n type: object\n x-dcl-go-name: BaseKeyUsage\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageBaseKeyUsage\n description: Describes high-level ways in which a key may\n be used.\n properties:\n certSign:\n type: boolean\n x-dcl-go-name: CertSign\n description: The key may be used to sign certificates.\n contentCommitment:\n type: boolean\n x-dcl-go-name: ContentCommitment\n description: The key may be used for cryptographic commitments.\n Note that this may also be referred to as \"non-repudiation\".\n crlSign:\n type: boolean\n x-dcl-go-name: CrlSign\n description: The key may be used sign certificate revocation\n lists.\n dataEncipherment:\n type: boolean\n x-dcl-go-name: DataEncipherment\n description: The key may be used to encipher data.\n decipherOnly:\n type: boolean\n x-dcl-go-name: DecipherOnly\n description: The key may be used to decipher only.\n digitalSignature:\n type: boolean\n x-dcl-go-name: DigitalSignature\n description: The key may be used for digital signatures.\n encipherOnly:\n type: boolean\n x-dcl-go-name: EncipherOnly\n description: The key may be used to encipher only.\n keyAgreement:\n type: boolean\n x-dcl-go-name: KeyAgreement\n description: The key may be used in a key agreement protocol.\n keyEncipherment:\n type: boolean\n x-dcl-go-name: KeyEncipherment\n description: The key may be used to encipher other keys.\n extendedKeyUsage:\n type: object\n x-dcl-go-name: ExtendedKeyUsage\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageExtendedKeyUsage\n description: Detailed scenarios in which a key may be used.\n properties:\n clientAuth:\n type: boolean\n x-dcl-go-name: ClientAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially\n described as \"TLS WWW client authentication\", though\n regularly used for non-WWW TLS.\n codeSigning:\n type: boolean\n x-dcl-go-name: CodeSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially\n described as \"Signing of downloadable executable code\n client authentication\".\n emailProtection:\n type: boolean\n x-dcl-go-name: EmailProtection\n description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially\n described as \"Email protection\".\n ocspSigning:\n type: boolean\n x-dcl-go-name: OcspSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially\n described as \"Signing OCSP responses\".\n serverAuth:\n type: boolean\n x-dcl-go-name: ServerAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially\n described as \"TLS WWW server authentication\", though\n regularly used for non-WWW TLS.\n timeStamping:\n type: boolean\n x-dcl-go-name: TimeStamping\n description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially\n described as \"Binding the hash of an object to a time\".\n unknownExtendedKeyUsages:\n type: array\n x-dcl-go-name: UnknownExtendedKeyUsages\n description: Used to describe extended key usages that are\n not listed in the KeyUsage.ExtendedKeyUsageOptions message.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionKeyUsageUnknownExtendedKeyUsages\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The\n most significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n policyIds:\n type: array\n x-dcl-go-name: PolicyIds\n description: Optional. Describes the X.509 certificate policy\n object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityCaCertificateDescriptionsX509DescriptionPolicyIds\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n caPool:\n type: string\n x-dcl-go-name: CaPool\n description: The caPool for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Privateca/CaPool\n field: name\n parent: true\n x-dcl-parameter: true\n config:\n type: object\n x-dcl-go-name: Config\n x-dcl-go-type: CertificateAuthorityConfig\n description: Required. Immutable. The config used to create a self-signed\n X.509 certificate or CSR.\n x-kubernetes-immutable: true\n required:\n - subjectConfig\n - x509Config\n properties:\n publicKey:\n type: object\n x-dcl-go-name: PublicKey\n x-dcl-go-type: CertificateAuthorityConfigPublicKey\n readOnly: true\n description: Optional. The public key that corresponds to this config.\n This is, for example, used when issuing Certificates, but not when\n creating a self-signed CertificateAuthority or CertificateAuthority\n CSR.\n x-kubernetes-immutable: true\n required:\n - key\n - format\n properties:\n format:\n type: string\n x-dcl-go-name: Format\n x-dcl-go-type: CertificateAuthorityConfigPublicKeyFormatEnum\n description: 'Required. The format of the public key. Possible values:\n PEM'\n x-kubernetes-immutable: true\n enum:\n - PEM\n key:\n type: string\n x-dcl-go-name: Key\n description: Required. A public key. The padding and encoding must\n match with the `KeyFormat` value specified for the `format` field.\n x-kubernetes-immutable: true\n subjectConfig:\n type: object\n x-dcl-go-name: SubjectConfig\n x-dcl-go-type: CertificateAuthorityConfigSubjectConfig\n description: Required. Specifies some of the values in a certificate\n that are related to the subject.\n x-kubernetes-immutable: true\n required:\n - subject\n properties:\n subject:\n type: object\n x-dcl-go-name: Subject\n x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubject\n description: Required. Contains distinguished name fields such as\n the common name, location and organization.\n x-kubernetes-immutable: true\n properties:\n commonName:\n type: string\n x-dcl-go-name: CommonName\n description: The \"common name\" of the subject.\n x-kubernetes-immutable: true\n countryCode:\n type: string\n x-dcl-go-name: CountryCode\n description: The country code of the subject.\n x-kubernetes-immutable: true\n locality:\n type: string\n x-dcl-go-name: Locality\n description: The locality or city of the subject.\n x-kubernetes-immutable: true\n organization:\n type: string\n x-dcl-go-name: Organization\n description: The organization of the subject.\n x-kubernetes-immutable: true\n organizationalUnit:\n type: string\n x-dcl-go-name: OrganizationalUnit\n description: The organizational_unit of the subject.\n x-kubernetes-immutable: true\n postalCode:\n type: string\n x-dcl-go-name: PostalCode\n description: The postal code of the subject.\n x-kubernetes-immutable: true\n province:\n type: string\n x-dcl-go-name: Province\n description: The province, territory, or regional state of the\n subject.\n x-kubernetes-immutable: true\n streetAddress:\n type: string\n x-dcl-go-name: StreetAddress\n description: The street address of the subject.\n x-kubernetes-immutable: true\n subjectAltName:\n type: object\n x-dcl-go-name: SubjectAltName\n x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubjectAltName\n description: Optional. The subject alternative name fields.\n x-kubernetes-immutable: true\n properties:\n customSans:\n type: array\n x-dcl-go-name: CustomSans\n description: Contains additional subject alternative name values.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSans\n required:\n - objectId\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to\n handle this extension, the client should consider this\n to be an error).\n x-kubernetes-immutable: true\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateAuthorityConfigSubjectConfigSubjectAltNameCustomSansObjectId\n description: Required. The OID for this X.509 extension.\n x-kubernetes-immutable: true\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The\n most significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n x-kubernetes-immutable: true\n dnsNames:\n type: array\n x-dcl-go-name: DnsNames\n description: Contains only valid, fully-qualified host names.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n emailAddresses:\n type: array\n x-dcl-go-name: EmailAddresses\n description: Contains only valid RFC 2822 E-mail addresses.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n ipAddresses:\n type: array\n x-dcl-go-name: IPAddresses\n description: Contains only valid 32-bit IPv4 addresses or RFC\n 4291 IPv6 addresses.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n uris:\n type: array\n x-dcl-go-name: Uris\n description: Contains only valid RFC 3986 URIs.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x509Config:\n type: object\n x-dcl-go-name: X509Config\n x-dcl-go-type: CertificateAuthorityConfigX509Config\n description: Required. Describes how some of the technical X.509 fields\n in a certificate should be populated.\n x-kubernetes-immutable: true\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. Describes custom X.509 extensions.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigAdditionalExtensions\n required:\n - objectId\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to handle\n this extension, the client should consider this to be an\n error).\n x-kubernetes-immutable: true\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigAdditionalExtensionsObjectId\n description: Required. The OID for this X.509 extension.\n x-kubernetes-immutable: true\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n x-kubernetes-immutable: true\n aiaOcspServers:\n type: array\n x-dcl-go-name: AiaOcspServers\n readOnly: true\n description: Optional. Describes Online Certificate Status Protocol\n (OCSP) endpoint addresses that appear in the \"Authority Information\n Access\" extension in the certificate.\n x-kubernetes-immutable: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caOptions:\n type: object\n x-dcl-go-name: CaOptions\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigCaOptions\n description: Optional. Describes options in this X509Parameters\n that are relevant in a CA certificate.\n x-kubernetes-immutable: true\n properties:\n isCa:\n type: boolean\n x-dcl-go-name: IsCa\n description: Optional. Refers to the \"CA\" X.509 extension, which\n is a boolean value. When this value is missing, the extension\n will be omitted from the CA certificate.\n x-kubernetes-immutable: true\n maxIssuerPathLength:\n type: integer\n format: int64\n x-dcl-go-name: MaxIssuerPathLength\n description: Optional. Refers to the path length restriction\n X.509 extension. For a CA certificate, this value describes\n the depth of subordinate CA certificates that are allowed.\n If this value is less than 0, the request will fail. If this\n value is missing, the max path length will be omitted from\n the CA certificate.\n x-kubernetes-immutable: true\n zeroMaxIssuerPathLength:\n type: boolean\n x-dcl-go-name: ZeroMaxIssuerPathLength\n description: Optional. When true, the \"path length constraint\"\n in Basic Constraints extension will be set to 0. if both max_issuer_path_length\n and zero_max_issuer_path_length are unset, the max path length\n will be omitted from the CA certificate.\n x-kubernetes-immutable: true\n keyUsage:\n type: object\n x-dcl-go-name: KeyUsage\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsage\n description: Optional. Indicates the intended use for keys that\n correspond to a certificate.\n x-kubernetes-immutable: true\n properties:\n baseKeyUsage:\n type: object\n x-dcl-go-name: BaseKeyUsage\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsageBaseKeyUsage\n description: Describes high-level ways in which a key may be\n used.\n x-kubernetes-immutable: true\n properties:\n certSign:\n type: boolean\n x-dcl-go-name: CertSign\n description: The key may be used to sign certificates.\n x-kubernetes-immutable: true\n contentCommitment:\n type: boolean\n x-dcl-go-name: ContentCommitment\n description: The key may be used for cryptographic commitments.\n Note that this may also be referred to as \"non-repudiation\".\n x-kubernetes-immutable: true\n crlSign:\n type: boolean\n x-dcl-go-name: CrlSign\n description: The key may be used sign certificate revocation\n lists.\n x-kubernetes-immutable: true\n dataEncipherment:\n type: boolean\n x-dcl-go-name: DataEncipherment\n description: The key may be used to encipher data.\n x-kubernetes-immutable: true\n decipherOnly:\n type: boolean\n x-dcl-go-name: DecipherOnly\n description: The key may be used to decipher only.\n x-kubernetes-immutable: true\n digitalSignature:\n type: boolean\n x-dcl-go-name: DigitalSignature\n description: The key may be used for digital signatures.\n x-kubernetes-immutable: true\n encipherOnly:\n type: boolean\n x-dcl-go-name: EncipherOnly\n description: The key may be used to encipher only.\n x-kubernetes-immutable: true\n keyAgreement:\n type: boolean\n x-dcl-go-name: KeyAgreement\n description: The key may be used in a key agreement protocol.\n x-kubernetes-immutable: true\n keyEncipherment:\n type: boolean\n x-dcl-go-name: KeyEncipherment\n description: The key may be used to encipher other keys.\n x-kubernetes-immutable: true\n extendedKeyUsage:\n type: object\n x-dcl-go-name: ExtendedKeyUsage\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsageExtendedKeyUsage\n description: Detailed scenarios in which a key may be used.\n x-kubernetes-immutable: true\n properties:\n clientAuth:\n type: boolean\n x-dcl-go-name: ClientAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially\n described as \"TLS WWW client authentication\", though regularly\n used for non-WWW TLS.\n x-kubernetes-immutable: true\n codeSigning:\n type: boolean\n x-dcl-go-name: CodeSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially\n described as \"Signing of downloadable executable code\n client authentication\".\n x-kubernetes-immutable: true\n emailProtection:\n type: boolean\n x-dcl-go-name: EmailProtection\n description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially\n described as \"Email protection\".\n x-kubernetes-immutable: true\n ocspSigning:\n type: boolean\n x-dcl-go-name: OcspSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially\n described as \"Signing OCSP responses\".\n x-kubernetes-immutable: true\n serverAuth:\n type: boolean\n x-dcl-go-name: ServerAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially\n described as \"TLS WWW server authentication\", though regularly\n used for non-WWW TLS.\n x-kubernetes-immutable: true\n timeStamping:\n type: boolean\n x-dcl-go-name: TimeStamping\n description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially\n described as \"Binding the hash of an object to a time\".\n x-kubernetes-immutable: true\n unknownExtendedKeyUsages:\n type: array\n x-dcl-go-name: UnknownExtendedKeyUsages\n description: Used to describe extended key usages that are not\n listed in the KeyUsage.ExtendedKeyUsageOptions message.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigKeyUsageUnknownExtendedKeyUsages\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n policyIds:\n type: array\n x-dcl-go-name: PolicyIds\n description: Optional. Describes the X.509 certificate policy object\n identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateAuthorityConfigX509ConfigPolicyIds\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. The time at which this CertificateAuthority was\n created.\n x-kubernetes-immutable: true\n deleteTime:\n type: string\n format: date-time\n x-dcl-go-name: DeleteTime\n readOnly: true\n description: Output only. The time at which this CertificateAuthority was\n soft deleted, if it is in the DELETED state.\n x-kubernetes-immutable: true\n expireTime:\n type: string\n format: date-time\n x-dcl-go-name: ExpireTime\n readOnly: true\n description: Output only. The time at which this CertificateAuthority will\n be permanently purged, if it is in the DELETED state.\n x-kubernetes-immutable: true\n gcsBucket:\n type: string\n x-dcl-go-name: GcsBucket\n description: Immutable. The name of a Cloud Storage bucket where this CertificateAuthority\n will publish content, such as the CA certificate and CRLs. This must be\n a bucket name, without any prefixes (such as `gs://`) or suffixes (such\n as `.googleapis.com`). For example, to use a bucket named `my-bucket`,\n you would simply specify `my-bucket`. If not specified, a managed bucket\n will be created.\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Storage/Bucket\n field: name\n keySpec:\n type: object\n x-dcl-go-name: KeySpec\n x-dcl-go-type: CertificateAuthorityKeySpec\n description: Required. Immutable. Used when issuing certificates for this\n CertificateAuthority. If this CertificateAuthority is a self-signed CertificateAuthority,\n this key is also used to sign the self-signed CA certificate. Otherwise,\n it is used to sign a CSR.\n x-kubernetes-immutable: true\n properties:\n algorithm:\n type: string\n x-dcl-go-name: Algorithm\n x-dcl-go-type: CertificateAuthorityKeySpecAlgorithmEnum\n description: 'The algorithm to use for creating a managed Cloud KMS\n key for a for a simplified experience. All managed keys will be have\n their ProtectionLevel as `HSM`. Possible values: RSA_PSS_2048_SHA256,\n RSA_PSS_3072_SHA256, RSA_PSS_4096_SHA256, RSA_PKCS1_2048_SHA256, RSA_PKCS1_3072_SHA256,\n RSA_PKCS1_4096_SHA256, EC_P256_SHA256, EC_P384_SHA384'\n x-kubernetes-immutable: true\n x-dcl-conflicts:\n - cloudKmsKeyVersion\n enum:\n - RSA_PSS_2048_SHA256\n - RSA_PSS_3072_SHA256\n - RSA_PSS_4096_SHA256\n - RSA_PKCS1_2048_SHA256\n - RSA_PKCS1_3072_SHA256\n - RSA_PKCS1_4096_SHA256\n - EC_P256_SHA256\n - EC_P384_SHA384\n cloudKmsKeyVersion:\n type: string\n x-dcl-go-name: CloudKmsKeyVersion\n description: The resource name for an existing Cloud KMS CryptoKeyVersion\n in the format `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.\n This option enables full flexibility in the key's capabilities and\n properties.\n x-kubernetes-immutable: true\n x-dcl-conflicts:\n - algorithm\n x-dcl-references:\n - resource: Cloudkms/CryptoKeyVersion\n field: name\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: Optional. Labels with user-defined metadata.\n lifetime:\n type: string\n x-dcl-go-name: Lifetime\n description: Required. The desired lifetime of the CA certificate. Used\n to create the \"not_before_time\" and \"not_after_time\" fields inside an\n X.509 certificate.\n x-kubernetes-immutable: true\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: The resource name for this CertificateAuthority in the format\n `projects/*/locations/*/caPools/*/certificateAuthorities/*`.\n x-kubernetes-immutable: true\n x-dcl-has-long-form: true\n pemCaCertificates:\n type: array\n x-dcl-go-name: PemCaCertificates\n readOnly: true\n description: Output only. This CertificateAuthority's certificate chain,\n including the current CertificateAuthority's certificate. Ordered such\n that the root issuer is the final element (consistent with RFC 5246).\n For a self-signed CA, this will only list the current CertificateAuthority's\n certificate.\n x-kubernetes-immutable: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n state:\n type: string\n x-dcl-go-name: State\n x-dcl-go-type: CertificateAuthorityStateEnum\n readOnly: true\n description: 'Output only. The State for this CertificateAuthority. Possible\n values: ENABLED, DISABLED, STAGED, AWAITING_USER_ACTIVATION, DELETED'\n x-kubernetes-immutable: true\n enum:\n - ENABLED\n - DISABLED\n - STAGED\n - AWAITING_USER_ACTIVATION\n - DELETED\n subordinateConfig:\n type: object\n x-dcl-go-name: SubordinateConfig\n x-dcl-go-type: CertificateAuthoritySubordinateConfig\n readOnly: true\n description: Optional. If this is a subordinate CertificateAuthority, this\n field will be set with the subordinate configuration, which describes\n its issuers. This may be updated, but this CertificateAuthority must continue\n to validate.\n x-kubernetes-immutable: true\n properties:\n certificateAuthority:\n type: string\n x-dcl-go-name: CertificateAuthority\n description: Required. This can refer to a CertificateAuthority in the\n same project that was used to create a subordinate CertificateAuthority.\n This field is used for information and usability purposes only. The\n resource name is in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`.\n x-kubernetes-immutable: true\n x-dcl-conflicts:\n - pemIssuerChain\n x-dcl-references:\n - resource: Privateca/CertificateAuthority\n field: selfLink\n pemIssuerChain:\n type: object\n x-dcl-go-name: PemIssuerChain\n x-dcl-go-type: CertificateAuthoritySubordinateConfigPemIssuerChain\n description: Required. Contains the PEM certificate chain for the issuers\n of this CertificateAuthority, but not pem certificate for this CA\n itself.\n x-kubernetes-immutable: true\n x-dcl-conflicts:\n - certificateAuthority\n required:\n - pemCertificates\n properties:\n pemCertificates:\n type: array\n x-dcl-go-name: PemCertificates\n description: Required. Expected to be in leaf-to-root order according\n to RFC 5246.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n tier:\n type: string\n x-dcl-go-name: Tier\n x-dcl-go-type: CertificateAuthorityTierEnum\n readOnly: true\n description: 'Output only. The CaPool.Tier of the CaPool that includes this\n CertificateAuthority. Possible values: ENTERPRISE, DEVOPS'\n x-kubernetes-immutable: true\n enum:\n - ENTERPRISE\n - DEVOPS\n type:\n type: string\n x-dcl-go-name: Type\n x-dcl-go-type: CertificateAuthorityTypeEnum\n description: 'Required. Immutable. The Type of this CertificateAuthority.\n Possible values: SELF_SIGNED, SUBORDINATE'\n x-kubernetes-immutable: true\n enum:\n - SELF_SIGNED\n - SUBORDINATE\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. The time at which this CertificateAuthority was\n last updated.\n x-kubernetes-immutable: true\n") + +// 60952 bytes +// MD5: 007e3eff923dcb49d130bc3cb94f03b5 diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_internal.go new file mode 100644 index 00000000000..52ba2fb24ee --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_internal.go @@ -0,0 +1,12661 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func (r *Certificate) validate() error { + + if err := dcl.ValidateAtMostOneOfFieldsSet([]string{"PemCsr", "Config"}, r.PemCsr, r.Config); err != nil { + return err + } + if err := dcl.Required(r, "name"); err != nil { + return err + } + if err := dcl.Required(r, "lifetime"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Project, "Project"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Location, "Location"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.CaPool, "CaPool"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Config) { + if err := r.Config.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.RevocationDetails) { + if err := r.RevocationDetails.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CertificateDescription) { + if err := r.CertificateDescription.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateConfig) validate() error { + if err := dcl.Required(r, "subjectConfig"); err != nil { + return err + } + if err := dcl.Required(r, "x509Config"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.SubjectConfig) { + if err := r.SubjectConfig.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.X509Config) { + if err := r.X509Config.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PublicKey) { + if err := r.PublicKey.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateConfigSubjectConfig) validate() error { + if err := dcl.Required(r, "subject"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.Subject) { + if err := r.Subject.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubjectAltName) { + if err := r.SubjectAltName.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateConfigSubjectConfigSubject) validate() error { + return nil +} +func (r *CertificateConfigSubjectConfigSubjectAltName) validate() error { + return nil +} +func (r *CertificateConfigX509Config) validate() error { + if !dcl.IsEmptyValueIndirect(r.KeyUsage) { + if err := r.KeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CaOptions) { + if err := r.CaOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateConfigX509ConfigKeyUsage) validate() error { + if !dcl.IsEmptyValueIndirect(r.BaseKeyUsage) { + if err := r.BaseKeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.ExtendedKeyUsage) { + if err := r.ExtendedKeyUsage.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) validate() error { + return nil +} +func (r *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) validate() error { + return nil +} +func (r *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateConfigX509ConfigCaOptions) validate() error { + return nil +} +func (r *CertificateConfigX509ConfigPolicyIds) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateConfigX509ConfigAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateConfigX509ConfigAdditionalExtensionsObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateConfigPublicKey) validate() error { + if err := dcl.Required(r, "key"); err != nil { + return err + } + if err := dcl.Required(r, "format"); err != nil { + return err + } + return nil +} +func (r *CertificateRevocationDetails) validate() error { + return nil +} +func (r *CertificateCertificateDescription) validate() error { + if !dcl.IsEmptyValueIndirect(r.SubjectDescription) { + if err := r.SubjectDescription.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.X509Description) { + if err := r.X509Description.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PublicKey) { + if err := r.PublicKey.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubjectKeyId) { + if err := r.SubjectKeyId.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.AuthorityKeyId) { + if err := r.AuthorityKeyId.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CertFingerprint) { + if err := r.CertFingerprint.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateCertificateDescriptionSubjectDescription) validate() error { + if !dcl.IsEmptyValueIndirect(r.Subject) { + if err := r.Subject.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.SubjectAltName) { + if err := r.SubjectAltName.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateCertificateDescriptionSubjectDescriptionSubject) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) validate() error { + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionX509Description) validate() error { + if !dcl.IsEmptyValueIndirect(r.KeyUsage) { + if err := r.KeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CaOptions) { + if err := r.CaOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsage) validate() error { + if !dcl.IsEmptyValueIndirect(r.BaseKeyUsage) { + if err := r.BaseKeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.ExtendedKeyUsage) { + if err := r.ExtendedKeyUsage.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionCaOptions) validate() error { + if err := dcl.ValidateAtMostOneOfFieldsSet([]string{"IsCa"}, r.IsCa); err != nil { + return err + } + if err := dcl.ValidateAtMostOneOfFieldsSet([]string{"MaxIssuerPathLength"}, r.MaxIssuerPathLength); err != nil { + return err + } + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionPolicyIds) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) validate() error { + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionPublicKey) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionSubjectKeyId) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionAuthorityKeyId) validate() error { + return nil +} +func (r *CertificateCertificateDescriptionCertFingerprint) validate() error { + return nil +} +func (r *Certificate) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://privateca.googleapis.com/v1/", params) +} + +func (r *Certificate) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificates/{{name}}", nr.basePath(), userBasePath, params), nil +} + +func (r *Certificate) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificates", nr.basePath(), userBasePath, params), nil + +} + +func (r *Certificate) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificates/{{name}}:revoke", nr.basePath(), userBasePath, params), nil +} + +// certificateApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type certificateApiOperation interface { + do(context.Context, *Certificate, *Client) error +} + +// newUpdateCertificateUpdateCertificateRequest creates a request for an +// Certificate resource's UpdateCertificate update type by filling in the update +// fields based on the intended state of the resource. +func newUpdateCertificateUpdateCertificateRequest(ctx context.Context, f *Certificate, c *Client) (map[string]interface{}, error) { + req := map[string]interface{}{} + res := f + _ = res + + if v := f.Labels; !dcl.IsEmptyValueIndirect(v) { + req["labels"] = v + } + return req, nil +} + +// marshalUpdateCertificateUpdateCertificateRequest converts the update into +// the final JSON request body. +func marshalUpdateCertificateUpdateCertificateRequest(c *Client, m map[string]interface{}) ([]byte, error) { + + return json.Marshal(m) +} + +type updateCertificateUpdateCertificateOperation struct { + // If the update operation has the REQUIRES_APPLY_OPTIONS trait, this will be populated. + // Usually it will be nil - this is to prevent us from accidentally depending on apply + // options, which should usually be unnecessary. + ApplyOptions []dcl.ApplyOption + FieldDiffs []*dcl.FieldDiff +} + +// do creates a request and sends it to the appropriate URL. In most operations, +// do will transcribe a subset of the resource into a request object and send a +// PUT request to a single URL. + +func (op *updateCertificateUpdateCertificateOperation) do(ctx context.Context, r *Certificate, c *Client) error { + _, err := c.GetCertificate(ctx, r) + if err != nil { + return err + } + + u, err := r.updateURL(c.Config.BasePath, "UpdateCertificate") + if err != nil { + return err + } + mask := dcl.UpdateMask(op.FieldDiffs) + u, err = dcl.AddQueryParams(u, map[string]string{"updateMask": mask}) + if err != nil { + return err + } + + req, err := newUpdateCertificateUpdateCertificateRequest(ctx, r, c) + if err != nil { + return err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created update: %#v", req) + body, err := marshalUpdateCertificateUpdateCertificateRequest(c, req) + if err != nil { + return err + } + _, err = dcl.SendRequest(ctx, c.Config, "PATCH", u, bytes.NewBuffer(body), c.Config.RetryProvider) + if err != nil { + return err + } + + return nil +} + +func (c *Client) listCertificateRaw(ctx context.Context, r *Certificate, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != CertificateMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listCertificateOperation struct { + Certificates []map[string]interface{} `json:"certificates"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listCertificate(ctx context.Context, r *Certificate, pageToken string, pageSize int32) ([]*Certificate, string, error) { + b, err := c.listCertificateRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listCertificateOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*Certificate + for _, v := range m.Certificates { + res, err := unmarshalMapCertificate(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Project = r.Project + res.Location = r.Location + res.CaPool = r.CaPool + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllCertificate(ctx context.Context, f func(*Certificate) bool, resources []*Certificate) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeleteCertificate(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deleteCertificateOperation struct{} + +func (op *deleteCertificateOperation) do(ctx context.Context, r *Certificate, c *Client) error { + r, err := c.GetCertificate(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "Certificate not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetCertificate checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + _, err = dcl.SendRequest(ctx, c.Config, "POST", u, body, c.Config.RetryProvider) + if err != nil { + return fmt.Errorf("failed to delete Certificate: %w", err) + } + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createCertificateOperation struct { + response map[string]interface{} +} + +func (op *createCertificateOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createCertificateOperation) do(ctx context.Context, r *Certificate, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + + o, err := dcl.ResponseBodyAsJSON(resp) + if err != nil { + return fmt.Errorf("error decoding response body into JSON: %w", err) + } + op.response = o + + if _, err := c.GetCertificate(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + return nil +} + +func (c *Client) getCertificateRaw(ctx context.Context, r *Certificate) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + return b, nil +} + +func (c *Client) certificateDiffsForRawDesired(ctx context.Context, rawDesired *Certificate, opts ...dcl.ApplyOption) (initial, desired *Certificate, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *Certificate + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*Certificate); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected Certificate, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetCertificate(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a Certificate resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve Certificate resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that Certificate resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizeCertificateDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for Certificate: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for Certificate: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractCertificateFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizeCertificateInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for Certificate: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizeCertificateDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for Certificate: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffCertificate(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizeCertificateInitialState(rawInitial, rawDesired *Certificate) (*Certificate, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + + if !dcl.IsZeroValue(rawInitial.PemCsr) { + // Check if anything else is set. + if dcl.AnySet(rawInitial.Config) { + rawInitial.PemCsr = dcl.String("") + } + } + + if !dcl.IsZeroValue(rawInitial.Config) { + // Check if anything else is set. + if dcl.AnySet(rawInitial.PemCsr) { + rawInitial.Config = EmptyCertificateConfig + } + } + + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizeCertificateDesiredState(rawDesired, rawInitial *Certificate, opts ...dcl.ApplyOption) (*Certificate, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + rawDesired.Config = canonicalizeCertificateConfig(rawDesired.Config, nil, opts...) + rawDesired.RevocationDetails = canonicalizeCertificateRevocationDetails(rawDesired.RevocationDetails, nil, opts...) + rawDesired.CertificateDescription = canonicalizeCertificateCertificateDescription(rawDesired.CertificateDescription, nil, opts...) + + return rawDesired, nil + } + canonicalDesired := &Certificate{} + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawInitial.Name) { + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + if dcl.StringCanonicalize(rawDesired.PemCsr, rawInitial.PemCsr) { + canonicalDesired.PemCsr = rawInitial.PemCsr + } else { + canonicalDesired.PemCsr = rawDesired.PemCsr + } + canonicalDesired.Config = canonicalizeCertificateConfig(rawDesired.Config, rawInitial.Config, opts...) + if dcl.StringCanonicalize(rawDesired.Lifetime, rawInitial.Lifetime) { + canonicalDesired.Lifetime = rawInitial.Lifetime + } else { + canonicalDesired.Lifetime = rawDesired.Lifetime + } + if dcl.PartialSelfLinkToSelfLink(rawDesired.CertificateTemplate, rawInitial.CertificateTemplate) { + canonicalDesired.CertificateTemplate = rawInitial.CertificateTemplate + } else { + canonicalDesired.CertificateTemplate = rawDesired.CertificateTemplate + } + if dcl.IsZeroValue(rawDesired.SubjectMode) || (dcl.IsEmptyValueIndirect(rawDesired.SubjectMode) && dcl.IsEmptyValueIndirect(rawInitial.SubjectMode)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.SubjectMode = rawInitial.SubjectMode + } else { + canonicalDesired.SubjectMode = rawDesired.SubjectMode + } + if dcl.IsZeroValue(rawDesired.Labels) || (dcl.IsEmptyValueIndirect(rawDesired.Labels) && dcl.IsEmptyValueIndirect(rawInitial.Labels)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Labels = rawInitial.Labels + } else { + canonicalDesired.Labels = rawDesired.Labels + } + if dcl.NameToSelfLink(rawDesired.Project, rawInitial.Project) { + canonicalDesired.Project = rawInitial.Project + } else { + canonicalDesired.Project = rawDesired.Project + } + if dcl.NameToSelfLink(rawDesired.Location, rawInitial.Location) { + canonicalDesired.Location = rawInitial.Location + } else { + canonicalDesired.Location = rawDesired.Location + } + if dcl.NameToSelfLink(rawDesired.CaPool, rawInitial.CaPool) { + canonicalDesired.CaPool = rawInitial.CaPool + } else { + canonicalDesired.CaPool = rawDesired.CaPool + } + if dcl.NameToSelfLink(rawDesired.CertificateAuthority, rawInitial.CertificateAuthority) { + canonicalDesired.CertificateAuthority = rawInitial.CertificateAuthority + } else { + canonicalDesired.CertificateAuthority = rawDesired.CertificateAuthority + } + + if canonicalDesired.PemCsr != nil { + // Check if anything else is set. + if dcl.AnySet(rawDesired.Config) { + canonicalDesired.PemCsr = dcl.String("") + } + } + + if canonicalDesired.Config != nil { + // Check if anything else is set. + if dcl.AnySet(rawDesired.PemCsr) { + canonicalDesired.Config = EmptyCertificateConfig + } + } + + return canonicalDesired, nil +} + +func canonicalizeCertificateNewState(c *Client, rawNew, rawDesired *Certificate) (*Certificate, error) { + + if dcl.IsEmptyValueIndirect(rawNew.Name) && dcl.IsEmptyValueIndirect(rawDesired.Name) { + rawNew.Name = rawDesired.Name + } else { + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawNew.Name) { + rawNew.Name = rawDesired.Name + } + } + + if dcl.IsEmptyValueIndirect(rawNew.PemCsr) && dcl.IsEmptyValueIndirect(rawDesired.PemCsr) { + rawNew.PemCsr = rawDesired.PemCsr + } else { + if dcl.StringCanonicalize(rawDesired.PemCsr, rawNew.PemCsr) { + rawNew.PemCsr = rawDesired.PemCsr + } + } + + if dcl.IsEmptyValueIndirect(rawNew.Config) && dcl.IsEmptyValueIndirect(rawDesired.Config) { + rawNew.Config = rawDesired.Config + } else { + rawNew.Config = canonicalizeNewCertificateConfig(c, rawDesired.Config, rawNew.Config) + } + + if dcl.IsEmptyValueIndirect(rawNew.IssuerCertificateAuthority) && dcl.IsEmptyValueIndirect(rawDesired.IssuerCertificateAuthority) { + rawNew.IssuerCertificateAuthority = rawDesired.IssuerCertificateAuthority + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.Lifetime) && dcl.IsEmptyValueIndirect(rawDesired.Lifetime) { + rawNew.Lifetime = rawDesired.Lifetime + } else { + if dcl.StringCanonicalize(rawDesired.Lifetime, rawNew.Lifetime) { + rawNew.Lifetime = rawDesired.Lifetime + } + } + + if dcl.IsEmptyValueIndirect(rawNew.CertificateTemplate) && dcl.IsEmptyValueIndirect(rawDesired.CertificateTemplate) { + rawNew.CertificateTemplate = rawDesired.CertificateTemplate + } else { + if dcl.PartialSelfLinkToSelfLink(rawDesired.CertificateTemplate, rawNew.CertificateTemplate) { + rawNew.CertificateTemplate = rawDesired.CertificateTemplate + } + } + + if dcl.IsEmptyValueIndirect(rawNew.SubjectMode) && dcl.IsEmptyValueIndirect(rawDesired.SubjectMode) { + rawNew.SubjectMode = rawDesired.SubjectMode + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.RevocationDetails) && dcl.IsEmptyValueIndirect(rawDesired.RevocationDetails) { + rawNew.RevocationDetails = rawDesired.RevocationDetails + } else { + rawNew.RevocationDetails = canonicalizeNewCertificateRevocationDetails(c, rawDesired.RevocationDetails, rawNew.RevocationDetails) + } + + if dcl.IsEmptyValueIndirect(rawNew.PemCertificate) && dcl.IsEmptyValueIndirect(rawDesired.PemCertificate) { + rawNew.PemCertificate = rawDesired.PemCertificate + } else { + if dcl.StringCanonicalize(rawDesired.PemCertificate, rawNew.PemCertificate) { + rawNew.PemCertificate = rawDesired.PemCertificate + } + } + + if dcl.IsEmptyValueIndirect(rawNew.CertificateDescription) && dcl.IsEmptyValueIndirect(rawDesired.CertificateDescription) { + rawNew.CertificateDescription = rawDesired.CertificateDescription + } else { + rawNew.CertificateDescription = canonicalizeNewCertificateCertificateDescription(c, rawDesired.CertificateDescription, rawNew.CertificateDescription) + } + + if dcl.IsEmptyValueIndirect(rawNew.PemCertificateChain) && dcl.IsEmptyValueIndirect(rawDesired.PemCertificateChain) { + rawNew.PemCertificateChain = rawDesired.PemCertificateChain + } else { + if dcl.StringArrayCanonicalize(rawDesired.PemCertificateChain, rawNew.PemCertificateChain) { + rawNew.PemCertificateChain = rawDesired.PemCertificateChain + } + } + + if dcl.IsEmptyValueIndirect(rawNew.CreateTime) && dcl.IsEmptyValueIndirect(rawDesired.CreateTime) { + rawNew.CreateTime = rawDesired.CreateTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.UpdateTime) && dcl.IsEmptyValueIndirect(rawDesired.UpdateTime) { + rawNew.UpdateTime = rawDesired.UpdateTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.Labels) && dcl.IsEmptyValueIndirect(rawDesired.Labels) { + rawNew.Labels = rawDesired.Labels + } else { + } + + rawNew.Project = rawDesired.Project + + rawNew.Location = rawDesired.Location + + rawNew.CaPool = rawDesired.CaPool + + rawNew.CertificateAuthority = rawDesired.CertificateAuthority + + return rawNew, nil +} + +func canonicalizeCertificateConfig(des, initial *CertificateConfig, opts ...dcl.ApplyOption) *CertificateConfig { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfig{} + + cDes.SubjectConfig = canonicalizeCertificateConfigSubjectConfig(des.SubjectConfig, initial.SubjectConfig, opts...) + cDes.X509Config = canonicalizeCertificateConfigX509Config(des.X509Config, initial.X509Config, opts...) + cDes.PublicKey = canonicalizeCertificateConfigPublicKey(des.PublicKey, initial.PublicKey, opts...) + + return cDes +} + +func canonicalizeCertificateConfigSlice(des, initial []CertificateConfig, opts ...dcl.ApplyOption) []CertificateConfig { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfig, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfig(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfig, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfig(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfig(c *Client, des, nw *CertificateConfig) *CertificateConfig { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfig while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.SubjectConfig = canonicalizeNewCertificateConfigSubjectConfig(c, des.SubjectConfig, nw.SubjectConfig) + nw.X509Config = canonicalizeNewCertificateConfigX509Config(c, des.X509Config, nw.X509Config) + nw.PublicKey = canonicalizeNewCertificateConfigPublicKey(c, des.PublicKey, nw.PublicKey) + + return nw +} + +func canonicalizeNewCertificateConfigSet(c *Client, des, nw []CertificateConfig) []CertificateConfig { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfig + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfig(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigSlice(c *Client, des, nw []CertificateConfig) []CertificateConfig { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfig + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfig(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigSubjectConfig(des, initial *CertificateConfigSubjectConfig, opts ...dcl.ApplyOption) *CertificateConfigSubjectConfig { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigSubjectConfig{} + + cDes.Subject = canonicalizeCertificateConfigSubjectConfigSubject(des.Subject, initial.Subject, opts...) + cDes.SubjectAltName = canonicalizeCertificateConfigSubjectConfigSubjectAltName(des.SubjectAltName, initial.SubjectAltName, opts...) + + return cDes +} + +func canonicalizeCertificateConfigSubjectConfigSlice(des, initial []CertificateConfigSubjectConfig, opts ...dcl.ApplyOption) []CertificateConfigSubjectConfig { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigSubjectConfig, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigSubjectConfig(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigSubjectConfig, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigSubjectConfig(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigSubjectConfig(c *Client, des, nw *CertificateConfigSubjectConfig) *CertificateConfigSubjectConfig { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigSubjectConfig while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Subject = canonicalizeNewCertificateConfigSubjectConfigSubject(c, des.Subject, nw.Subject) + nw.SubjectAltName = canonicalizeNewCertificateConfigSubjectConfigSubjectAltName(c, des.SubjectAltName, nw.SubjectAltName) + + return nw +} + +func canonicalizeNewCertificateConfigSubjectConfigSet(c *Client, des, nw []CertificateConfigSubjectConfig) []CertificateConfigSubjectConfig { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigSubjectConfig + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigSubjectConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigSubjectConfig(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigSubjectConfigSlice(c *Client, des, nw []CertificateConfigSubjectConfig) []CertificateConfigSubjectConfig { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigSubjectConfig + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigSubjectConfig(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigSubjectConfigSubject(des, initial *CertificateConfigSubjectConfigSubject, opts ...dcl.ApplyOption) *CertificateConfigSubjectConfigSubject { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigSubjectConfigSubject{} + + if dcl.StringCanonicalize(des.CommonName, initial.CommonName) || dcl.IsZeroValue(des.CommonName) { + cDes.CommonName = initial.CommonName + } else { + cDes.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, initial.CountryCode) || dcl.IsZeroValue(des.CountryCode) { + cDes.CountryCode = initial.CountryCode + } else { + cDes.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, initial.Organization) || dcl.IsZeroValue(des.Organization) { + cDes.Organization = initial.Organization + } else { + cDes.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, initial.OrganizationalUnit) || dcl.IsZeroValue(des.OrganizationalUnit) { + cDes.OrganizationalUnit = initial.OrganizationalUnit + } else { + cDes.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, initial.Locality) || dcl.IsZeroValue(des.Locality) { + cDes.Locality = initial.Locality + } else { + cDes.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, initial.Province) || dcl.IsZeroValue(des.Province) { + cDes.Province = initial.Province + } else { + cDes.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, initial.StreetAddress) || dcl.IsZeroValue(des.StreetAddress) { + cDes.StreetAddress = initial.StreetAddress + } else { + cDes.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, initial.PostalCode) || dcl.IsZeroValue(des.PostalCode) { + cDes.PostalCode = initial.PostalCode + } else { + cDes.PostalCode = des.PostalCode + } + + return cDes +} + +func canonicalizeCertificateConfigSubjectConfigSubjectSlice(des, initial []CertificateConfigSubjectConfigSubject, opts ...dcl.ApplyOption) []CertificateConfigSubjectConfigSubject { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigSubjectConfigSubject, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigSubjectConfigSubject(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigSubjectConfigSubject, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigSubjectConfigSubject(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigSubjectConfigSubject(c *Client, des, nw *CertificateConfigSubjectConfigSubject) *CertificateConfigSubjectConfigSubject { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigSubjectConfigSubject while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.CommonName, nw.CommonName) { + nw.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, nw.CountryCode) { + nw.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, nw.Organization) { + nw.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, nw.OrganizationalUnit) { + nw.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, nw.Locality) { + nw.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, nw.Province) { + nw.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, nw.StreetAddress) { + nw.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, nw.PostalCode) { + nw.PostalCode = des.PostalCode + } + + return nw +} + +func canonicalizeNewCertificateConfigSubjectConfigSubjectSet(c *Client, des, nw []CertificateConfigSubjectConfigSubject) []CertificateConfigSubjectConfigSubject { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigSubjectConfigSubject + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigSubjectConfigSubjectNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigSubjectConfigSubject(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigSubjectConfigSubjectSlice(c *Client, des, nw []CertificateConfigSubjectConfigSubject) []CertificateConfigSubjectConfigSubject { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigSubjectConfigSubject + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigSubjectConfigSubject(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigSubjectConfigSubjectAltName(des, initial *CertificateConfigSubjectConfigSubjectAltName, opts ...dcl.ApplyOption) *CertificateConfigSubjectConfigSubjectAltName { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigSubjectConfigSubjectAltName{} + + if dcl.StringArrayCanonicalize(des.DnsNames, initial.DnsNames) { + cDes.DnsNames = initial.DnsNames + } else { + cDes.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, initial.Uris) { + cDes.Uris = initial.Uris + } else { + cDes.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, initial.EmailAddresses) { + cDes.EmailAddresses = initial.EmailAddresses + } else { + cDes.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, initial.IPAddresses) { + cDes.IPAddresses = initial.IPAddresses + } else { + cDes.IPAddresses = des.IPAddresses + } + + return cDes +} + +func canonicalizeCertificateConfigSubjectConfigSubjectAltNameSlice(des, initial []CertificateConfigSubjectConfigSubjectAltName, opts ...dcl.ApplyOption) []CertificateConfigSubjectConfigSubjectAltName { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigSubjectConfigSubjectAltName, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigSubjectConfigSubjectAltName(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigSubjectConfigSubjectAltName, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigSubjectConfigSubjectAltName(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigSubjectConfigSubjectAltName(c *Client, des, nw *CertificateConfigSubjectConfigSubjectAltName) *CertificateConfigSubjectConfigSubjectAltName { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigSubjectConfigSubjectAltName while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DnsNames, nw.DnsNames) { + nw.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, nw.Uris) { + nw.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, nw.EmailAddresses) { + nw.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, nw.IPAddresses) { + nw.IPAddresses = des.IPAddresses + } + + return nw +} + +func canonicalizeNewCertificateConfigSubjectConfigSubjectAltNameSet(c *Client, des, nw []CertificateConfigSubjectConfigSubjectAltName) []CertificateConfigSubjectConfigSubjectAltName { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigSubjectConfigSubjectAltName + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigSubjectConfigSubjectAltNameNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigSubjectConfigSubjectAltName(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigSubjectConfigSubjectAltNameSlice(c *Client, des, nw []CertificateConfigSubjectConfigSubjectAltName) []CertificateConfigSubjectConfigSubjectAltName { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigSubjectConfigSubjectAltName + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigSubjectConfigSubjectAltName(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509Config(des, initial *CertificateConfigX509Config, opts ...dcl.ApplyOption) *CertificateConfigX509Config { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509Config{} + + cDes.KeyUsage = canonicalizeCertificateConfigX509ConfigKeyUsage(des.KeyUsage, initial.KeyUsage, opts...) + cDes.CaOptions = canonicalizeCertificateConfigX509ConfigCaOptions(des.CaOptions, initial.CaOptions, opts...) + cDes.PolicyIds = canonicalizeCertificateConfigX509ConfigPolicyIdsSlice(des.PolicyIds, initial.PolicyIds, opts...) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, initial.AiaOcspServers) { + cDes.AiaOcspServers = initial.AiaOcspServers + } else { + cDes.AiaOcspServers = des.AiaOcspServers + } + cDes.AdditionalExtensions = canonicalizeCertificateConfigX509ConfigAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigSlice(des, initial []CertificateConfigX509Config, opts ...dcl.ApplyOption) []CertificateConfigX509Config { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509Config, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509Config(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509Config, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509Config(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509Config(c *Client, des, nw *CertificateConfigX509Config) *CertificateConfigX509Config { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509Config while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.KeyUsage = canonicalizeNewCertificateConfigX509ConfigKeyUsage(c, des.KeyUsage, nw.KeyUsage) + nw.CaOptions = canonicalizeNewCertificateConfigX509ConfigCaOptions(c, des.CaOptions, nw.CaOptions) + nw.PolicyIds = canonicalizeNewCertificateConfigX509ConfigPolicyIdsSlice(c, des.PolicyIds, nw.PolicyIds) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, nw.AiaOcspServers) { + nw.AiaOcspServers = des.AiaOcspServers + } + nw.AdditionalExtensions = canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigSet(c *Client, des, nw []CertificateConfigX509Config) []CertificateConfigX509Config { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509Config + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509Config(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigSlice(c *Client, des, nw []CertificateConfigX509Config) []CertificateConfigX509Config { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509Config + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509Config(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigKeyUsage(des, initial *CertificateConfigX509ConfigKeyUsage, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigKeyUsage{} + + cDes.BaseKeyUsage = canonicalizeCertificateConfigX509ConfigKeyUsageBaseKeyUsage(des.BaseKeyUsage, initial.BaseKeyUsage, opts...) + cDes.ExtendedKeyUsage = canonicalizeCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(des.ExtendedKeyUsage, initial.ExtendedKeyUsage, opts...) + cDes.UnknownExtendedKeyUsages = canonicalizeCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(des.UnknownExtendedKeyUsages, initial.UnknownExtendedKeyUsages, opts...) + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageSlice(des, initial []CertificateConfigX509ConfigKeyUsage, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsage(c *Client, des, nw *CertificateConfigX509ConfigKeyUsage) *CertificateConfigX509ConfigKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.BaseKeyUsage = canonicalizeNewCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, des.BaseKeyUsage, nw.BaseKeyUsage) + nw.ExtendedKeyUsage = canonicalizeNewCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, des.ExtendedKeyUsage, nw.ExtendedKeyUsage) + nw.UnknownExtendedKeyUsages = canonicalizeNewCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c, des.UnknownExtendedKeyUsages, nw.UnknownExtendedKeyUsages) + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageSet(c *Client, des, nw []CertificateConfigX509ConfigKeyUsage) []CertificateConfigX509ConfigKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageSlice(c *Client, des, nw []CertificateConfigX509ConfigKeyUsage) []CertificateConfigX509ConfigKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageBaseKeyUsage(des, initial *CertificateConfigX509ConfigKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + + if dcl.BoolCanonicalize(des.DigitalSignature, initial.DigitalSignature) || dcl.IsZeroValue(des.DigitalSignature) { + cDes.DigitalSignature = initial.DigitalSignature + } else { + cDes.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, initial.ContentCommitment) || dcl.IsZeroValue(des.ContentCommitment) { + cDes.ContentCommitment = initial.ContentCommitment + } else { + cDes.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, initial.KeyEncipherment) || dcl.IsZeroValue(des.KeyEncipherment) { + cDes.KeyEncipherment = initial.KeyEncipherment + } else { + cDes.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, initial.DataEncipherment) || dcl.IsZeroValue(des.DataEncipherment) { + cDes.DataEncipherment = initial.DataEncipherment + } else { + cDes.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, initial.KeyAgreement) || dcl.IsZeroValue(des.KeyAgreement) { + cDes.KeyAgreement = initial.KeyAgreement + } else { + cDes.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, initial.CertSign) || dcl.IsZeroValue(des.CertSign) { + cDes.CertSign = initial.CertSign + } else { + cDes.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, initial.CrlSign) || dcl.IsZeroValue(des.CrlSign) { + cDes.CrlSign = initial.CrlSign + } else { + cDes.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, initial.EncipherOnly) || dcl.IsZeroValue(des.EncipherOnly) { + cDes.EncipherOnly = initial.EncipherOnly + } else { + cDes.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, initial.DecipherOnly) || dcl.IsZeroValue(des.DecipherOnly) { + cDes.DecipherOnly = initial.DecipherOnly + } else { + cDes.DecipherOnly = des.DecipherOnly + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageBaseKeyUsageSlice(des, initial []CertificateConfigX509ConfigKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigKeyUsageBaseKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsageBaseKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigKeyUsageBaseKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsageBaseKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c *Client, des, nw *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) *CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigKeyUsageBaseKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.DigitalSignature, nw.DigitalSignature) { + nw.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, nw.ContentCommitment) { + nw.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, nw.KeyEncipherment) { + nw.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, nw.DataEncipherment) { + nw.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, nw.KeyAgreement) { + nw.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, nw.CertSign) { + nw.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, nw.CrlSign) { + nw.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, nw.EncipherOnly) { + nw.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, nw.DecipherOnly) { + nw.DecipherOnly = des.DecipherOnly + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageBaseKeyUsageSet(c *Client, des, nw []CertificateConfigX509ConfigKeyUsageBaseKeyUsage) []CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigKeyUsageBaseKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigKeyUsageBaseKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageBaseKeyUsageSlice(c *Client, des, nw []CertificateConfigX509ConfigKeyUsageBaseKeyUsage) []CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigKeyUsageBaseKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(des, initial *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + + if dcl.BoolCanonicalize(des.ServerAuth, initial.ServerAuth) || dcl.IsZeroValue(des.ServerAuth) { + cDes.ServerAuth = initial.ServerAuth + } else { + cDes.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, initial.ClientAuth) || dcl.IsZeroValue(des.ClientAuth) { + cDes.ClientAuth = initial.ClientAuth + } else { + cDes.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, initial.CodeSigning) || dcl.IsZeroValue(des.CodeSigning) { + cDes.CodeSigning = initial.CodeSigning + } else { + cDes.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, initial.EmailProtection) || dcl.IsZeroValue(des.EmailProtection) { + cDes.EmailProtection = initial.EmailProtection + } else { + cDes.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, initial.TimeStamping) || dcl.IsZeroValue(des.TimeStamping) { + cDes.TimeStamping = initial.TimeStamping + } else { + cDes.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, initial.OcspSigning) || dcl.IsZeroValue(des.OcspSigning) { + cDes.OcspSigning = initial.OcspSigning + } else { + cDes.OcspSigning = des.OcspSigning + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSlice(des, initial []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c *Client, des, nw *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigKeyUsageExtendedKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.ServerAuth, nw.ServerAuth) { + nw.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, nw.ClientAuth) { + nw.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, nw.CodeSigning) { + nw.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, nw.EmailProtection) { + nw.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, nw.TimeStamping) { + nw.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, nw.OcspSigning) { + nw.OcspSigning = des.OcspSigning + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSet(c *Client, des, nw []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigKeyUsageExtendedKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSlice(c *Client, des, nw []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(des, initial *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(des, initial []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c *Client, des, nw *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSet(c *Client, des, nw []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, des, nw []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigCaOptions(des, initial *CertificateConfigX509ConfigCaOptions, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigCaOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigCaOptions{} + + if dcl.BoolCanonicalize(des.IsCa, initial.IsCa) || dcl.IsZeroValue(des.IsCa) { + cDes.IsCa = initial.IsCa + } else { + cDes.IsCa = des.IsCa + } + if dcl.BoolCanonicalize(des.NonCa, initial.NonCa) || dcl.IsZeroValue(des.NonCa) { + cDes.NonCa = initial.NonCa + } else { + cDes.NonCa = des.NonCa + } + if dcl.IsZeroValue(des.MaxIssuerPathLength) || (dcl.IsEmptyValueIndirect(des.MaxIssuerPathLength) && dcl.IsEmptyValueIndirect(initial.MaxIssuerPathLength)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxIssuerPathLength = initial.MaxIssuerPathLength + } else { + cDes.MaxIssuerPathLength = des.MaxIssuerPathLength + } + if dcl.BoolCanonicalize(des.ZeroMaxIssuerPathLength, initial.ZeroMaxIssuerPathLength) || dcl.IsZeroValue(des.ZeroMaxIssuerPathLength) { + cDes.ZeroMaxIssuerPathLength = initial.ZeroMaxIssuerPathLength + } else { + cDes.ZeroMaxIssuerPathLength = des.ZeroMaxIssuerPathLength + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigCaOptionsSlice(des, initial []CertificateConfigX509ConfigCaOptions, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigCaOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigCaOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigCaOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigCaOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigCaOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigCaOptions(c *Client, des, nw *CertificateConfigX509ConfigCaOptions) *CertificateConfigX509ConfigCaOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigCaOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.IsCa, nw.IsCa) { + nw.IsCa = des.IsCa + } + if dcl.BoolCanonicalize(des.NonCa, nw.NonCa) { + nw.NonCa = des.NonCa + } + if dcl.BoolCanonicalize(des.ZeroMaxIssuerPathLength, nw.ZeroMaxIssuerPathLength) { + nw.ZeroMaxIssuerPathLength = des.ZeroMaxIssuerPathLength + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigCaOptionsSet(c *Client, des, nw []CertificateConfigX509ConfigCaOptions) []CertificateConfigX509ConfigCaOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigCaOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigCaOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigCaOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigCaOptionsSlice(c *Client, des, nw []CertificateConfigX509ConfigCaOptions) []CertificateConfigX509ConfigCaOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigCaOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigCaOptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigPolicyIds(des, initial *CertificateConfigX509ConfigPolicyIds, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigPolicyIds { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigPolicyIds{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigPolicyIdsSlice(des, initial []CertificateConfigX509ConfigPolicyIds, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigPolicyIds { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigPolicyIds, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigPolicyIds(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigPolicyIds, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigPolicyIds(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigPolicyIds(c *Client, des, nw *CertificateConfigX509ConfigPolicyIds) *CertificateConfigX509ConfigPolicyIds { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigPolicyIds while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigPolicyIdsSet(c *Client, des, nw []CertificateConfigX509ConfigPolicyIds) []CertificateConfigX509ConfigPolicyIds { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigPolicyIds + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigPolicyIdsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigPolicyIds(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigPolicyIdsSlice(c *Client, des, nw []CertificateConfigX509ConfigPolicyIds) []CertificateConfigX509ConfigPolicyIds { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigPolicyIds + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigPolicyIds(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigAdditionalExtensions(des, initial *CertificateConfigX509ConfigAdditionalExtensions, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigAdditionalExtensions{} + + cDes.ObjectId = canonicalizeCertificateConfigX509ConfigAdditionalExtensionsObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigAdditionalExtensionsSlice(des, initial []CertificateConfigX509ConfigAdditionalExtensions, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigAdditionalExtensions(c *Client, des, nw *CertificateConfigX509ConfigAdditionalExtensions) *CertificateConfigX509ConfigAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsSet(c *Client, des, nw []CertificateConfigX509ConfigAdditionalExtensions) []CertificateConfigX509ConfigAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsSlice(c *Client, des, nw []CertificateConfigX509ConfigAdditionalExtensions) []CertificateConfigX509ConfigAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigX509ConfigAdditionalExtensionsObjectId(des, initial *CertificateConfigX509ConfigAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) *CertificateConfigX509ConfigAdditionalExtensionsObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateConfigX509ConfigAdditionalExtensionsObjectIdSlice(des, initial []CertificateConfigX509ConfigAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) []CertificateConfigX509ConfigAdditionalExtensionsObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigX509ConfigAdditionalExtensionsObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigX509ConfigAdditionalExtensionsObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigX509ConfigAdditionalExtensionsObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigX509ConfigAdditionalExtensionsObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsObjectId(c *Client, des, nw *CertificateConfigX509ConfigAdditionalExtensionsObjectId) *CertificateConfigX509ConfigAdditionalExtensionsObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigX509ConfigAdditionalExtensionsObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsObjectIdSet(c *Client, des, nw []CertificateConfigX509ConfigAdditionalExtensionsObjectId) []CertificateConfigX509ConfigAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigX509ConfigAdditionalExtensionsObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigX509ConfigAdditionalExtensionsObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsObjectIdSlice(c *Client, des, nw []CertificateConfigX509ConfigAdditionalExtensionsObjectId) []CertificateConfigX509ConfigAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigX509ConfigAdditionalExtensionsObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateConfigPublicKey(des, initial *CertificateConfigPublicKey, opts ...dcl.ApplyOption) *CertificateConfigPublicKey { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateConfigPublicKey{} + + if dcl.StringCanonicalize(des.Key, initial.Key) || dcl.IsZeroValue(des.Key) { + cDes.Key = initial.Key + } else { + cDes.Key = des.Key + } + if dcl.IsZeroValue(des.Format) || (dcl.IsEmptyValueIndirect(des.Format) && dcl.IsEmptyValueIndirect(initial.Format)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Format = initial.Format + } else { + cDes.Format = des.Format + } + + return cDes +} + +func canonicalizeCertificateConfigPublicKeySlice(des, initial []CertificateConfigPublicKey, opts ...dcl.ApplyOption) []CertificateConfigPublicKey { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateConfigPublicKey, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateConfigPublicKey(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateConfigPublicKey, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateConfigPublicKey(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateConfigPublicKey(c *Client, des, nw *CertificateConfigPublicKey) *CertificateConfigPublicKey { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateConfigPublicKey while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Key, nw.Key) { + nw.Key = des.Key + } + + return nw +} + +func canonicalizeNewCertificateConfigPublicKeySet(c *Client, des, nw []CertificateConfigPublicKey) []CertificateConfigPublicKey { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateConfigPublicKey + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateConfigPublicKeyNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateConfigPublicKey(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateConfigPublicKeySlice(c *Client, des, nw []CertificateConfigPublicKey) []CertificateConfigPublicKey { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateConfigPublicKey + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateConfigPublicKey(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateRevocationDetails(des, initial *CertificateRevocationDetails, opts ...dcl.ApplyOption) *CertificateRevocationDetails { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateRevocationDetails{} + + if dcl.IsZeroValue(des.RevocationState) || (dcl.IsEmptyValueIndirect(des.RevocationState) && dcl.IsEmptyValueIndirect(initial.RevocationState)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.RevocationState = initial.RevocationState + } else { + cDes.RevocationState = des.RevocationState + } + if dcl.IsZeroValue(des.RevocationTime) || (dcl.IsEmptyValueIndirect(des.RevocationTime) && dcl.IsEmptyValueIndirect(initial.RevocationTime)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.RevocationTime = initial.RevocationTime + } else { + cDes.RevocationTime = des.RevocationTime + } + + return cDes +} + +func canonicalizeCertificateRevocationDetailsSlice(des, initial []CertificateRevocationDetails, opts ...dcl.ApplyOption) []CertificateRevocationDetails { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateRevocationDetails, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateRevocationDetails(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateRevocationDetails, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateRevocationDetails(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateRevocationDetails(c *Client, des, nw *CertificateRevocationDetails) *CertificateRevocationDetails { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateRevocationDetails while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateRevocationDetailsSet(c *Client, des, nw []CertificateRevocationDetails) []CertificateRevocationDetails { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateRevocationDetails + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateRevocationDetailsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateRevocationDetails(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateRevocationDetailsSlice(c *Client, des, nw []CertificateRevocationDetails) []CertificateRevocationDetails { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateRevocationDetails + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateRevocationDetails(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescription(des, initial *CertificateCertificateDescription, opts ...dcl.ApplyOption) *CertificateCertificateDescription { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescription{} + + cDes.SubjectDescription = canonicalizeCertificateCertificateDescriptionSubjectDescription(des.SubjectDescription, initial.SubjectDescription, opts...) + cDes.X509Description = canonicalizeCertificateCertificateDescriptionX509Description(des.X509Description, initial.X509Description, opts...) + cDes.PublicKey = canonicalizeCertificateCertificateDescriptionPublicKey(des.PublicKey, initial.PublicKey, opts...) + cDes.SubjectKeyId = canonicalizeCertificateCertificateDescriptionSubjectKeyId(des.SubjectKeyId, initial.SubjectKeyId, opts...) + cDes.AuthorityKeyId = canonicalizeCertificateCertificateDescriptionAuthorityKeyId(des.AuthorityKeyId, initial.AuthorityKeyId, opts...) + if dcl.StringArrayCanonicalize(des.CrlDistributionPoints, initial.CrlDistributionPoints) { + cDes.CrlDistributionPoints = initial.CrlDistributionPoints + } else { + cDes.CrlDistributionPoints = des.CrlDistributionPoints + } + if dcl.StringArrayCanonicalize(des.AiaIssuingCertificateUrls, initial.AiaIssuingCertificateUrls) { + cDes.AiaIssuingCertificateUrls = initial.AiaIssuingCertificateUrls + } else { + cDes.AiaIssuingCertificateUrls = des.AiaIssuingCertificateUrls + } + cDes.CertFingerprint = canonicalizeCertificateCertificateDescriptionCertFingerprint(des.CertFingerprint, initial.CertFingerprint, opts...) + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSlice(des, initial []CertificateCertificateDescription, opts ...dcl.ApplyOption) []CertificateCertificateDescription { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescription, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescription(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescription, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescription(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescription(c *Client, des, nw *CertificateCertificateDescription) *CertificateCertificateDescription { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescription while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.SubjectDescription = canonicalizeNewCertificateCertificateDescriptionSubjectDescription(c, des.SubjectDescription, nw.SubjectDescription) + nw.X509Description = canonicalizeNewCertificateCertificateDescriptionX509Description(c, des.X509Description, nw.X509Description) + nw.PublicKey = canonicalizeNewCertificateCertificateDescriptionPublicKey(c, des.PublicKey, nw.PublicKey) + nw.SubjectKeyId = canonicalizeNewCertificateCertificateDescriptionSubjectKeyId(c, des.SubjectKeyId, nw.SubjectKeyId) + nw.AuthorityKeyId = canonicalizeNewCertificateCertificateDescriptionAuthorityKeyId(c, des.AuthorityKeyId, nw.AuthorityKeyId) + if dcl.StringArrayCanonicalize(des.CrlDistributionPoints, nw.CrlDistributionPoints) { + nw.CrlDistributionPoints = des.CrlDistributionPoints + } + if dcl.StringArrayCanonicalize(des.AiaIssuingCertificateUrls, nw.AiaIssuingCertificateUrls) { + nw.AiaIssuingCertificateUrls = des.AiaIssuingCertificateUrls + } + nw.CertFingerprint = canonicalizeNewCertificateCertificateDescriptionCertFingerprint(c, des.CertFingerprint, nw.CertFingerprint) + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSet(c *Client, des, nw []CertificateCertificateDescription) []CertificateCertificateDescription { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescription + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescription(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSlice(c *Client, des, nw []CertificateCertificateDescription) []CertificateCertificateDescription { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescription + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescription(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescription(des, initial *CertificateCertificateDescriptionSubjectDescription, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionSubjectDescription { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionSubjectDescription{} + + cDes.Subject = canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubject(des.Subject, initial.Subject, opts...) + cDes.SubjectAltName = canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(des.SubjectAltName, initial.SubjectAltName, opts...) + if dcl.StringCanonicalize(des.HexSerialNumber, initial.HexSerialNumber) || dcl.IsZeroValue(des.HexSerialNumber) { + cDes.HexSerialNumber = initial.HexSerialNumber + } else { + cDes.HexSerialNumber = des.HexSerialNumber + } + if dcl.StringCanonicalize(des.Lifetime, initial.Lifetime) || dcl.IsZeroValue(des.Lifetime) { + cDes.Lifetime = initial.Lifetime + } else { + cDes.Lifetime = des.Lifetime + } + if dcl.IsZeroValue(des.NotBeforeTime) || (dcl.IsEmptyValueIndirect(des.NotBeforeTime) && dcl.IsEmptyValueIndirect(initial.NotBeforeTime)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.NotBeforeTime = initial.NotBeforeTime + } else { + cDes.NotBeforeTime = des.NotBeforeTime + } + if dcl.IsZeroValue(des.NotAfterTime) || (dcl.IsEmptyValueIndirect(des.NotAfterTime) && dcl.IsEmptyValueIndirect(initial.NotAfterTime)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.NotAfterTime = initial.NotAfterTime + } else { + cDes.NotAfterTime = des.NotAfterTime + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSlice(des, initial []CertificateCertificateDescriptionSubjectDescription, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionSubjectDescription { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionSubjectDescription, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescription(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionSubjectDescription, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescription(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescription(c *Client, des, nw *CertificateCertificateDescriptionSubjectDescription) *CertificateCertificateDescriptionSubjectDescription { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionSubjectDescription while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.Subject = canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubject(c, des.Subject, nw.Subject) + nw.SubjectAltName = canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, des.SubjectAltName, nw.SubjectAltName) + if dcl.StringCanonicalize(des.HexSerialNumber, nw.HexSerialNumber) { + nw.HexSerialNumber = des.HexSerialNumber + } + if dcl.StringCanonicalize(des.Lifetime, nw.Lifetime) { + nw.Lifetime = des.Lifetime + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSet(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescription) []CertificateCertificateDescriptionSubjectDescription { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionSubjectDescription + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionSubjectDescriptionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescription(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSlice(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescription) []CertificateCertificateDescriptionSubjectDescription { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionSubjectDescription + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescription(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubject(des, initial *CertificateCertificateDescriptionSubjectDescriptionSubject, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionSubjectDescriptionSubject { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionSubjectDescriptionSubject{} + + if dcl.StringCanonicalize(des.CommonName, initial.CommonName) || dcl.IsZeroValue(des.CommonName) { + cDes.CommonName = initial.CommonName + } else { + cDes.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, initial.CountryCode) || dcl.IsZeroValue(des.CountryCode) { + cDes.CountryCode = initial.CountryCode + } else { + cDes.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, initial.Organization) || dcl.IsZeroValue(des.Organization) { + cDes.Organization = initial.Organization + } else { + cDes.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, initial.OrganizationalUnit) || dcl.IsZeroValue(des.OrganizationalUnit) { + cDes.OrganizationalUnit = initial.OrganizationalUnit + } else { + cDes.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, initial.Locality) || dcl.IsZeroValue(des.Locality) { + cDes.Locality = initial.Locality + } else { + cDes.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, initial.Province) || dcl.IsZeroValue(des.Province) { + cDes.Province = initial.Province + } else { + cDes.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, initial.StreetAddress) || dcl.IsZeroValue(des.StreetAddress) { + cDes.StreetAddress = initial.StreetAddress + } else { + cDes.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, initial.PostalCode) || dcl.IsZeroValue(des.PostalCode) { + cDes.PostalCode = initial.PostalCode + } else { + cDes.PostalCode = des.PostalCode + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectSlice(des, initial []CertificateCertificateDescriptionSubjectDescriptionSubject, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionSubjectDescriptionSubject { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubject, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubject(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubject, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubject(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubject(c *Client, des, nw *CertificateCertificateDescriptionSubjectDescriptionSubject) *CertificateCertificateDescriptionSubjectDescriptionSubject { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionSubjectDescriptionSubject while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.CommonName, nw.CommonName) { + nw.CommonName = des.CommonName + } + if dcl.StringCanonicalize(des.CountryCode, nw.CountryCode) { + nw.CountryCode = des.CountryCode + } + if dcl.StringCanonicalize(des.Organization, nw.Organization) { + nw.Organization = des.Organization + } + if dcl.StringCanonicalize(des.OrganizationalUnit, nw.OrganizationalUnit) { + nw.OrganizationalUnit = des.OrganizationalUnit + } + if dcl.StringCanonicalize(des.Locality, nw.Locality) { + nw.Locality = des.Locality + } + if dcl.StringCanonicalize(des.Province, nw.Province) { + nw.Province = des.Province + } + if dcl.StringCanonicalize(des.StreetAddress, nw.StreetAddress) { + nw.StreetAddress = des.StreetAddress + } + if dcl.StringCanonicalize(des.PostalCode, nw.PostalCode) { + nw.PostalCode = des.PostalCode + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectSet(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubject) []CertificateCertificateDescriptionSubjectDescriptionSubject { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionSubjectDescriptionSubject + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionSubjectDescriptionSubjectNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubject(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectSlice(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubject) []CertificateCertificateDescriptionSubjectDescriptionSubject { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionSubjectDescriptionSubject + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubject(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(des, initial *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + + if dcl.StringArrayCanonicalize(des.DnsNames, initial.DnsNames) { + cDes.DnsNames = initial.DnsNames + } else { + cDes.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, initial.Uris) { + cDes.Uris = initial.Uris + } else { + cDes.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, initial.EmailAddresses) { + cDes.EmailAddresses = initial.EmailAddresses + } else { + cDes.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, initial.IPAddresses) { + cDes.IPAddresses = initial.IPAddresses + } else { + cDes.IPAddresses = des.IPAddresses + } + cDes.CustomSans = canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(des.CustomSans, initial.CustomSans, opts...) + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSlice(des, initial []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c *Client, des, nw *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionSubjectDescriptionSubjectAltName while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DnsNames, nw.DnsNames) { + nw.DnsNames = des.DnsNames + } + if dcl.StringArrayCanonicalize(des.Uris, nw.Uris) { + nw.Uris = des.Uris + } + if dcl.StringArrayCanonicalize(des.EmailAddresses, nw.EmailAddresses) { + nw.EmailAddresses = des.EmailAddresses + } + if dcl.StringArrayCanonicalize(des.IPAddresses, nw.IPAddresses) { + nw.IPAddresses = des.IPAddresses + } + nw.CustomSans = canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(c, des.CustomSans, nw.CustomSans) + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSet(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSlice(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(des, initial *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{} + + cDes.ObjectId = canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(des, initial []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c *Client, des, nw *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSet(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(des, initial *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(des, initial []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c *Client, des, nw *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSet(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(c *Client, des, nw []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509Description(des, initial *CertificateCertificateDescriptionX509Description, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509Description { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509Description{} + + cDes.KeyUsage = canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsage(des.KeyUsage, initial.KeyUsage, opts...) + cDes.CaOptions = canonicalizeCertificateCertificateDescriptionX509DescriptionCaOptions(des.CaOptions, initial.CaOptions, opts...) + cDes.PolicyIds = canonicalizeCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(des.PolicyIds, initial.PolicyIds, opts...) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, initial.AiaOcspServers) { + cDes.AiaOcspServers = initial.AiaOcspServers + } else { + cDes.AiaOcspServers = des.AiaOcspServers + } + cDes.AdditionalExtensions = canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionSlice(des, initial []CertificateCertificateDescriptionX509Description, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509Description { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509Description, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509Description(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509Description, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509Description(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509Description(c *Client, des, nw *CertificateCertificateDescriptionX509Description) *CertificateCertificateDescriptionX509Description { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509Description while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.KeyUsage = canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsage(c, des.KeyUsage, nw.KeyUsage) + nw.CaOptions = canonicalizeNewCertificateCertificateDescriptionX509DescriptionCaOptions(c, des.CaOptions, nw.CaOptions) + nw.PolicyIds = canonicalizeNewCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(c, des.PolicyIds, nw.PolicyIds) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, nw.AiaOcspServers) { + nw.AiaOcspServers = des.AiaOcspServers + } + nw.AdditionalExtensions = canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionSet(c *Client, des, nw []CertificateCertificateDescriptionX509Description) []CertificateCertificateDescriptionX509Description { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509Description + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509Description(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionSlice(c *Client, des, nw []CertificateCertificateDescriptionX509Description) []CertificateCertificateDescriptionX509Description { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509Description + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509Description(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsage(des, initial *CertificateCertificateDescriptionX509DescriptionKeyUsage, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionKeyUsage{} + + cDes.BaseKeyUsage = canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(des.BaseKeyUsage, initial.BaseKeyUsage, opts...) + cDes.ExtendedKeyUsage = canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(des.ExtendedKeyUsage, initial.ExtendedKeyUsage, opts...) + cDes.UnknownExtendedKeyUsages = canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(des.UnknownExtendedKeyUsages, initial.UnknownExtendedKeyUsages, opts...) + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageSlice(des, initial []CertificateCertificateDescriptionX509DescriptionKeyUsage, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsage(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionKeyUsage) *CertificateCertificateDescriptionX509DescriptionKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.BaseKeyUsage = canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, des.BaseKeyUsage, nw.BaseKeyUsage) + nw.ExtendedKeyUsage = canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, des.ExtendedKeyUsage, nw.ExtendedKeyUsage) + nw.UnknownExtendedKeyUsages = canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c, des.UnknownExtendedKeyUsages, nw.UnknownExtendedKeyUsages) + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsage) []CertificateCertificateDescriptionX509DescriptionKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsage) []CertificateCertificateDescriptionX509DescriptionKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(des, initial *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + + if dcl.BoolCanonicalize(des.DigitalSignature, initial.DigitalSignature) || dcl.IsZeroValue(des.DigitalSignature) { + cDes.DigitalSignature = initial.DigitalSignature + } else { + cDes.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, initial.ContentCommitment) || dcl.IsZeroValue(des.ContentCommitment) { + cDes.ContentCommitment = initial.ContentCommitment + } else { + cDes.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, initial.KeyEncipherment) || dcl.IsZeroValue(des.KeyEncipherment) { + cDes.KeyEncipherment = initial.KeyEncipherment + } else { + cDes.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, initial.DataEncipherment) || dcl.IsZeroValue(des.DataEncipherment) { + cDes.DataEncipherment = initial.DataEncipherment + } else { + cDes.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, initial.KeyAgreement) || dcl.IsZeroValue(des.KeyAgreement) { + cDes.KeyAgreement = initial.KeyAgreement + } else { + cDes.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, initial.CertSign) || dcl.IsZeroValue(des.CertSign) { + cDes.CertSign = initial.CertSign + } else { + cDes.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, initial.CrlSign) || dcl.IsZeroValue(des.CrlSign) { + cDes.CrlSign = initial.CrlSign + } else { + cDes.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, initial.EncipherOnly) || dcl.IsZeroValue(des.EncipherOnly) { + cDes.EncipherOnly = initial.EncipherOnly + } else { + cDes.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, initial.DecipherOnly) || dcl.IsZeroValue(des.DecipherOnly) { + cDes.DecipherOnly = initial.DecipherOnly + } else { + cDes.DecipherOnly = des.DecipherOnly + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSlice(des, initial []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.DigitalSignature, nw.DigitalSignature) { + nw.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, nw.ContentCommitment) { + nw.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, nw.KeyEncipherment) { + nw.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, nw.DataEncipherment) { + nw.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, nw.KeyAgreement) { + nw.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, nw.CertSign) { + nw.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, nw.CrlSign) { + nw.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, nw.EncipherOnly) { + nw.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, nw.DecipherOnly) { + nw.DecipherOnly = des.DecipherOnly + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(des, initial *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + + if dcl.BoolCanonicalize(des.ServerAuth, initial.ServerAuth) || dcl.IsZeroValue(des.ServerAuth) { + cDes.ServerAuth = initial.ServerAuth + } else { + cDes.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, initial.ClientAuth) || dcl.IsZeroValue(des.ClientAuth) { + cDes.ClientAuth = initial.ClientAuth + } else { + cDes.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, initial.CodeSigning) || dcl.IsZeroValue(des.CodeSigning) { + cDes.CodeSigning = initial.CodeSigning + } else { + cDes.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, initial.EmailProtection) || dcl.IsZeroValue(des.EmailProtection) { + cDes.EmailProtection = initial.EmailProtection + } else { + cDes.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, initial.TimeStamping) || dcl.IsZeroValue(des.TimeStamping) { + cDes.TimeStamping = initial.TimeStamping + } else { + cDes.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, initial.OcspSigning) || dcl.IsZeroValue(des.OcspSigning) { + cDes.OcspSigning = initial.OcspSigning + } else { + cDes.OcspSigning = des.OcspSigning + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSlice(des, initial []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.ServerAuth, nw.ServerAuth) { + nw.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, nw.ClientAuth) { + nw.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, nw.CodeSigning) { + nw.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, nw.EmailProtection) { + nw.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, nw.TimeStamping) { + nw.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, nw.OcspSigning) { + nw.OcspSigning = des.OcspSigning + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(des, initial *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(des, initial []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionCaOptions(des, initial *CertificateCertificateDescriptionX509DescriptionCaOptions, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionCaOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if des.IsCa != nil || (initial != nil && initial.IsCa != nil) { + // Check if anything else is set. + if dcl.AnySet() { + des.IsCa = nil + if initial != nil { + initial.IsCa = nil + } + } + } + + if des.MaxIssuerPathLength != nil || (initial != nil && initial.MaxIssuerPathLength != nil) { + // Check if anything else is set. + if dcl.AnySet() { + des.MaxIssuerPathLength = nil + if initial != nil { + initial.MaxIssuerPathLength = nil + } + } + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionCaOptions{} + + if dcl.BoolCanonicalize(des.IsCa, initial.IsCa) || dcl.IsZeroValue(des.IsCa) { + cDes.IsCa = initial.IsCa + } else { + cDes.IsCa = des.IsCa + } + if dcl.IsZeroValue(des.MaxIssuerPathLength) || (dcl.IsEmptyValueIndirect(des.MaxIssuerPathLength) && dcl.IsEmptyValueIndirect(initial.MaxIssuerPathLength)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxIssuerPathLength = initial.MaxIssuerPathLength + } else { + cDes.MaxIssuerPathLength = des.MaxIssuerPathLength + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionCaOptionsSlice(des, initial []CertificateCertificateDescriptionX509DescriptionCaOptions, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionCaOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionCaOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionCaOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionCaOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionCaOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionCaOptions(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionCaOptions) *CertificateCertificateDescriptionX509DescriptionCaOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionCaOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.IsCa, nw.IsCa) { + nw.IsCa = des.IsCa + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionCaOptionsSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionCaOptions) []CertificateCertificateDescriptionX509DescriptionCaOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionCaOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionCaOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionCaOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionCaOptionsSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionCaOptions) []CertificateCertificateDescriptionX509DescriptionCaOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionCaOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionCaOptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionPolicyIds(des, initial *CertificateCertificateDescriptionX509DescriptionPolicyIds, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionPolicyIds { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionPolicyIds{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(des, initial []CertificateCertificateDescriptionX509DescriptionPolicyIds, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionPolicyIds { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionPolicyIds, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionPolicyIds(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionPolicyIds, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionPolicyIds(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionPolicyIds(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionPolicyIds) *CertificateCertificateDescriptionX509DescriptionPolicyIds { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionPolicyIds while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionPolicyIdsSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionPolicyIds) []CertificateCertificateDescriptionX509DescriptionPolicyIds { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionPolicyIds + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionPolicyIdsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionPolicyIds(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionPolicyIds) []CertificateCertificateDescriptionX509DescriptionPolicyIds { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionPolicyIds + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionPolicyIds(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(des, initial *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{} + + cDes.ObjectId = canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(des, initial []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(des, initial *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSlice(des, initial []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c *Client, des, nw *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSet(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSlice(c *Client, des, nw []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionPublicKey(des, initial *CertificateCertificateDescriptionPublicKey, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionPublicKey { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionPublicKey{} + + if dcl.StringCanonicalize(des.Key, initial.Key) || dcl.IsZeroValue(des.Key) { + cDes.Key = initial.Key + } else { + cDes.Key = des.Key + } + if dcl.IsZeroValue(des.Format) || (dcl.IsEmptyValueIndirect(des.Format) && dcl.IsEmptyValueIndirect(initial.Format)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Format = initial.Format + } else { + cDes.Format = des.Format + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionPublicKeySlice(des, initial []CertificateCertificateDescriptionPublicKey, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionPublicKey { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionPublicKey, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionPublicKey(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionPublicKey, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionPublicKey(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionPublicKey(c *Client, des, nw *CertificateCertificateDescriptionPublicKey) *CertificateCertificateDescriptionPublicKey { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionPublicKey while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Key, nw.Key) { + nw.Key = des.Key + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionPublicKeySet(c *Client, des, nw []CertificateCertificateDescriptionPublicKey) []CertificateCertificateDescriptionPublicKey { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionPublicKey + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionPublicKeyNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionPublicKey(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionPublicKeySlice(c *Client, des, nw []CertificateCertificateDescriptionPublicKey) []CertificateCertificateDescriptionPublicKey { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionPublicKey + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionPublicKey(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionSubjectKeyId(des, initial *CertificateCertificateDescriptionSubjectKeyId, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionSubjectKeyId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionSubjectKeyId{} + + if dcl.StringCanonicalize(des.KeyId, initial.KeyId) || dcl.IsZeroValue(des.KeyId) { + cDes.KeyId = initial.KeyId + } else { + cDes.KeyId = des.KeyId + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionSubjectKeyIdSlice(des, initial []CertificateCertificateDescriptionSubjectKeyId, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionSubjectKeyId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionSubjectKeyId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectKeyId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionSubjectKeyId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionSubjectKeyId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectKeyId(c *Client, des, nw *CertificateCertificateDescriptionSubjectKeyId) *CertificateCertificateDescriptionSubjectKeyId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionSubjectKeyId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.KeyId, nw.KeyId) { + nw.KeyId = des.KeyId + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectKeyIdSet(c *Client, des, nw []CertificateCertificateDescriptionSubjectKeyId) []CertificateCertificateDescriptionSubjectKeyId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionSubjectKeyId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionSubjectKeyIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectKeyId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionSubjectKeyIdSlice(c *Client, des, nw []CertificateCertificateDescriptionSubjectKeyId) []CertificateCertificateDescriptionSubjectKeyId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionSubjectKeyId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionSubjectKeyId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionAuthorityKeyId(des, initial *CertificateCertificateDescriptionAuthorityKeyId, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionAuthorityKeyId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionAuthorityKeyId{} + + if dcl.StringCanonicalize(des.KeyId, initial.KeyId) || dcl.IsZeroValue(des.KeyId) { + cDes.KeyId = initial.KeyId + } else { + cDes.KeyId = des.KeyId + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionAuthorityKeyIdSlice(des, initial []CertificateCertificateDescriptionAuthorityKeyId, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionAuthorityKeyId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionAuthorityKeyId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionAuthorityKeyId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionAuthorityKeyId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionAuthorityKeyId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionAuthorityKeyId(c *Client, des, nw *CertificateCertificateDescriptionAuthorityKeyId) *CertificateCertificateDescriptionAuthorityKeyId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionAuthorityKeyId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.KeyId, nw.KeyId) { + nw.KeyId = des.KeyId + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionAuthorityKeyIdSet(c *Client, des, nw []CertificateCertificateDescriptionAuthorityKeyId) []CertificateCertificateDescriptionAuthorityKeyId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionAuthorityKeyId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionAuthorityKeyIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionAuthorityKeyId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionAuthorityKeyIdSlice(c *Client, des, nw []CertificateCertificateDescriptionAuthorityKeyId) []CertificateCertificateDescriptionAuthorityKeyId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionAuthorityKeyId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionAuthorityKeyId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateCertificateDescriptionCertFingerprint(des, initial *CertificateCertificateDescriptionCertFingerprint, opts ...dcl.ApplyOption) *CertificateCertificateDescriptionCertFingerprint { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateCertificateDescriptionCertFingerprint{} + + if dcl.StringCanonicalize(des.Sha256Hash, initial.Sha256Hash) || dcl.IsZeroValue(des.Sha256Hash) { + cDes.Sha256Hash = initial.Sha256Hash + } else { + cDes.Sha256Hash = des.Sha256Hash + } + + return cDes +} + +func canonicalizeCertificateCertificateDescriptionCertFingerprintSlice(des, initial []CertificateCertificateDescriptionCertFingerprint, opts ...dcl.ApplyOption) []CertificateCertificateDescriptionCertFingerprint { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateCertificateDescriptionCertFingerprint, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateCertificateDescriptionCertFingerprint(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateCertificateDescriptionCertFingerprint, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateCertificateDescriptionCertFingerprint(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateCertificateDescriptionCertFingerprint(c *Client, des, nw *CertificateCertificateDescriptionCertFingerprint) *CertificateCertificateDescriptionCertFingerprint { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateCertificateDescriptionCertFingerprint while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Sha256Hash, nw.Sha256Hash) { + nw.Sha256Hash = des.Sha256Hash + } + + return nw +} + +func canonicalizeNewCertificateCertificateDescriptionCertFingerprintSet(c *Client, des, nw []CertificateCertificateDescriptionCertFingerprint) []CertificateCertificateDescriptionCertFingerprint { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateCertificateDescriptionCertFingerprint + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateCertificateDescriptionCertFingerprintNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateCertificateDescriptionCertFingerprint(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateCertificateDescriptionCertFingerprintSlice(c *Client, des, nw []CertificateCertificateDescriptionCertFingerprint) []CertificateCertificateDescriptionCertFingerprint { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateCertificateDescriptionCertFingerprint + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateCertificateDescriptionCertFingerprint(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffCertificate(c *Client, desired, actual *Certificate, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PemCsr, actual.PemCsr, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PemCsr")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Config, actual.Config, dcl.DiffInfo{ObjectFunction: compareCertificateConfigNewStyle, EmptyObject: EmptyCertificateConfig, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Config")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.IssuerCertificateAuthority, actual.IssuerCertificateAuthority, dcl.DiffInfo{OutputOnly: true, Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IssuerCertificateAuthority")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Lifetime, actual.Lifetime, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Lifetime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertificateTemplate, actual.CertificateTemplate, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertificateTemplate")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectMode, actual.SubjectMode, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectMode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.RevocationDetails, actual.RevocationDetails, dcl.DiffInfo{OutputOnly: true, ObjectFunction: compareCertificateRevocationDetailsNewStyle, EmptyObject: EmptyCertificateRevocationDetails, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("RevocationDetails")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PemCertificate, actual.PemCertificate, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PemCertificate")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertificateDescription, actual.CertificateDescription, dcl.DiffInfo{OutputOnly: true, ObjectFunction: compareCertificateCertificateDescriptionNewStyle, EmptyObject: EmptyCertificateCertificateDescription, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertificateDescription")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PemCertificateChain, actual.PemCertificateChain, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PemCertificateChain")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateUpdateCertificateOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaPool, actual.CaPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaPool")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertificateAuthority, actual.CertificateAuthority, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertificateAuthority")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareCertificateConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfig) + if !ok { + desiredNotPointer, ok := d.(CertificateConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfig or *CertificateConfig", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfig) + if !ok { + actualNotPointer, ok := a.(CertificateConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfig", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.SubjectConfig, actual.SubjectConfig, dcl.DiffInfo{ObjectFunction: compareCertificateConfigSubjectConfigNewStyle, EmptyObject: EmptyCertificateConfigSubjectConfig, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectConfig")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.X509Config, actual.X509Config, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigNewStyle, EmptyObject: EmptyCertificateConfigX509Config, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("X509Config")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PublicKey, actual.PublicKey, dcl.DiffInfo{ObjectFunction: compareCertificateConfigPublicKeyNewStyle, EmptyObject: EmptyCertificateConfigPublicKey, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PublicKey")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigSubjectConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigSubjectConfig) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigSubjectConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigSubjectConfig or *CertificateConfigSubjectConfig", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigSubjectConfig) + if !ok { + actualNotPointer, ok := a.(CertificateConfigSubjectConfig) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigSubjectConfig", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Subject, actual.Subject, dcl.DiffInfo{ObjectFunction: compareCertificateConfigSubjectConfigSubjectNewStyle, EmptyObject: EmptyCertificateConfigSubjectConfigSubject, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Subject")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectAltName, actual.SubjectAltName, dcl.DiffInfo{ObjectFunction: compareCertificateConfigSubjectConfigSubjectAltNameNewStyle, EmptyObject: EmptyCertificateConfigSubjectConfigSubjectAltName, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectAltName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigSubjectConfigSubjectNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigSubjectConfigSubject) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigSubjectConfigSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigSubjectConfigSubject or *CertificateConfigSubjectConfigSubject", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigSubjectConfigSubject) + if !ok { + actualNotPointer, ok := a.(CertificateConfigSubjectConfigSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigSubjectConfigSubject", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CommonName, actual.CommonName, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CommonName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CountryCode, actual.CountryCode, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CountryCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Organization, actual.Organization, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Organization")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OrganizationalUnit, actual.OrganizationalUnit, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("OrganizationalUnit")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Locality, actual.Locality, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Locality")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Province, actual.Province, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Province")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.StreetAddress, actual.StreetAddress, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("StreetAddress")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PostalCode, actual.PostalCode, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PostalCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigSubjectConfigSubjectAltNameNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigSubjectConfigSubjectAltName) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigSubjectConfigSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigSubjectConfigSubjectAltName or *CertificateConfigSubjectConfigSubjectAltName", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigSubjectConfigSubjectAltName) + if !ok { + actualNotPointer, ok := a.(CertificateConfigSubjectConfigSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigSubjectConfigSubjectAltName", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DnsNames, actual.DnsNames, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DnsNames")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Uris, actual.Uris, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uris")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailAddresses, actual.EmailAddresses, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EmailAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.IPAddresses, actual.IPAddresses, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IpAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509Config) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509Config) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509Config or *CertificateConfigX509Config", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509Config) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509Config) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509Config", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyUsage, actual.KeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigKeyUsageNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaOptions, actual.CaOptions, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigCaOptionsNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigCaOptions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PolicyIds, actual.PolicyIds, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigPolicyIdsNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigPolicyIds, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PolicyIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaOcspServers, actual.AiaOcspServers, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AiaOcspServers")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigAdditionalExtensionsNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigAdditionalExtensions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsage or *CertificateConfigX509ConfigKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.BaseKeyUsage, actual.BaseKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigKeyUsageBaseKeyUsageNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigKeyUsageBaseKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("BaseKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExtendedKeyUsage, actual.ExtendedKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigKeyUsageExtendedKeyUsageNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigKeyUsageExtendedKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ExtendedKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UnknownExtendedKeyUsages, actual.UnknownExtendedKeyUsages, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UnknownExtendedKeyUsages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigKeyUsageBaseKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsageBaseKeyUsage or *CertificateConfigX509ConfigKeyUsageBaseKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsageBaseKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DigitalSignature, actual.DigitalSignature, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DigitalSignature")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ContentCommitment, actual.ContentCommitment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ContentCommitment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyEncipherment, actual.KeyEncipherment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DataEncipherment, actual.DataEncipherment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DataEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyAgreement, actual.KeyAgreement, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyAgreement")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertSign, actual.CertSign, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlSign, actual.CrlSign, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CrlSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EncipherOnly, actual.EncipherOnly, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EncipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DecipherOnly, actual.DecipherOnly, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DecipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigKeyUsageExtendedKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsageExtendedKeyUsage or *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsageExtendedKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ServerAuth, actual.ServerAuth, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ServerAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ClientAuth, actual.ClientAuth, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ClientAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CodeSigning, actual.CodeSigning, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CodeSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailProtection, actual.EmailProtection, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EmailProtection")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.TimeStamping, actual.TimeStamping, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TimeStamping")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OcspSigning, actual.OcspSigning, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("OcspSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages or *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigCaOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigCaOptions) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigCaOptions or *CertificateConfigX509ConfigCaOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigCaOptions) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigCaOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.IsCa, actual.IsCa, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IsCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.NonCa, actual.NonCa, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("NonCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxIssuerPathLength, actual.MaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("MaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ZeroMaxIssuerPathLength, actual.ZeroMaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ZeroMaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigPolicyIdsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigPolicyIds) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigPolicyIds or *CertificateConfigX509ConfigPolicyIds", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigPolicyIds) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigPolicyIds", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigAdditionalExtensions or *CertificateConfigX509ConfigAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateConfigX509ConfigAdditionalExtensionsObjectIdNewStyle, EmptyObject: EmptyCertificateConfigX509ConfigAdditionalExtensionsObjectId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigX509ConfigAdditionalExtensionsObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigAdditionalExtensionsObjectId or *CertificateConfigX509ConfigAdditionalExtensionsObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateConfigX509ConfigAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigX509ConfigAdditionalExtensionsObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateConfigPublicKeyNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateConfigPublicKey) + if !ok { + desiredNotPointer, ok := d.(CertificateConfigPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigPublicKey or *CertificateConfigPublicKey", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateConfigPublicKey) + if !ok { + actualNotPointer, ok := a.(CertificateConfigPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateConfigPublicKey", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Key, actual.Key, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Key")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Format, actual.Format, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Format")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateRevocationDetailsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateRevocationDetails) + if !ok { + desiredNotPointer, ok := d.(CertificateRevocationDetails) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateRevocationDetails or *CertificateRevocationDetails", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateRevocationDetails) + if !ok { + actualNotPointer, ok := a.(CertificateRevocationDetails) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateRevocationDetails", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.RevocationState, actual.RevocationState, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("RevocationState")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.RevocationTime, actual.RevocationTime, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("RevocationTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescription) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescription) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescription or *CertificateCertificateDescription", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescription) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescription) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescription", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.SubjectDescription, actual.SubjectDescription, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionSubjectDescriptionNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionSubjectDescription, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectDescription")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.X509Description, actual.X509Description, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509Description, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("X509Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PublicKey, actual.PublicKey, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionPublicKeyNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionPublicKey, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PublicKey")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectKeyId, actual.SubjectKeyId, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionSubjectKeyIdNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionSubjectKeyId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectKeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AuthorityKeyId, actual.AuthorityKeyId, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionAuthorityKeyIdNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionAuthorityKeyId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AuthorityKeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlDistributionPoints, actual.CrlDistributionPoints, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CrlDistributionPoints")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaIssuingCertificateUrls, actual.AiaIssuingCertificateUrls, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AiaIssuingCertificateUrls")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertFingerprint, actual.CertFingerprint, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionCertFingerprintNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionCertFingerprint, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertFingerprint")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionSubjectDescriptionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionSubjectDescription) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionSubjectDescription) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescription or *CertificateCertificateDescriptionSubjectDescription", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionSubjectDescription) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionSubjectDescription) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescription", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Subject, actual.Subject, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionSubjectDescriptionSubjectNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionSubjectDescriptionSubject, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Subject")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.SubjectAltName, actual.SubjectAltName, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltName, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("SubjectAltName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.HexSerialNumber, actual.HexSerialNumber, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("HexSerialNumber")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Lifetime, actual.Lifetime, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Lifetime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.NotBeforeTime, actual.NotBeforeTime, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("NotBeforeTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.NotAfterTime, actual.NotAfterTime, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("NotAfterTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionSubjectDescriptionSubjectNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionSubjectDescriptionSubject) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionSubjectDescriptionSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubject or *CertificateCertificateDescriptionSubjectDescriptionSubject", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionSubjectDescriptionSubject) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionSubjectDescriptionSubject) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubject", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CommonName, actual.CommonName, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CommonName")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CountryCode, actual.CountryCode, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CountryCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Organization, actual.Organization, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Organization")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OrganizationalUnit, actual.OrganizationalUnit, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("OrganizationalUnit")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Locality, actual.Locality, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Locality")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Province, actual.Province, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Province")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.StreetAddress, actual.StreetAddress, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("StreetAddress")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PostalCode, actual.PostalCode, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PostalCode")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubjectAltName or *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubjectAltName", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DnsNames, actual.DnsNames, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DnsNames")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Uris, actual.Uris, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uris")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailAddresses, actual.EmailAddresses, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EmailAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.IPAddresses, actual.IPAddresses, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IpAddresses")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CustomSans, actual.CustomSans, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CustomSans")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans or *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId or *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509Description) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509Description) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509Description or *CertificateCertificateDescriptionX509Description", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509Description) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509Description) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509Description", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyUsage, actual.KeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionKeyUsageNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaOptions, actual.CaOptions, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionCaOptionsNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionCaOptions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CaOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PolicyIds, actual.PolicyIds, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionPolicyIdsNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionPolicyIds, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("PolicyIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaOcspServers, actual.AiaOcspServers, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AiaOcspServers")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensions, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsage or *CertificateCertificateDescriptionX509DescriptionKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.BaseKeyUsage, actual.BaseKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("BaseKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExtendedKeyUsage, actual.ExtendedKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ExtendedKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UnknownExtendedKeyUsages, actual.UnknownExtendedKeyUsages, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UnknownExtendedKeyUsages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage or *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DigitalSignature, actual.DigitalSignature, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DigitalSignature")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ContentCommitment, actual.ContentCommitment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ContentCommitment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyEncipherment, actual.KeyEncipherment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DataEncipherment, actual.DataEncipherment, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DataEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyAgreement, actual.KeyAgreement, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyAgreement")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertSign, actual.CertSign, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CertSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlSign, actual.CrlSign, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CrlSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EncipherOnly, actual.EncipherOnly, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EncipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DecipherOnly, actual.DecipherOnly, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("DecipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage or *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ServerAuth, actual.ServerAuth, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ServerAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ClientAuth, actual.ClientAuth, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ClientAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CodeSigning, actual.CodeSigning, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CodeSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailProtection, actual.EmailProtection, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("EmailProtection")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.TimeStamping, actual.TimeStamping, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TimeStamping")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OcspSigning, actual.OcspSigning, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("OcspSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages or *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionCaOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionCaOptions) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionCaOptions or *CertificateCertificateDescriptionX509DescriptionCaOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionCaOptions) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionCaOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.IsCa, actual.IsCa, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("IsCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxIssuerPathLength, actual.MaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("MaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionPolicyIdsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionPolicyIds) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionPolicyIds or *CertificateCertificateDescriptionX509DescriptionPolicyIds", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionPolicyIds) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionPolicyIds", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionAdditionalExtensions or *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdNewStyle, EmptyObject: EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId or *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionPublicKeyNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionPublicKey) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionPublicKey or *CertificateCertificateDescriptionPublicKey", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionPublicKey) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionPublicKey) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionPublicKey", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Key, actual.Key, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Key")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Format, actual.Format, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Format")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionSubjectKeyIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionSubjectKeyId) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionSubjectKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectKeyId or *CertificateCertificateDescriptionSubjectKeyId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionSubjectKeyId) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionSubjectKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionSubjectKeyId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyId, actual.KeyId, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionAuthorityKeyIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionAuthorityKeyId) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionAuthorityKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionAuthorityKeyId or *CertificateCertificateDescriptionAuthorityKeyId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionAuthorityKeyId) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionAuthorityKeyId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionAuthorityKeyId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyId, actual.KeyId, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("KeyId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateCertificateDescriptionCertFingerprintNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateCertificateDescriptionCertFingerprint) + if !ok { + desiredNotPointer, ok := d.(CertificateCertificateDescriptionCertFingerprint) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionCertFingerprint or *CertificateCertificateDescriptionCertFingerprint", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateCertificateDescriptionCertFingerprint) + if !ok { + actualNotPointer, ok := a.(CertificateCertificateDescriptionCertFingerprint) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateCertificateDescriptionCertFingerprint", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Sha256Hash, actual.Sha256Hash, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Sha256Hash")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Certificate) urlNormalized() *Certificate { + normalized := dcl.Copy(*r).(Certificate) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.PemCsr = dcl.SelfLinkToName(r.PemCsr) + normalized.IssuerCertificateAuthority = dcl.SelfLinkToName(r.IssuerCertificateAuthority) + normalized.Lifetime = dcl.SelfLinkToName(r.Lifetime) + normalized.CertificateTemplate = dcl.SelfLinkToName(r.CertificateTemplate) + normalized.PemCertificate = dcl.SelfLinkToName(r.PemCertificate) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + normalized.CaPool = dcl.SelfLinkToName(r.CaPool) + normalized.CertificateAuthority = dcl.SelfLinkToName(r.CertificateAuthority) + return &normalized +} + +func (r *Certificate) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateCertificate" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificates/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Certificate resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Certificate) marshal(c *Client) ([]byte, error) { + m, err := expandCertificate(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Certificate: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalCertificate decodes JSON responses into the Certificate resource schema. +func unmarshalCertificate(b []byte, c *Client, res *Certificate) (*Certificate, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapCertificate(m, c, res) +} + +func unmarshalMapCertificate(m map[string]interface{}, c *Client, res *Certificate) (*Certificate, error) { + + flattened := flattenCertificate(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandCertificate expands Certificate into a JSON request object. +func expandCertificate(c *Client, f *Certificate) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.DeriveField("projects/%s/locations/%s/caPools/%s/certificates/%s", f.Name, dcl.SelfLinkToName(f.Project), dcl.SelfLinkToName(f.Location), dcl.SelfLinkToName(f.CaPool), dcl.SelfLinkToName(f.Name)); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.PemCsr; dcl.ValueShouldBeSent(v) { + m["pemCsr"] = v + } + if v, err := expandCertificateConfig(c, f.Config, res); err != nil { + return nil, fmt.Errorf("error expanding Config into config: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["config"] = v + } + if v := f.Lifetime; dcl.ValueShouldBeSent(v) { + m["lifetime"] = v + } + if v, err := dcl.DeriveField("projects/%s/locations/%s/certificateTemplates/%s", f.CertificateTemplate, dcl.SelfLinkToName(f.Project), dcl.SelfLinkToName(f.Location), dcl.SelfLinkToName(f.CertificateTemplate)); err != nil { + return nil, fmt.Errorf("error expanding CertificateTemplate into certificateTemplate: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["certificateTemplate"] = v + } + if v := f.SubjectMode; dcl.ValueShouldBeSent(v) { + m["subjectMode"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding CaPool into caPool: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caPool"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding CertificateAuthority into certificateAuthority: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["certificateAuthority"] = v + } + + return m, nil +} + +// flattenCertificate flattens Certificate from a JSON request object into the +// Certificate type. +func flattenCertificate(c *Client, i interface{}, res *Certificate) *Certificate { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Certificate{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.PemCsr = dcl.FlattenString(m["pemCsr"]) + resultRes.Config = flattenCertificateConfig(c, m["config"], res) + resultRes.IssuerCertificateAuthority = dcl.FlattenString(m["issuerCertificateAuthority"]) + resultRes.Lifetime = dcl.FlattenString(m["lifetime"]) + resultRes.CertificateTemplate = dcl.FlattenString(m["certificateTemplate"]) + resultRes.SubjectMode = flattenCertificateSubjectModeEnum(m["subjectMode"]) + resultRes.RevocationDetails = flattenCertificateRevocationDetails(c, m["revocationDetails"], res) + resultRes.PemCertificate = dcl.FlattenString(m["pemCertificate"]) + resultRes.CertificateDescription = flattenCertificateCertificateDescription(c, m["certificateDescription"], res) + resultRes.PemCertificateChain = dcl.FlattenStringSlice(m["pemCertificateChain"]) + resultRes.CreateTime = dcl.FlattenString(m["createTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + resultRes.CaPool = dcl.FlattenString(m["caPool"]) + resultRes.CertificateAuthority = dcl.FlattenString(m["certificateAuthority"]) + + return resultRes +} + +// expandCertificateConfigMap expands the contents of CertificateConfig into a JSON +// request object. +func expandCertificateConfigMap(c *Client, f map[string]CertificateConfig, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfig(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigSlice expands the contents of CertificateConfig into a JSON +// request object. +func expandCertificateConfigSlice(c *Client, f []CertificateConfig, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfig(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigMap flattens the contents of CertificateConfig from a JSON +// response object. +func flattenCertificateConfigMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfig { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfig{} + } + + if len(a) == 0 { + return map[string]CertificateConfig{} + } + + items := make(map[string]CertificateConfig) + for k, item := range a { + items[k] = *flattenCertificateConfig(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigSlice flattens the contents of CertificateConfig from a JSON +// response object. +func flattenCertificateConfigSlice(c *Client, i interface{}, res *Certificate) []CertificateConfig { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfig{} + } + + if len(a) == 0 { + return []CertificateConfig{} + } + + items := make([]CertificateConfig, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfig(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfig expands an instance of CertificateConfig into a JSON +// request object. +func expandCertificateConfig(c *Client, f *CertificateConfig, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateConfigSubjectConfig(c, f.SubjectConfig, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectConfig into subjectConfig: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectConfig"] = v + } + if v, err := expandCertificateConfigX509Config(c, f.X509Config, res); err != nil { + return nil, fmt.Errorf("error expanding X509Config into x509Config: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["x509Config"] = v + } + if v, err := expandCertificateConfigPublicKey(c, f.PublicKey, res); err != nil { + return nil, fmt.Errorf("error expanding PublicKey into publicKey: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["publicKey"] = v + } + + return m, nil +} + +// flattenCertificateConfig flattens an instance of CertificateConfig from a JSON +// response object. +func flattenCertificateConfig(c *Client, i interface{}, res *Certificate) *CertificateConfig { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfig{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfig + } + r.SubjectConfig = flattenCertificateConfigSubjectConfig(c, m["subjectConfig"], res) + r.X509Config = flattenCertificateConfigX509Config(c, m["x509Config"], res) + r.PublicKey = flattenCertificateConfigPublicKey(c, m["publicKey"], res) + + return r +} + +// expandCertificateConfigSubjectConfigMap expands the contents of CertificateConfigSubjectConfig into a JSON +// request object. +func expandCertificateConfigSubjectConfigMap(c *Client, f map[string]CertificateConfigSubjectConfig, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigSubjectConfig(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigSubjectConfigSlice expands the contents of CertificateConfigSubjectConfig into a JSON +// request object. +func expandCertificateConfigSubjectConfigSlice(c *Client, f []CertificateConfigSubjectConfig, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigSubjectConfig(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigSubjectConfigMap flattens the contents of CertificateConfigSubjectConfig from a JSON +// response object. +func flattenCertificateConfigSubjectConfigMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigSubjectConfig { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigSubjectConfig{} + } + + if len(a) == 0 { + return map[string]CertificateConfigSubjectConfig{} + } + + items := make(map[string]CertificateConfigSubjectConfig) + for k, item := range a { + items[k] = *flattenCertificateConfigSubjectConfig(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigSubjectConfigSlice flattens the contents of CertificateConfigSubjectConfig from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigSubjectConfig { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigSubjectConfig{} + } + + if len(a) == 0 { + return []CertificateConfigSubjectConfig{} + } + + items := make([]CertificateConfigSubjectConfig, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigSubjectConfig(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigSubjectConfig expands an instance of CertificateConfigSubjectConfig into a JSON +// request object. +func expandCertificateConfigSubjectConfig(c *Client, f *CertificateConfigSubjectConfig, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateConfigSubjectConfigSubject(c, f.Subject, res); err != nil { + return nil, fmt.Errorf("error expanding Subject into subject: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subject"] = v + } + if v, err := expandCertificateConfigSubjectConfigSubjectAltName(c, f.SubjectAltName, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectAltName into subjectAltName: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectAltName"] = v + } + + return m, nil +} + +// flattenCertificateConfigSubjectConfig flattens an instance of CertificateConfigSubjectConfig from a JSON +// response object. +func flattenCertificateConfigSubjectConfig(c *Client, i interface{}, res *Certificate) *CertificateConfigSubjectConfig { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigSubjectConfig{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigSubjectConfig + } + r.Subject = flattenCertificateConfigSubjectConfigSubject(c, m["subject"], res) + r.SubjectAltName = flattenCertificateConfigSubjectConfigSubjectAltName(c, m["subjectAltName"], res) + + return r +} + +// expandCertificateConfigSubjectConfigSubjectMap expands the contents of CertificateConfigSubjectConfigSubject into a JSON +// request object. +func expandCertificateConfigSubjectConfigSubjectMap(c *Client, f map[string]CertificateConfigSubjectConfigSubject, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigSubjectConfigSubject(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigSubjectConfigSubjectSlice expands the contents of CertificateConfigSubjectConfigSubject into a JSON +// request object. +func expandCertificateConfigSubjectConfigSubjectSlice(c *Client, f []CertificateConfigSubjectConfigSubject, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigSubjectConfigSubject(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigSubjectConfigSubjectMap flattens the contents of CertificateConfigSubjectConfigSubject from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSubjectMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigSubjectConfigSubject { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigSubjectConfigSubject{} + } + + if len(a) == 0 { + return map[string]CertificateConfigSubjectConfigSubject{} + } + + items := make(map[string]CertificateConfigSubjectConfigSubject) + for k, item := range a { + items[k] = *flattenCertificateConfigSubjectConfigSubject(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigSubjectConfigSubjectSlice flattens the contents of CertificateConfigSubjectConfigSubject from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSubjectSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigSubjectConfigSubject { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigSubjectConfigSubject{} + } + + if len(a) == 0 { + return []CertificateConfigSubjectConfigSubject{} + } + + items := make([]CertificateConfigSubjectConfigSubject, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigSubjectConfigSubject(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigSubjectConfigSubject expands an instance of CertificateConfigSubjectConfigSubject into a JSON +// request object. +func expandCertificateConfigSubjectConfigSubject(c *Client, f *CertificateConfigSubjectConfigSubject, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CommonName; !dcl.IsEmptyValueIndirect(v) { + m["commonName"] = v + } + if v := f.CountryCode; !dcl.IsEmptyValueIndirect(v) { + m["countryCode"] = v + } + if v := f.Organization; !dcl.IsEmptyValueIndirect(v) { + m["organization"] = v + } + if v := f.OrganizationalUnit; !dcl.IsEmptyValueIndirect(v) { + m["organizationalUnit"] = v + } + if v := f.Locality; !dcl.IsEmptyValueIndirect(v) { + m["locality"] = v + } + if v := f.Province; !dcl.IsEmptyValueIndirect(v) { + m["province"] = v + } + if v := f.StreetAddress; !dcl.IsEmptyValueIndirect(v) { + m["streetAddress"] = v + } + if v := f.PostalCode; !dcl.IsEmptyValueIndirect(v) { + m["postalCode"] = v + } + + return m, nil +} + +// flattenCertificateConfigSubjectConfigSubject flattens an instance of CertificateConfigSubjectConfigSubject from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSubject(c *Client, i interface{}, res *Certificate) *CertificateConfigSubjectConfigSubject { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigSubjectConfigSubject{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigSubjectConfigSubject + } + r.CommonName = dcl.FlattenString(m["commonName"]) + r.CountryCode = dcl.FlattenString(m["countryCode"]) + r.Organization = dcl.FlattenString(m["organization"]) + r.OrganizationalUnit = dcl.FlattenString(m["organizationalUnit"]) + r.Locality = dcl.FlattenString(m["locality"]) + r.Province = dcl.FlattenString(m["province"]) + r.StreetAddress = dcl.FlattenString(m["streetAddress"]) + r.PostalCode = dcl.FlattenString(m["postalCode"]) + + return r +} + +// expandCertificateConfigSubjectConfigSubjectAltNameMap expands the contents of CertificateConfigSubjectConfigSubjectAltName into a JSON +// request object. +func expandCertificateConfigSubjectConfigSubjectAltNameMap(c *Client, f map[string]CertificateConfigSubjectConfigSubjectAltName, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigSubjectConfigSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigSubjectConfigSubjectAltNameSlice expands the contents of CertificateConfigSubjectConfigSubjectAltName into a JSON +// request object. +func expandCertificateConfigSubjectConfigSubjectAltNameSlice(c *Client, f []CertificateConfigSubjectConfigSubjectAltName, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigSubjectConfigSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigSubjectConfigSubjectAltNameMap flattens the contents of CertificateConfigSubjectConfigSubjectAltName from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSubjectAltNameMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigSubjectConfigSubjectAltName { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigSubjectConfigSubjectAltName{} + } + + if len(a) == 0 { + return map[string]CertificateConfigSubjectConfigSubjectAltName{} + } + + items := make(map[string]CertificateConfigSubjectConfigSubjectAltName) + for k, item := range a { + items[k] = *flattenCertificateConfigSubjectConfigSubjectAltName(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigSubjectConfigSubjectAltNameSlice flattens the contents of CertificateConfigSubjectConfigSubjectAltName from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSubjectAltNameSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigSubjectConfigSubjectAltName { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigSubjectConfigSubjectAltName{} + } + + if len(a) == 0 { + return []CertificateConfigSubjectConfigSubjectAltName{} + } + + items := make([]CertificateConfigSubjectConfigSubjectAltName, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigSubjectConfigSubjectAltName(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigSubjectConfigSubjectAltName expands an instance of CertificateConfigSubjectConfigSubjectAltName into a JSON +// request object. +func expandCertificateConfigSubjectConfigSubjectAltName(c *Client, f *CertificateConfigSubjectConfigSubjectAltName, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DnsNames; v != nil { + m["dnsNames"] = v + } + if v := f.Uris; v != nil { + m["uris"] = v + } + if v := f.EmailAddresses; v != nil { + m["emailAddresses"] = v + } + if v := f.IPAddresses; v != nil { + m["ipAddresses"] = v + } + + return m, nil +} + +// flattenCertificateConfigSubjectConfigSubjectAltName flattens an instance of CertificateConfigSubjectConfigSubjectAltName from a JSON +// response object. +func flattenCertificateConfigSubjectConfigSubjectAltName(c *Client, i interface{}, res *Certificate) *CertificateConfigSubjectConfigSubjectAltName { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigSubjectConfigSubjectAltName{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigSubjectConfigSubjectAltName + } + r.DnsNames = dcl.FlattenStringSlice(m["dnsNames"]) + r.Uris = dcl.FlattenStringSlice(m["uris"]) + r.EmailAddresses = dcl.FlattenStringSlice(m["emailAddresses"]) + r.IPAddresses = dcl.FlattenStringSlice(m["ipAddresses"]) + + return r +} + +// expandCertificateConfigX509ConfigMap expands the contents of CertificateConfigX509Config into a JSON +// request object. +func expandCertificateConfigX509ConfigMap(c *Client, f map[string]CertificateConfigX509Config, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509Config(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigSlice expands the contents of CertificateConfigX509Config into a JSON +// request object. +func expandCertificateConfigX509ConfigSlice(c *Client, f []CertificateConfigX509Config, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509Config(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigMap flattens the contents of CertificateConfigX509Config from a JSON +// response object. +func flattenCertificateConfigX509ConfigMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509Config { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509Config{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509Config{} + } + + items := make(map[string]CertificateConfigX509Config) + for k, item := range a { + items[k] = *flattenCertificateConfigX509Config(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigSlice flattens the contents of CertificateConfigX509Config from a JSON +// response object. +func flattenCertificateConfigX509ConfigSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509Config { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509Config{} + } + + if len(a) == 0 { + return []CertificateConfigX509Config{} + } + + items := make([]CertificateConfigX509Config, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509Config(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509Config expands an instance of CertificateConfigX509Config into a JSON +// request object. +func expandCertificateConfigX509Config(c *Client, f *CertificateConfigX509Config, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateConfigX509ConfigKeyUsage(c, f.KeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding KeyUsage into keyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keyUsage"] = v + } + if v, err := expandCertificateConfigX509ConfigCAOptions(c, f.CaOptions, res); err != nil { + return nil, fmt.Errorf("error expanding CaOptions into caOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caOptions"] = v + } + if v, err := expandCertificateConfigX509ConfigPolicyIdsSlice(c, f.PolicyIds, res); err != nil { + return nil, fmt.Errorf("error expanding PolicyIds into policyIds: %w", err) + } else if v != nil { + m["policyIds"] = v + } + if v := f.AiaOcspServers; v != nil { + m["aiaOcspServers"] = v + } + if v, err := expandCertificateConfigX509ConfigAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509Config flattens an instance of CertificateConfigX509Config from a JSON +// response object. +func flattenCertificateConfigX509Config(c *Client, i interface{}, res *Certificate) *CertificateConfigX509Config { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509Config{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509Config + } + r.KeyUsage = flattenCertificateConfigX509ConfigKeyUsage(c, m["keyUsage"], res) + r.CaOptions = flattenCertificateConfigX509ConfigCAOptions(c, m["caOptions"], res) + r.PolicyIds = flattenCertificateConfigX509ConfigPolicyIdsSlice(c, m["policyIds"], res) + r.AiaOcspServers = dcl.FlattenStringSlice(m["aiaOcspServers"]) + r.AdditionalExtensions = flattenCertificateConfigX509ConfigAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCertificateConfigX509ConfigKeyUsageMap expands the contents of CertificateConfigX509ConfigKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageMap(c *Client, f map[string]CertificateConfigX509ConfigKeyUsage, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigKeyUsageSlice expands the contents of CertificateConfigX509ConfigKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageSlice(c *Client, f []CertificateConfigX509ConfigKeyUsage, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageMap flattens the contents of CertificateConfigX509ConfigKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigKeyUsage{} + } + + items := make(map[string]CertificateConfigX509ConfigKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigKeyUsageSlice flattens the contents of CertificateConfigX509ConfigKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigKeyUsage{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigKeyUsage{} + } + + items := make([]CertificateConfigX509ConfigKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigKeyUsage expands an instance of CertificateConfigX509ConfigKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsage(c *Client, f *CertificateConfigX509ConfigKeyUsage, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, f.BaseKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding BaseKeyUsage into baseKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baseKeyUsage"] = v + } + if v, err := expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, f.ExtendedKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding ExtendedKeyUsage into extendedKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["extendedKeyUsage"] = v + } + if v, err := expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c, f.UnknownExtendedKeyUsages, res); err != nil { + return nil, fmt.Errorf("error expanding UnknownExtendedKeyUsages into unknownExtendedKeyUsages: %w", err) + } else if v != nil { + m["unknownExtendedKeyUsages"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigKeyUsage flattens an instance of CertificateConfigX509ConfigKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsage(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigKeyUsage + } + r.BaseKeyUsage = flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, m["baseKeyUsage"], res) + r.ExtendedKeyUsage = flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, m["extendedKeyUsage"], res) + r.UnknownExtendedKeyUsages = flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c, m["unknownExtendedKeyUsages"], res) + + return r +} + +// expandCertificateConfigX509ConfigKeyUsageBaseKeyUsageMap expands the contents of CertificateConfigX509ConfigKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageBaseKeyUsageMap(c *Client, f map[string]CertificateConfigX509ConfigKeyUsageBaseKeyUsage, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigKeyUsageBaseKeyUsageSlice expands the contents of CertificateConfigX509ConfigKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageBaseKeyUsageSlice(c *Client, f []CertificateConfigX509ConfigKeyUsageBaseKeyUsage, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsageMap flattens the contents of CertificateConfigX509ConfigKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsageMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + items := make(map[string]CertificateConfigX509ConfigKeyUsageBaseKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsageSlice flattens the contents of CertificateConfigX509ConfigKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsageSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + } + + items := make([]CertificateConfigX509ConfigKeyUsageBaseKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigKeyUsageBaseKeyUsage expands an instance of CertificateConfigX509ConfigKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c *Client, f *CertificateConfigX509ConfigKeyUsageBaseKeyUsage, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DigitalSignature; !dcl.IsEmptyValueIndirect(v) { + m["digitalSignature"] = v + } + if v := f.ContentCommitment; !dcl.IsEmptyValueIndirect(v) { + m["contentCommitment"] = v + } + if v := f.KeyEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["keyEncipherment"] = v + } + if v := f.DataEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["dataEncipherment"] = v + } + if v := f.KeyAgreement; !dcl.IsEmptyValueIndirect(v) { + m["keyAgreement"] = v + } + if v := f.CertSign; !dcl.IsEmptyValueIndirect(v) { + m["certSign"] = v + } + if v := f.CrlSign; !dcl.IsEmptyValueIndirect(v) { + m["crlSign"] = v + } + if v := f.EncipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["encipherOnly"] = v + } + if v := f.DecipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["decipherOnly"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsage flattens an instance of CertificateConfigX509ConfigKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageBaseKeyUsage(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsageMap expands the contents of CertificateConfigX509ConfigKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsageMap(c *Client, f map[string]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSlice expands the contents of CertificateConfigX509ConfigKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSlice(c *Client, f []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsageMap flattens the contents of CertificateConfigX509ConfigKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsageMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + items := make(map[string]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSlice flattens the contents of CertificateConfigX509ConfigKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsageSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + + items := make([]CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsage expands an instance of CertificateConfigX509ConfigKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c *Client, f *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ServerAuth; !dcl.IsEmptyValueIndirect(v) { + m["serverAuth"] = v + } + if v := f.ClientAuth; !dcl.IsEmptyValueIndirect(v) { + m["clientAuth"] = v + } + if v := f.CodeSigning; !dcl.IsEmptyValueIndirect(v) { + m["codeSigning"] = v + } + if v := f.EmailProtection; !dcl.IsEmptyValueIndirect(v) { + m["emailProtection"] = v + } + if v := f.TimeStamping; !dcl.IsEmptyValueIndirect(v) { + m["timeStamping"] = v + } + if v := f.OcspSigning; !dcl.IsEmptyValueIndirect(v) { + m["ocspSigning"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsage flattens an instance of CertificateConfigX509ConfigKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageExtendedKeyUsage(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +// expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap expands the contents of CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap(c *Client, f map[string]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice expands the contents of CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, f []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap flattens the contents of CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + items := make(map[string]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice flattens the contents of CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + } + + items := make([]CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages expands an instance of CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c *Client, f *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages flattens an instance of CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateConfigX509ConfigCaOptionsMap expands the contents of CertificateConfigX509ConfigCaOptions into a JSON +// request object. +func expandCertificateConfigX509ConfigCaOptionsMap(c *Client, f map[string]CertificateConfigX509ConfigCaOptions, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigCaOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigCaOptionsSlice expands the contents of CertificateConfigX509ConfigCaOptions into a JSON +// request object. +func expandCertificateConfigX509ConfigCaOptionsSlice(c *Client, f []CertificateConfigX509ConfigCaOptions, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigCaOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigCaOptionsMap flattens the contents of CertificateConfigX509ConfigCaOptions from a JSON +// response object. +func flattenCertificateConfigX509ConfigCaOptionsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigCaOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigCaOptions{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigCaOptions{} + } + + items := make(map[string]CertificateConfigX509ConfigCaOptions) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigCaOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigCaOptionsSlice flattens the contents of CertificateConfigX509ConfigCaOptions from a JSON +// response object. +func flattenCertificateConfigX509ConfigCaOptionsSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigCaOptions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigCaOptions{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigCaOptions{} + } + + items := make([]CertificateConfigX509ConfigCaOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigCaOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigCaOptions expands an instance of CertificateConfigX509ConfigCaOptions into a JSON +// request object. +func expandCertificateConfigX509ConfigCaOptions(c *Client, f *CertificateConfigX509ConfigCaOptions, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + if v := f.NonCa; !dcl.IsEmptyValueIndirect(v) { + m["nonCa"] = v + } + if v := f.MaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["maxIssuerPathLength"] = v + } + if v := f.ZeroMaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["zeroMaxIssuerPathLength"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigCaOptions flattens an instance of CertificateConfigX509ConfigCaOptions from a JSON +// response object. +func flattenCertificateConfigX509ConfigCaOptions(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigCaOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigCaOptions + } + r.IsCa = dcl.FlattenBool(m["isCa"]) + r.NonCa = dcl.FlattenBool(m["nonCa"]) + r.MaxIssuerPathLength = dcl.FlattenInteger(m["maxIssuerPathLength"]) + r.ZeroMaxIssuerPathLength = dcl.FlattenBool(m["zeroMaxIssuerPathLength"]) + + return r +} + +// expandCertificateConfigX509ConfigPolicyIdsMap expands the contents of CertificateConfigX509ConfigPolicyIds into a JSON +// request object. +func expandCertificateConfigX509ConfigPolicyIdsMap(c *Client, f map[string]CertificateConfigX509ConfigPolicyIds, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigPolicyIdsSlice expands the contents of CertificateConfigX509ConfigPolicyIds into a JSON +// request object. +func expandCertificateConfigX509ConfigPolicyIdsSlice(c *Client, f []CertificateConfigX509ConfigPolicyIds, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigPolicyIdsMap flattens the contents of CertificateConfigX509ConfigPolicyIds from a JSON +// response object. +func flattenCertificateConfigX509ConfigPolicyIdsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigPolicyIds { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigPolicyIds{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigPolicyIds{} + } + + items := make(map[string]CertificateConfigX509ConfigPolicyIds) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigPolicyIds(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigPolicyIdsSlice flattens the contents of CertificateConfigX509ConfigPolicyIds from a JSON +// response object. +func flattenCertificateConfigX509ConfigPolicyIdsSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigPolicyIds { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigPolicyIds{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigPolicyIds{} + } + + items := make([]CertificateConfigX509ConfigPolicyIds, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigPolicyIds(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigPolicyIds expands an instance of CertificateConfigX509ConfigPolicyIds into a JSON +// request object. +func expandCertificateConfigX509ConfigPolicyIds(c *Client, f *CertificateConfigX509ConfigPolicyIds, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigPolicyIds flattens an instance of CertificateConfigX509ConfigPolicyIds from a JSON +// response object. +func flattenCertificateConfigX509ConfigPolicyIds(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigPolicyIds { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigPolicyIds{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigPolicyIds + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateConfigX509ConfigAdditionalExtensionsMap expands the contents of CertificateConfigX509ConfigAdditionalExtensions into a JSON +// request object. +func expandCertificateConfigX509ConfigAdditionalExtensionsMap(c *Client, f map[string]CertificateConfigX509ConfigAdditionalExtensions, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigAdditionalExtensionsSlice expands the contents of CertificateConfigX509ConfigAdditionalExtensions into a JSON +// request object. +func expandCertificateConfigX509ConfigAdditionalExtensionsSlice(c *Client, f []CertificateConfigX509ConfigAdditionalExtensions, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigAdditionalExtensionsMap flattens the contents of CertificateConfigX509ConfigAdditionalExtensions from a JSON +// response object. +func flattenCertificateConfigX509ConfigAdditionalExtensionsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigAdditionalExtensions{} + } + + items := make(map[string]CertificateConfigX509ConfigAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigAdditionalExtensionsSlice flattens the contents of CertificateConfigX509ConfigAdditionalExtensions from a JSON +// response object. +func flattenCertificateConfigX509ConfigAdditionalExtensionsSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigAdditionalExtensions{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigAdditionalExtensions{} + } + + items := make([]CertificateConfigX509ConfigAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigAdditionalExtensions expands an instance of CertificateConfigX509ConfigAdditionalExtensions into a JSON +// request object. +func expandCertificateConfigX509ConfigAdditionalExtensions(c *Client, f *CertificateConfigX509ConfigAdditionalExtensions, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigAdditionalExtensions flattens an instance of CertificateConfigX509ConfigAdditionalExtensions from a JSON +// response object. +func flattenCertificateConfigX509ConfigAdditionalExtensions(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigAdditionalExtensions + } + r.ObjectId = flattenCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateConfigX509ConfigAdditionalExtensionsObjectIdMap expands the contents of CertificateConfigX509ConfigAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateConfigX509ConfigAdditionalExtensionsObjectIdMap(c *Client, f map[string]CertificateConfigX509ConfigAdditionalExtensionsObjectId, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigX509ConfigAdditionalExtensionsObjectIdSlice expands the contents of CertificateConfigX509ConfigAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateConfigX509ConfigAdditionalExtensionsObjectIdSlice(c *Client, f []CertificateConfigX509ConfigAdditionalExtensionsObjectId, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigX509ConfigAdditionalExtensionsObjectIdMap flattens the contents of CertificateConfigX509ConfigAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateConfigX509ConfigAdditionalExtensionsObjectIdMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigX509ConfigAdditionalExtensionsObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + } + + items := make(map[string]CertificateConfigX509ConfigAdditionalExtensionsObjectId) + for k, item := range a { + items[k] = *flattenCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigX509ConfigAdditionalExtensionsObjectIdSlice flattens the contents of CertificateConfigX509ConfigAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateConfigX509ConfigAdditionalExtensionsObjectIdSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigX509ConfigAdditionalExtensionsObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return []CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + } + + items := make([]CertificateConfigX509ConfigAdditionalExtensionsObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigX509ConfigAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigX509ConfigAdditionalExtensionsObjectId expands an instance of CertificateConfigX509ConfigAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateConfigX509ConfigAdditionalExtensionsObjectId(c *Client, f *CertificateConfigX509ConfigAdditionalExtensionsObjectId, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateConfigX509ConfigAdditionalExtensionsObjectId flattens an instance of CertificateConfigX509ConfigAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateConfigX509ConfigAdditionalExtensionsObjectId(c *Client, i interface{}, res *Certificate) *CertificateConfigX509ConfigAdditionalExtensionsObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigX509ConfigAdditionalExtensionsObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateConfigPublicKeyMap expands the contents of CertificateConfigPublicKey into a JSON +// request object. +func expandCertificateConfigPublicKeyMap(c *Client, f map[string]CertificateConfigPublicKey, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateConfigPublicKey(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateConfigPublicKeySlice expands the contents of CertificateConfigPublicKey into a JSON +// request object. +func expandCertificateConfigPublicKeySlice(c *Client, f []CertificateConfigPublicKey, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateConfigPublicKey(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateConfigPublicKeyMap flattens the contents of CertificateConfigPublicKey from a JSON +// response object. +func flattenCertificateConfigPublicKeyMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigPublicKey { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigPublicKey{} + } + + if len(a) == 0 { + return map[string]CertificateConfigPublicKey{} + } + + items := make(map[string]CertificateConfigPublicKey) + for k, item := range a { + items[k] = *flattenCertificateConfigPublicKey(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateConfigPublicKeySlice flattens the contents of CertificateConfigPublicKey from a JSON +// response object. +func flattenCertificateConfigPublicKeySlice(c *Client, i interface{}, res *Certificate) []CertificateConfigPublicKey { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigPublicKey{} + } + + if len(a) == 0 { + return []CertificateConfigPublicKey{} + } + + items := make([]CertificateConfigPublicKey, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigPublicKey(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateConfigPublicKey expands an instance of CertificateConfigPublicKey into a JSON +// request object. +func expandCertificateConfigPublicKey(c *Client, f *CertificateConfigPublicKey, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Key; !dcl.IsEmptyValueIndirect(v) { + m["key"] = v + } + if v := f.Format; !dcl.IsEmptyValueIndirect(v) { + m["format"] = v + } + + return m, nil +} + +// flattenCertificateConfigPublicKey flattens an instance of CertificateConfigPublicKey from a JSON +// response object. +func flattenCertificateConfigPublicKey(c *Client, i interface{}, res *Certificate) *CertificateConfigPublicKey { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateConfigPublicKey{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateConfigPublicKey + } + r.Key = dcl.FlattenString(m["key"]) + r.Format = flattenCertificateConfigPublicKeyFormatEnum(m["format"]) + + return r +} + +// expandCertificateRevocationDetailsMap expands the contents of CertificateRevocationDetails into a JSON +// request object. +func expandCertificateRevocationDetailsMap(c *Client, f map[string]CertificateRevocationDetails, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateRevocationDetails(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateRevocationDetailsSlice expands the contents of CertificateRevocationDetails into a JSON +// request object. +func expandCertificateRevocationDetailsSlice(c *Client, f []CertificateRevocationDetails, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateRevocationDetails(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateRevocationDetailsMap flattens the contents of CertificateRevocationDetails from a JSON +// response object. +func flattenCertificateRevocationDetailsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateRevocationDetails { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateRevocationDetails{} + } + + if len(a) == 0 { + return map[string]CertificateRevocationDetails{} + } + + items := make(map[string]CertificateRevocationDetails) + for k, item := range a { + items[k] = *flattenCertificateRevocationDetails(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateRevocationDetailsSlice flattens the contents of CertificateRevocationDetails from a JSON +// response object. +func flattenCertificateRevocationDetailsSlice(c *Client, i interface{}, res *Certificate) []CertificateRevocationDetails { + a, ok := i.([]interface{}) + if !ok { + return []CertificateRevocationDetails{} + } + + if len(a) == 0 { + return []CertificateRevocationDetails{} + } + + items := make([]CertificateRevocationDetails, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateRevocationDetails(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateRevocationDetails expands an instance of CertificateRevocationDetails into a JSON +// request object. +func expandCertificateRevocationDetails(c *Client, f *CertificateRevocationDetails, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.RevocationState; !dcl.IsEmptyValueIndirect(v) { + m["revocationState"] = v + } + if v := f.RevocationTime; !dcl.IsEmptyValueIndirect(v) { + m["revocationTime"] = v + } + + return m, nil +} + +// flattenCertificateRevocationDetails flattens an instance of CertificateRevocationDetails from a JSON +// response object. +func flattenCertificateRevocationDetails(c *Client, i interface{}, res *Certificate) *CertificateRevocationDetails { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateRevocationDetails{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateRevocationDetails + } + r.RevocationState = flattenCertificateRevocationDetailsRevocationStateEnum(m["revocationState"]) + r.RevocationTime = dcl.FlattenString(m["revocationTime"]) + + return r +} + +// expandCertificateCertificateDescriptionMap expands the contents of CertificateCertificateDescription into a JSON +// request object. +func expandCertificateCertificateDescriptionMap(c *Client, f map[string]CertificateCertificateDescription, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescription(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSlice expands the contents of CertificateCertificateDescription into a JSON +// request object. +func expandCertificateCertificateDescriptionSlice(c *Client, f []CertificateCertificateDescription, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescription(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionMap flattens the contents of CertificateCertificateDescription from a JSON +// response object. +func flattenCertificateCertificateDescriptionMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescription { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescription{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescription{} + } + + items := make(map[string]CertificateCertificateDescription) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescription(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSlice flattens the contents of CertificateCertificateDescription from a JSON +// response object. +func flattenCertificateCertificateDescriptionSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescription { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescription{} + } + + if len(a) == 0 { + return []CertificateCertificateDescription{} + } + + items := make([]CertificateCertificateDescription, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescription(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescription expands an instance of CertificateCertificateDescription into a JSON +// request object. +func expandCertificateCertificateDescription(c *Client, f *CertificateCertificateDescription, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateCertificateDescriptionSubjectDescription(c, f.SubjectDescription, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectDescription into subjectDescription: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectDescription"] = v + } + if v, err := expandCertificateCertificateDescriptionX509Description(c, f.X509Description, res); err != nil { + return nil, fmt.Errorf("error expanding X509Description into x509Description: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["x509Description"] = v + } + if v, err := expandCertificateCertificateDescriptionPublicKey(c, f.PublicKey, res); err != nil { + return nil, fmt.Errorf("error expanding PublicKey into publicKey: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["publicKey"] = v + } + if v, err := expandCertificateCertificateDescriptionSubjectKeyId(c, f.SubjectKeyId, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectKeyId into subjectKeyId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectKeyId"] = v + } + if v, err := expandCertificateCertificateDescriptionAuthorityKeyId(c, f.AuthorityKeyId, res); err != nil { + return nil, fmt.Errorf("error expanding AuthorityKeyId into authorityKeyId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["authorityKeyId"] = v + } + if v := f.CrlDistributionPoints; v != nil { + m["crlDistributionPoints"] = v + } + if v := f.AiaIssuingCertificateUrls; v != nil { + m["aiaIssuingCertificateUrls"] = v + } + if v, err := expandCertificateCertificateDescriptionCertFingerprint(c, f.CertFingerprint, res); err != nil { + return nil, fmt.Errorf("error expanding CertFingerprint into certFingerprint: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["certFingerprint"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescription flattens an instance of CertificateCertificateDescription from a JSON +// response object. +func flattenCertificateCertificateDescription(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescription { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescription{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescription + } + r.SubjectDescription = flattenCertificateCertificateDescriptionSubjectDescription(c, m["subjectDescription"], res) + r.X509Description = flattenCertificateCertificateDescriptionX509Description(c, m["x509Description"], res) + r.PublicKey = flattenCertificateCertificateDescriptionPublicKey(c, m["publicKey"], res) + r.SubjectKeyId = flattenCertificateCertificateDescriptionSubjectKeyId(c, m["subjectKeyId"], res) + r.AuthorityKeyId = flattenCertificateCertificateDescriptionAuthorityKeyId(c, m["authorityKeyId"], res) + r.CrlDistributionPoints = dcl.FlattenStringSlice(m["crlDistributionPoints"]) + r.AiaIssuingCertificateUrls = dcl.FlattenStringSlice(m["aiaIssuingCertificateUrls"]) + r.CertFingerprint = flattenCertificateCertificateDescriptionCertFingerprint(c, m["certFingerprint"], res) + + return r +} + +// expandCertificateCertificateDescriptionSubjectDescriptionMap expands the contents of CertificateCertificateDescriptionSubjectDescription into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionMap(c *Client, f map[string]CertificateCertificateDescriptionSubjectDescription, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescription(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSlice expands the contents of CertificateCertificateDescriptionSubjectDescription into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSlice(c *Client, f []CertificateCertificateDescriptionSubjectDescription, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescription(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionMap flattens the contents of CertificateCertificateDescriptionSubjectDescription from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionSubjectDescription { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionSubjectDescription{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionSubjectDescription{} + } + + items := make(map[string]CertificateCertificateDescriptionSubjectDescription) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionSubjectDescription(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSlice flattens the contents of CertificateCertificateDescriptionSubjectDescription from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionSubjectDescription { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionSubjectDescription{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionSubjectDescription{} + } + + items := make([]CertificateCertificateDescriptionSubjectDescription, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionSubjectDescription(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionSubjectDescription expands an instance of CertificateCertificateDescriptionSubjectDescription into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescription(c *Client, f *CertificateCertificateDescriptionSubjectDescription, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateCertificateDescriptionSubjectDescriptionSubject(c, f.Subject, res); err != nil { + return nil, fmt.Errorf("error expanding Subject into subject: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subject"] = v + } + if v, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, f.SubjectAltName, res); err != nil { + return nil, fmt.Errorf("error expanding SubjectAltName into subjectAltName: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["subjectAltName"] = v + } + if v := f.HexSerialNumber; !dcl.IsEmptyValueIndirect(v) { + m["hexSerialNumber"] = v + } + if v := f.Lifetime; !dcl.IsEmptyValueIndirect(v) { + m["lifetime"] = v + } + if v := f.NotBeforeTime; !dcl.IsEmptyValueIndirect(v) { + m["notBeforeTime"] = v + } + if v := f.NotAfterTime; !dcl.IsEmptyValueIndirect(v) { + m["notAfterTime"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescription flattens an instance of CertificateCertificateDescriptionSubjectDescription from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescription(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionSubjectDescription { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionSubjectDescription{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionSubjectDescription + } + r.Subject = flattenCertificateCertificateDescriptionSubjectDescriptionSubject(c, m["subject"], res) + r.SubjectAltName = flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, m["subjectAltName"], res) + r.HexSerialNumber = dcl.FlattenString(m["hexSerialNumber"]) + r.Lifetime = dcl.FlattenString(m["lifetime"]) + r.NotBeforeTime = dcl.FlattenString(m["notBeforeTime"]) + r.NotAfterTime = dcl.FlattenString(m["notAfterTime"]) + + return r +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectMap expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubject into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectMap(c *Client, f map[string]CertificateCertificateDescriptionSubjectDescriptionSubject, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubject(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectSlice expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubject into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectSlice(c *Client, f []CertificateCertificateDescriptionSubjectDescriptionSubject, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubject(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectMap flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubject from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionSubjectDescriptionSubject { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubject{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubject{} + } + + items := make(map[string]CertificateCertificateDescriptionSubjectDescriptionSubject) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionSubjectDescriptionSubject(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectSlice flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubject from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionSubjectDescriptionSubject { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionSubjectDescriptionSubject{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionSubjectDescriptionSubject{} + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubject, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionSubjectDescriptionSubject(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubject expands an instance of CertificateCertificateDescriptionSubjectDescriptionSubject into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubject(c *Client, f *CertificateCertificateDescriptionSubjectDescriptionSubject, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.CommonName; !dcl.IsEmptyValueIndirect(v) { + m["commonName"] = v + } + if v := f.CountryCode; !dcl.IsEmptyValueIndirect(v) { + m["countryCode"] = v + } + if v := f.Organization; !dcl.IsEmptyValueIndirect(v) { + m["organization"] = v + } + if v := f.OrganizationalUnit; !dcl.IsEmptyValueIndirect(v) { + m["organizationalUnit"] = v + } + if v := f.Locality; !dcl.IsEmptyValueIndirect(v) { + m["locality"] = v + } + if v := f.Province; !dcl.IsEmptyValueIndirect(v) { + m["province"] = v + } + if v := f.StreetAddress; !dcl.IsEmptyValueIndirect(v) { + m["streetAddress"] = v + } + if v := f.PostalCode; !dcl.IsEmptyValueIndirect(v) { + m["postalCode"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubject flattens an instance of CertificateCertificateDescriptionSubjectDescriptionSubject from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubject(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionSubjectDescriptionSubject { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionSubjectDescriptionSubject{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionSubjectDescriptionSubject + } + r.CommonName = dcl.FlattenString(m["commonName"]) + r.CountryCode = dcl.FlattenString(m["countryCode"]) + r.Organization = dcl.FlattenString(m["organization"]) + r.OrganizationalUnit = dcl.FlattenString(m["organizationalUnit"]) + r.Locality = dcl.FlattenString(m["locality"]) + r.Province = dcl.FlattenString(m["province"]) + r.StreetAddress = dcl.FlattenString(m["streetAddress"]) + r.PostalCode = dcl.FlattenString(m["postalCode"]) + + return r +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameMap expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltName into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameMap(c *Client, f map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSlice expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltName into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSlice(c *Client, f []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameMap flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltName from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + } + + items := make(map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSlice flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltName from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltName expands an instance of CertificateCertificateDescriptionSubjectDescriptionSubjectAltName into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c *Client, f *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DnsNames; v != nil { + m["dnsNames"] = v + } + if v := f.Uris; v != nil { + m["uris"] = v + } + if v := f.EmailAddresses; v != nil { + m["emailAddresses"] = v + } + if v := f.IPAddresses; v != nil { + m["ipAddresses"] = v + } + if v, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(c, f.CustomSans, res); err != nil { + return nil, fmt.Errorf("error expanding CustomSans into customSans: %w", err) + } else if v != nil { + m["customSans"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltName flattens an instance of CertificateCertificateDescriptionSubjectDescriptionSubjectAltName from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltName(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltName + } + r.DnsNames = dcl.FlattenStringSlice(m["dnsNames"]) + r.Uris = dcl.FlattenStringSlice(m["uris"]) + r.EmailAddresses = dcl.FlattenStringSlice(m["emailAddresses"]) + r.IPAddresses = dcl.FlattenStringSlice(m["ipAddresses"]) + r.CustomSans = flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(c, m["customSans"], res) + + return r +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansMap expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansMap(c *Client, f map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(c *Client, f []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansMap flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{} + } + + items := make(map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{} + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans expands an instance of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c *Client, f *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans flattens an instance of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans + } + r.ObjectId = flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdMap expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdMap(c *Client, f map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice expands the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(c *Client, f []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdMap flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + items := make(map[string]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice flattens the contents of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + + items := make([]CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId expands an instance of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c *Client, f *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId flattens an instance of CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionMap expands the contents of CertificateCertificateDescriptionX509Description into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionMap(c *Client, f map[string]CertificateCertificateDescriptionX509Description, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509Description(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionSlice expands the contents of CertificateCertificateDescriptionX509Description into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionSlice(c *Client, f []CertificateCertificateDescriptionX509Description, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509Description(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionMap flattens the contents of CertificateCertificateDescriptionX509Description from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509Description { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509Description{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509Description{} + } + + items := make(map[string]CertificateCertificateDescriptionX509Description) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509Description(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionSlice flattens the contents of CertificateCertificateDescriptionX509Description from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509Description { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509Description{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509Description{} + } + + items := make([]CertificateCertificateDescriptionX509Description, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509Description(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509Description expands an instance of CertificateCertificateDescriptionX509Description into a JSON +// request object. +func expandCertificateCertificateDescriptionX509Description(c *Client, f *CertificateCertificateDescriptionX509Description, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsage(c, f.KeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding KeyUsage into keyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keyUsage"] = v + } + if v, err := expandCertificateCertificateDescriptionX509DescriptionCaOptions(c, f.CaOptions, res); err != nil { + return nil, fmt.Errorf("error expanding CaOptions into caOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caOptions"] = v + } + if v, err := expandCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(c, f.PolicyIds, res); err != nil { + return nil, fmt.Errorf("error expanding PolicyIds into policyIds: %w", err) + } else if v != nil { + m["policyIds"] = v + } + if v := f.AiaOcspServers; v != nil { + m["aiaOcspServers"] = v + } + if v, err := expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509Description flattens an instance of CertificateCertificateDescriptionX509Description from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509Description(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509Description { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509Description{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509Description + } + r.KeyUsage = flattenCertificateCertificateDescriptionX509DescriptionKeyUsage(c, m["keyUsage"], res) + r.CaOptions = flattenCertificateCertificateDescriptionX509DescriptionCaOptions(c, m["caOptions"], res) + r.PolicyIds = flattenCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(c, m["policyIds"], res) + r.AiaOcspServers = dcl.FlattenStringSlice(m["aiaOcspServers"]) + r.AdditionalExtensions = flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageMap expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionKeyUsage, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageSlice expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionKeyUsage, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageMap flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsage{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionKeyUsage{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionKeyUsage{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsage expands an instance of CertificateCertificateDescriptionX509DescriptionKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsage(c *Client, f *CertificateCertificateDescriptionX509DescriptionKeyUsage, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, f.BaseKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding BaseKeyUsage into baseKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baseKeyUsage"] = v + } + if v, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, f.ExtendedKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding ExtendedKeyUsage into extendedKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["extendedKeyUsage"] = v + } + if v, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c, f.UnknownExtendedKeyUsages, res); err != nil { + return nil, fmt.Errorf("error expanding UnknownExtendedKeyUsages into unknownExtendedKeyUsages: %w", err) + } else if v != nil { + m["unknownExtendedKeyUsages"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsage flattens an instance of CertificateCertificateDescriptionX509DescriptionKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsage(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionKeyUsage + } + r.BaseKeyUsage = flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, m["baseKeyUsage"], res) + r.ExtendedKeyUsage = flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, m["extendedKeyUsage"], res) + r.UnknownExtendedKeyUsages = flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c, m["unknownExtendedKeyUsages"], res) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageMap expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSlice expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageMap flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage expands an instance of CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c *Client, f *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DigitalSignature; !dcl.IsEmptyValueIndirect(v) { + m["digitalSignature"] = v + } + if v := f.ContentCommitment; !dcl.IsEmptyValueIndirect(v) { + m["contentCommitment"] = v + } + if v := f.KeyEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["keyEncipherment"] = v + } + if v := f.DataEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["dataEncipherment"] = v + } + if v := f.KeyAgreement; !dcl.IsEmptyValueIndirect(v) { + m["keyAgreement"] = v + } + if v := f.CertSign; !dcl.IsEmptyValueIndirect(v) { + m["certSign"] = v + } + if v := f.CrlSign; !dcl.IsEmptyValueIndirect(v) { + m["crlSign"] = v + } + if v := f.EncipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["encipherOnly"] = v + } + if v := f.DecipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["decipherOnly"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage flattens an instance of CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageMap expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSlice expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageMap flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage expands an instance of CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c *Client, f *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ServerAuth; !dcl.IsEmptyValueIndirect(v) { + m["serverAuth"] = v + } + if v := f.ClientAuth; !dcl.IsEmptyValueIndirect(v) { + m["clientAuth"] = v + } + if v := f.CodeSigning; !dcl.IsEmptyValueIndirect(v) { + m["codeSigning"] = v + } + if v := f.EmailProtection; !dcl.IsEmptyValueIndirect(v) { + m["emailProtection"] = v + } + if v := f.TimeStamping; !dcl.IsEmptyValueIndirect(v) { + m["timeStamping"] = v + } + if v := f.OcspSigning; !dcl.IsEmptyValueIndirect(v) { + m["ocspSigning"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage flattens an instance of CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice expands the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages expands an instance of CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c *Client, f *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages flattens an instance of CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionCaOptionsMap expands the contents of CertificateCertificateDescriptionX509DescriptionCaOptions into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionCaOptionsMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionCaOptions, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionCaOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionCaOptionsSlice expands the contents of CertificateCertificateDescriptionX509DescriptionCaOptions into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionCaOptionsSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionCaOptions, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionCaOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionCaOptionsMap flattens the contents of CertificateCertificateDescriptionX509DescriptionCaOptions from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionCaOptionsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionCaOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionCaOptions{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionCaOptions{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionCaOptions) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionCaOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionCaOptionsSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionCaOptions from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionCaOptionsSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionCaOptions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionCaOptions{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionCaOptions{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionCaOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionCaOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionCaOptions expands an instance of CertificateCertificateDescriptionX509DescriptionCaOptions into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionCaOptions(c *Client, f *CertificateCertificateDescriptionX509DescriptionCaOptions, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + if v := f.MaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["maxIssuerPathLength"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionCaOptions flattens an instance of CertificateCertificateDescriptionX509DescriptionCaOptions from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionCaOptions(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionCaOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionCaOptions + } + r.IsCa = dcl.FlattenBool(m["isCa"]) + r.MaxIssuerPathLength = dcl.FlattenInteger(m["maxIssuerPathLength"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionPolicyIdsMap expands the contents of CertificateCertificateDescriptionX509DescriptionPolicyIds into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionPolicyIdsMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionPolicyIds, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice expands the contents of CertificateCertificateDescriptionX509DescriptionPolicyIds into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionPolicyIds, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionPolicyIdsMap flattens the contents of CertificateCertificateDescriptionX509DescriptionPolicyIds from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionPolicyIdsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionPolicyIds { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionPolicyIds{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionPolicyIds{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionPolicyIds) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionPolicyIds(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionPolicyIds from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionPolicyIdsSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionPolicyIds { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionPolicyIds{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionPolicyIds{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionPolicyIds, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionPolicyIds(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionPolicyIds expands an instance of CertificateCertificateDescriptionX509DescriptionPolicyIds into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionPolicyIds(c *Client, f *CertificateCertificateDescriptionX509DescriptionPolicyIds, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionPolicyIds flattens an instance of CertificateCertificateDescriptionX509DescriptionPolicyIds from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionPolicyIds(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionPolicyIds { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionPolicyIds{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionPolicyIds + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsMap expands the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensions into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice expands the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensions into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsMap flattens the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensions from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensions from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensions expands an instance of CertificateCertificateDescriptionX509DescriptionAdditionalExtensions into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c *Client, f *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensions flattens an instance of CertificateCertificateDescriptionX509DescriptionAdditionalExtensions from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensions(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensions + } + r.ObjectId = flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdMap expands the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdMap(c *Client, f map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSlice expands the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSlice(c *Client, f []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdMap flattens the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + } + + items := make(map[string]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSlice flattens the contents of CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + } + + items := make([]CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId expands an instance of CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c *Client, f *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId flattens an instance of CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateCertificateDescriptionPublicKeyMap expands the contents of CertificateCertificateDescriptionPublicKey into a JSON +// request object. +func expandCertificateCertificateDescriptionPublicKeyMap(c *Client, f map[string]CertificateCertificateDescriptionPublicKey, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionPublicKey(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionPublicKeySlice expands the contents of CertificateCertificateDescriptionPublicKey into a JSON +// request object. +func expandCertificateCertificateDescriptionPublicKeySlice(c *Client, f []CertificateCertificateDescriptionPublicKey, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionPublicKey(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionPublicKeyMap flattens the contents of CertificateCertificateDescriptionPublicKey from a JSON +// response object. +func flattenCertificateCertificateDescriptionPublicKeyMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionPublicKey { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionPublicKey{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionPublicKey{} + } + + items := make(map[string]CertificateCertificateDescriptionPublicKey) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionPublicKey(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionPublicKeySlice flattens the contents of CertificateCertificateDescriptionPublicKey from a JSON +// response object. +func flattenCertificateCertificateDescriptionPublicKeySlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionPublicKey { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionPublicKey{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionPublicKey{} + } + + items := make([]CertificateCertificateDescriptionPublicKey, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionPublicKey(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionPublicKey expands an instance of CertificateCertificateDescriptionPublicKey into a JSON +// request object. +func expandCertificateCertificateDescriptionPublicKey(c *Client, f *CertificateCertificateDescriptionPublicKey, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Key; !dcl.IsEmptyValueIndirect(v) { + m["key"] = v + } + if v := f.Format; !dcl.IsEmptyValueIndirect(v) { + m["format"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionPublicKey flattens an instance of CertificateCertificateDescriptionPublicKey from a JSON +// response object. +func flattenCertificateCertificateDescriptionPublicKey(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionPublicKey { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionPublicKey{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionPublicKey + } + r.Key = dcl.FlattenString(m["key"]) + r.Format = flattenCertificateCertificateDescriptionPublicKeyFormatEnum(m["format"]) + + return r +} + +// expandCertificateCertificateDescriptionSubjectKeyIdMap expands the contents of CertificateCertificateDescriptionSubjectKeyId into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectKeyIdMap(c *Client, f map[string]CertificateCertificateDescriptionSubjectKeyId, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectKeyId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionSubjectKeyIdSlice expands the contents of CertificateCertificateDescriptionSubjectKeyId into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectKeyIdSlice(c *Client, f []CertificateCertificateDescriptionSubjectKeyId, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionSubjectKeyId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionSubjectKeyIdMap flattens the contents of CertificateCertificateDescriptionSubjectKeyId from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectKeyIdMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionSubjectKeyId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionSubjectKeyId{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionSubjectKeyId{} + } + + items := make(map[string]CertificateCertificateDescriptionSubjectKeyId) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionSubjectKeyId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionSubjectKeyIdSlice flattens the contents of CertificateCertificateDescriptionSubjectKeyId from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectKeyIdSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionSubjectKeyId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionSubjectKeyId{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionSubjectKeyId{} + } + + items := make([]CertificateCertificateDescriptionSubjectKeyId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionSubjectKeyId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionSubjectKeyId expands an instance of CertificateCertificateDescriptionSubjectKeyId into a JSON +// request object. +func expandCertificateCertificateDescriptionSubjectKeyId(c *Client, f *CertificateCertificateDescriptionSubjectKeyId, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.KeyId; !dcl.IsEmptyValueIndirect(v) { + m["keyId"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionSubjectKeyId flattens an instance of CertificateCertificateDescriptionSubjectKeyId from a JSON +// response object. +func flattenCertificateCertificateDescriptionSubjectKeyId(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionSubjectKeyId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionSubjectKeyId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionSubjectKeyId + } + r.KeyId = dcl.FlattenString(m["keyId"]) + + return r +} + +// expandCertificateCertificateDescriptionAuthorityKeyIdMap expands the contents of CertificateCertificateDescriptionAuthorityKeyId into a JSON +// request object. +func expandCertificateCertificateDescriptionAuthorityKeyIdMap(c *Client, f map[string]CertificateCertificateDescriptionAuthorityKeyId, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionAuthorityKeyId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionAuthorityKeyIdSlice expands the contents of CertificateCertificateDescriptionAuthorityKeyId into a JSON +// request object. +func expandCertificateCertificateDescriptionAuthorityKeyIdSlice(c *Client, f []CertificateCertificateDescriptionAuthorityKeyId, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionAuthorityKeyId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionAuthorityKeyIdMap flattens the contents of CertificateCertificateDescriptionAuthorityKeyId from a JSON +// response object. +func flattenCertificateCertificateDescriptionAuthorityKeyIdMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionAuthorityKeyId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionAuthorityKeyId{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionAuthorityKeyId{} + } + + items := make(map[string]CertificateCertificateDescriptionAuthorityKeyId) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionAuthorityKeyId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionAuthorityKeyIdSlice flattens the contents of CertificateCertificateDescriptionAuthorityKeyId from a JSON +// response object. +func flattenCertificateCertificateDescriptionAuthorityKeyIdSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionAuthorityKeyId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionAuthorityKeyId{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionAuthorityKeyId{} + } + + items := make([]CertificateCertificateDescriptionAuthorityKeyId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionAuthorityKeyId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionAuthorityKeyId expands an instance of CertificateCertificateDescriptionAuthorityKeyId into a JSON +// request object. +func expandCertificateCertificateDescriptionAuthorityKeyId(c *Client, f *CertificateCertificateDescriptionAuthorityKeyId, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.KeyId; !dcl.IsEmptyValueIndirect(v) { + m["keyId"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionAuthorityKeyId flattens an instance of CertificateCertificateDescriptionAuthorityKeyId from a JSON +// response object. +func flattenCertificateCertificateDescriptionAuthorityKeyId(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionAuthorityKeyId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionAuthorityKeyId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionAuthorityKeyId + } + r.KeyId = dcl.FlattenString(m["keyId"]) + + return r +} + +// expandCertificateCertificateDescriptionCertFingerprintMap expands the contents of CertificateCertificateDescriptionCertFingerprint into a JSON +// request object. +func expandCertificateCertificateDescriptionCertFingerprintMap(c *Client, f map[string]CertificateCertificateDescriptionCertFingerprint, res *Certificate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateCertificateDescriptionCertFingerprint(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateCertificateDescriptionCertFingerprintSlice expands the contents of CertificateCertificateDescriptionCertFingerprint into a JSON +// request object. +func expandCertificateCertificateDescriptionCertFingerprintSlice(c *Client, f []CertificateCertificateDescriptionCertFingerprint, res *Certificate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateCertificateDescriptionCertFingerprint(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateCertificateDescriptionCertFingerprintMap flattens the contents of CertificateCertificateDescriptionCertFingerprint from a JSON +// response object. +func flattenCertificateCertificateDescriptionCertFingerprintMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionCertFingerprint { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionCertFingerprint{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionCertFingerprint{} + } + + items := make(map[string]CertificateCertificateDescriptionCertFingerprint) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionCertFingerprint(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateCertificateDescriptionCertFingerprintSlice flattens the contents of CertificateCertificateDescriptionCertFingerprint from a JSON +// response object. +func flattenCertificateCertificateDescriptionCertFingerprintSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionCertFingerprint { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionCertFingerprint{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionCertFingerprint{} + } + + items := make([]CertificateCertificateDescriptionCertFingerprint, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionCertFingerprint(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateCertificateDescriptionCertFingerprint expands an instance of CertificateCertificateDescriptionCertFingerprint into a JSON +// request object. +func expandCertificateCertificateDescriptionCertFingerprint(c *Client, f *CertificateCertificateDescriptionCertFingerprint, res *Certificate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Sha256Hash; !dcl.IsEmptyValueIndirect(v) { + m["sha256Hash"] = v + } + + return m, nil +} + +// flattenCertificateCertificateDescriptionCertFingerprint flattens an instance of CertificateCertificateDescriptionCertFingerprint from a JSON +// response object. +func flattenCertificateCertificateDescriptionCertFingerprint(c *Client, i interface{}, res *Certificate) *CertificateCertificateDescriptionCertFingerprint { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateCertificateDescriptionCertFingerprint{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateCertificateDescriptionCertFingerprint + } + r.Sha256Hash = dcl.FlattenString(m["sha256Hash"]) + + return r +} + +// flattenCertificateConfigPublicKeyFormatEnumMap flattens the contents of CertificateConfigPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateConfigPublicKeyFormatEnumMap(c *Client, i interface{}, res *Certificate) map[string]CertificateConfigPublicKeyFormatEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateConfigPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return map[string]CertificateConfigPublicKeyFormatEnum{} + } + + items := make(map[string]CertificateConfigPublicKeyFormatEnum) + for k, item := range a { + items[k] = *flattenCertificateConfigPublicKeyFormatEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateConfigPublicKeyFormatEnumSlice flattens the contents of CertificateConfigPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateConfigPublicKeyFormatEnumSlice(c *Client, i interface{}, res *Certificate) []CertificateConfigPublicKeyFormatEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateConfigPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return []CertificateConfigPublicKeyFormatEnum{} + } + + items := make([]CertificateConfigPublicKeyFormatEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateConfigPublicKeyFormatEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateConfigPublicKeyFormatEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateConfigPublicKeyFormatEnum with the same value as that string. +func flattenCertificateConfigPublicKeyFormatEnum(i interface{}) *CertificateConfigPublicKeyFormatEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateConfigPublicKeyFormatEnumRef(s) +} + +// flattenCertificateSubjectModeEnumMap flattens the contents of CertificateSubjectModeEnum from a JSON +// response object. +func flattenCertificateSubjectModeEnumMap(c *Client, i interface{}, res *Certificate) map[string]CertificateSubjectModeEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateSubjectModeEnum{} + } + + if len(a) == 0 { + return map[string]CertificateSubjectModeEnum{} + } + + items := make(map[string]CertificateSubjectModeEnum) + for k, item := range a { + items[k] = *flattenCertificateSubjectModeEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateSubjectModeEnumSlice flattens the contents of CertificateSubjectModeEnum from a JSON +// response object. +func flattenCertificateSubjectModeEnumSlice(c *Client, i interface{}, res *Certificate) []CertificateSubjectModeEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateSubjectModeEnum{} + } + + if len(a) == 0 { + return []CertificateSubjectModeEnum{} + } + + items := make([]CertificateSubjectModeEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateSubjectModeEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateSubjectModeEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateSubjectModeEnum with the same value as that string. +func flattenCertificateSubjectModeEnum(i interface{}) *CertificateSubjectModeEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateSubjectModeEnumRef(s) +} + +// flattenCertificateRevocationDetailsRevocationStateEnumMap flattens the contents of CertificateRevocationDetailsRevocationStateEnum from a JSON +// response object. +func flattenCertificateRevocationDetailsRevocationStateEnumMap(c *Client, i interface{}, res *Certificate) map[string]CertificateRevocationDetailsRevocationStateEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateRevocationDetailsRevocationStateEnum{} + } + + if len(a) == 0 { + return map[string]CertificateRevocationDetailsRevocationStateEnum{} + } + + items := make(map[string]CertificateRevocationDetailsRevocationStateEnum) + for k, item := range a { + items[k] = *flattenCertificateRevocationDetailsRevocationStateEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateRevocationDetailsRevocationStateEnumSlice flattens the contents of CertificateRevocationDetailsRevocationStateEnum from a JSON +// response object. +func flattenCertificateRevocationDetailsRevocationStateEnumSlice(c *Client, i interface{}, res *Certificate) []CertificateRevocationDetailsRevocationStateEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateRevocationDetailsRevocationStateEnum{} + } + + if len(a) == 0 { + return []CertificateRevocationDetailsRevocationStateEnum{} + } + + items := make([]CertificateRevocationDetailsRevocationStateEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateRevocationDetailsRevocationStateEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateRevocationDetailsRevocationStateEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateRevocationDetailsRevocationStateEnum with the same value as that string. +func flattenCertificateRevocationDetailsRevocationStateEnum(i interface{}) *CertificateRevocationDetailsRevocationStateEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateRevocationDetailsRevocationStateEnumRef(s) +} + +// flattenCertificateCertificateDescriptionPublicKeyFormatEnumMap flattens the contents of CertificateCertificateDescriptionPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateCertificateDescriptionPublicKeyFormatEnumMap(c *Client, i interface{}, res *Certificate) map[string]CertificateCertificateDescriptionPublicKeyFormatEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateCertificateDescriptionPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return map[string]CertificateCertificateDescriptionPublicKeyFormatEnum{} + } + + items := make(map[string]CertificateCertificateDescriptionPublicKeyFormatEnum) + for k, item := range a { + items[k] = *flattenCertificateCertificateDescriptionPublicKeyFormatEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateCertificateDescriptionPublicKeyFormatEnumSlice flattens the contents of CertificateCertificateDescriptionPublicKeyFormatEnum from a JSON +// response object. +func flattenCertificateCertificateDescriptionPublicKeyFormatEnumSlice(c *Client, i interface{}, res *Certificate) []CertificateCertificateDescriptionPublicKeyFormatEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateCertificateDescriptionPublicKeyFormatEnum{} + } + + if len(a) == 0 { + return []CertificateCertificateDescriptionPublicKeyFormatEnum{} + } + + items := make([]CertificateCertificateDescriptionPublicKeyFormatEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateCertificateDescriptionPublicKeyFormatEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateCertificateDescriptionPublicKeyFormatEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateCertificateDescriptionPublicKeyFormatEnum with the same value as that string. +func flattenCertificateCertificateDescriptionPublicKeyFormatEnum(i interface{}) *CertificateCertificateDescriptionPublicKeyFormatEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateCertificateDescriptionPublicKeyFormatEnumRef(s) +} + +// This function returns a matcher that checks whether a serialized resource matches this resource +// in its parameters (as defined by the fields in a Get, which definitionally define resource +// identity). This is useful in extracting the element from a List call. +func (r *Certificate) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalCertificate(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if nr.Project == nil && ncr.Project == nil { + c.Config.Logger.Info("Both Project fields null - considering equal.") + } else if nr.Project == nil || ncr.Project == nil { + c.Config.Logger.Info("Only one Project field is null - considering unequal.") + return false + } else if *nr.Project != *ncr.Project { + return false + } + if nr.Location == nil && ncr.Location == nil { + c.Config.Logger.Info("Both Location fields null - considering equal.") + } else if nr.Location == nil || ncr.Location == nil { + c.Config.Logger.Info("Only one Location field is null - considering unequal.") + return false + } else if *nr.Location != *ncr.Location { + return false + } + if nr.CaPool == nil && ncr.CaPool == nil { + c.Config.Logger.Info("Both CaPool fields null - considering equal.") + } else if nr.CaPool == nil || ncr.CaPool == nil { + c.Config.Logger.Info("Only one CaPool field is null - considering unequal.") + return false + } else if *nr.CaPool != *ncr.CaPool { + return false + } + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + return true + } +} + +type certificateDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp certificateApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToCertificateDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]certificateDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []certificateDiff + // For each operation name, create a certificateDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := certificateDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToCertificateApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToCertificateApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (certificateApiOperation, error) { + switch opName { + + case "updateCertificateUpdateCertificateOperation": + return &updateCertificateUpdateCertificateOperation{FieldDiffs: fieldDiffs}, nil + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractCertificateFields(r *Certificate) error { + vConfig := r.Config + if vConfig == nil { + // note: explicitly not the empty object. + vConfig = &CertificateConfig{} + } + if err := extractCertificateConfigFields(r, vConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vConfig) { + r.Config = vConfig + } + vRevocationDetails := r.RevocationDetails + if vRevocationDetails == nil { + // note: explicitly not the empty object. + vRevocationDetails = &CertificateRevocationDetails{} + } + if err := extractCertificateRevocationDetailsFields(r, vRevocationDetails); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRevocationDetails) { + r.RevocationDetails = vRevocationDetails + } + vCertificateDescription := r.CertificateDescription + if vCertificateDescription == nil { + // note: explicitly not the empty object. + vCertificateDescription = &CertificateCertificateDescription{} + } + if err := extractCertificateCertificateDescriptionFields(r, vCertificateDescription); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCertificateDescription) { + r.CertificateDescription = vCertificateDescription + } + return nil +} +func extractCertificateConfigFields(r *Certificate, o *CertificateConfig) error { + vSubjectConfig := o.SubjectConfig + if vSubjectConfig == nil { + // note: explicitly not the empty object. + vSubjectConfig = &CertificateConfigSubjectConfig{} + } + if err := extractCertificateConfigSubjectConfigFields(r, vSubjectConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectConfig) { + o.SubjectConfig = vSubjectConfig + } + vX509Config := o.X509Config + if vX509Config == nil { + // note: explicitly not the empty object. + vX509Config = &CertificateConfigX509Config{} + } + if err := extractCertificateConfigX509ConfigFields(r, vX509Config); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Config) { + o.X509Config = vX509Config + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateConfigPublicKey{} + } + if err := extractCertificateConfigPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + return nil +} +func extractCertificateConfigSubjectConfigFields(r *Certificate, o *CertificateConfigSubjectConfig) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateConfigSubjectConfigSubject{} + } + if err := extractCertificateConfigSubjectConfigSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateConfigSubjectConfigSubjectAltName{} + } + if err := extractCertificateConfigSubjectConfigSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func extractCertificateConfigSubjectConfigSubjectFields(r *Certificate, o *CertificateConfigSubjectConfigSubject) error { + return nil +} +func extractCertificateConfigSubjectConfigSubjectAltNameFields(r *Certificate, o *CertificateConfigSubjectConfigSubjectAltName) error { + return nil +} +func extractCertificateConfigX509ConfigFields(r *Certificate, o *CertificateConfigX509Config) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateConfigX509ConfigKeyUsage{} + } + if err := extractCertificateConfigX509ConfigKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateConfigX509ConfigCaOptions{} + } + if err := extractCertificateConfigX509ConfigCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func extractCertificateConfigX509ConfigKeyUsageFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + } + if err := extractCertificateConfigX509ConfigKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateConfigX509ConfigKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func extractCertificateConfigX509ConfigKeyUsageBaseKeyUsageFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) error { + return nil +} +func extractCertificateConfigX509ConfigKeyUsageExtendedKeyUsageFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) error { + return nil +} +func extractCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func extractCertificateConfigX509ConfigCaOptionsFields(r *Certificate, o *CertificateConfigX509ConfigCaOptions) error { + return nil +} +func extractCertificateConfigX509ConfigPolicyIdsFields(r *Certificate, o *CertificateConfigX509ConfigPolicyIds) error { + return nil +} +func extractCertificateConfigX509ConfigAdditionalExtensionsFields(r *Certificate, o *CertificateConfigX509ConfigAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + } + if err := extractCertificateConfigX509ConfigAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateConfigX509ConfigAdditionalExtensionsObjectIdFields(r *Certificate, o *CertificateConfigX509ConfigAdditionalExtensionsObjectId) error { + return nil +} +func extractCertificateConfigPublicKeyFields(r *Certificate, o *CertificateConfigPublicKey) error { + return nil +} +func extractCertificateRevocationDetailsFields(r *Certificate, o *CertificateRevocationDetails) error { + return nil +} +func extractCertificateCertificateDescriptionFields(r *Certificate, o *CertificateCertificateDescription) error { + vSubjectDescription := o.SubjectDescription + if vSubjectDescription == nil { + // note: explicitly not the empty object. + vSubjectDescription = &CertificateCertificateDescriptionSubjectDescription{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionFields(r, vSubjectDescription); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectDescription) { + o.SubjectDescription = vSubjectDescription + } + vX509Description := o.X509Description + if vX509Description == nil { + // note: explicitly not the empty object. + vX509Description = &CertificateCertificateDescriptionX509Description{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionFields(r, vX509Description); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Description) { + o.X509Description = vX509Description + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateCertificateDescriptionPublicKey{} + } + if err := extractCertificateCertificateDescriptionPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + vSubjectKeyId := o.SubjectKeyId + if vSubjectKeyId == nil { + // note: explicitly not the empty object. + vSubjectKeyId = &CertificateCertificateDescriptionSubjectKeyId{} + } + if err := extractCertificateCertificateDescriptionSubjectKeyIdFields(r, vSubjectKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectKeyId) { + o.SubjectKeyId = vSubjectKeyId + } + vAuthorityKeyId := o.AuthorityKeyId + if vAuthorityKeyId == nil { + // note: explicitly not the empty object. + vAuthorityKeyId = &CertificateCertificateDescriptionAuthorityKeyId{} + } + if err := extractCertificateCertificateDescriptionAuthorityKeyIdFields(r, vAuthorityKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAuthorityKeyId) { + o.AuthorityKeyId = vAuthorityKeyId + } + vCertFingerprint := o.CertFingerprint + if vCertFingerprint == nil { + // note: explicitly not the empty object. + vCertFingerprint = &CertificateCertificateDescriptionCertFingerprint{} + } + if err := extractCertificateCertificateDescriptionCertFingerprintFields(r, vCertFingerprint); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCertFingerprint) { + o.CertFingerprint = vCertFingerprint + } + return nil +} +func extractCertificateCertificateDescriptionSubjectDescriptionFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescription) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateCertificateDescriptionSubjectDescriptionSubject{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func extractCertificateCertificateDescriptionSubjectDescriptionSubjectFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubject) error { + return nil +} +func extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) error { + return nil +} +func extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) error { + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionFields(r *Certificate, o *CertificateCertificateDescriptionX509Description) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsage{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateCertificateDescriptionX509DescriptionCaOptions{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionKeyUsageFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) error { + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) error { + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionCaOptionsFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionCaOptions) error { + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionPolicyIdsFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionPolicyIds) error { + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) error { + return nil +} +func extractCertificateCertificateDescriptionPublicKeyFields(r *Certificate, o *CertificateCertificateDescriptionPublicKey) error { + return nil +} +func extractCertificateCertificateDescriptionSubjectKeyIdFields(r *Certificate, o *CertificateCertificateDescriptionSubjectKeyId) error { + return nil +} +func extractCertificateCertificateDescriptionAuthorityKeyIdFields(r *Certificate, o *CertificateCertificateDescriptionAuthorityKeyId) error { + return nil +} +func extractCertificateCertificateDescriptionCertFingerprintFields(r *Certificate, o *CertificateCertificateDescriptionCertFingerprint) error { + return nil +} + +func postReadExtractCertificateFields(r *Certificate) error { + vConfig := r.Config + if vConfig == nil { + // note: explicitly not the empty object. + vConfig = &CertificateConfig{} + } + if err := postReadExtractCertificateConfigFields(r, vConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vConfig) { + r.Config = vConfig + } + vRevocationDetails := r.RevocationDetails + if vRevocationDetails == nil { + // note: explicitly not the empty object. + vRevocationDetails = &CertificateRevocationDetails{} + } + if err := postReadExtractCertificateRevocationDetailsFields(r, vRevocationDetails); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRevocationDetails) { + r.RevocationDetails = vRevocationDetails + } + vCertificateDescription := r.CertificateDescription + if vCertificateDescription == nil { + // note: explicitly not the empty object. + vCertificateDescription = &CertificateCertificateDescription{} + } + if err := postReadExtractCertificateCertificateDescriptionFields(r, vCertificateDescription); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCertificateDescription) { + r.CertificateDescription = vCertificateDescription + } + return nil +} +func postReadExtractCertificateConfigFields(r *Certificate, o *CertificateConfig) error { + vSubjectConfig := o.SubjectConfig + if vSubjectConfig == nil { + // note: explicitly not the empty object. + vSubjectConfig = &CertificateConfigSubjectConfig{} + } + if err := extractCertificateConfigSubjectConfigFields(r, vSubjectConfig); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectConfig) { + o.SubjectConfig = vSubjectConfig + } + vX509Config := o.X509Config + if vX509Config == nil { + // note: explicitly not the empty object. + vX509Config = &CertificateConfigX509Config{} + } + if err := extractCertificateConfigX509ConfigFields(r, vX509Config); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Config) { + o.X509Config = vX509Config + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateConfigPublicKey{} + } + if err := extractCertificateConfigPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + return nil +} +func postReadExtractCertificateConfigSubjectConfigFields(r *Certificate, o *CertificateConfigSubjectConfig) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateConfigSubjectConfigSubject{} + } + if err := extractCertificateConfigSubjectConfigSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateConfigSubjectConfigSubjectAltName{} + } + if err := extractCertificateConfigSubjectConfigSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func postReadExtractCertificateConfigSubjectConfigSubjectFields(r *Certificate, o *CertificateConfigSubjectConfigSubject) error { + return nil +} +func postReadExtractCertificateConfigSubjectConfigSubjectAltNameFields(r *Certificate, o *CertificateConfigSubjectConfigSubjectAltName) error { + return nil +} +func postReadExtractCertificateConfigX509ConfigFields(r *Certificate, o *CertificateConfigX509Config) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateConfigX509ConfigKeyUsage{} + } + if err := extractCertificateConfigX509ConfigKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateConfigX509ConfigCaOptions{} + } + if err := extractCertificateConfigX509ConfigCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func postReadExtractCertificateConfigX509ConfigKeyUsageFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateConfigX509ConfigKeyUsageBaseKeyUsage{} + } + if err := extractCertificateConfigX509ConfigKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateConfigX509ConfigKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateConfigX509ConfigKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func postReadExtractCertificateConfigX509ConfigKeyUsageBaseKeyUsageFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsageBaseKeyUsage) error { + return nil +} +func postReadExtractCertificateConfigX509ConfigKeyUsageExtendedKeyUsageFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsageExtendedKeyUsage) error { + return nil +} +func postReadExtractCertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsagesFields(r *Certificate, o *CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func postReadExtractCertificateConfigX509ConfigCaOptionsFields(r *Certificate, o *CertificateConfigX509ConfigCaOptions) error { + return nil +} +func postReadExtractCertificateConfigX509ConfigPolicyIdsFields(r *Certificate, o *CertificateConfigX509ConfigPolicyIds) error { + return nil +} +func postReadExtractCertificateConfigX509ConfigAdditionalExtensionsFields(r *Certificate, o *CertificateConfigX509ConfigAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateConfigX509ConfigAdditionalExtensionsObjectId{} + } + if err := extractCertificateConfigX509ConfigAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateConfigX509ConfigAdditionalExtensionsObjectIdFields(r *Certificate, o *CertificateConfigX509ConfigAdditionalExtensionsObjectId) error { + return nil +} +func postReadExtractCertificateConfigPublicKeyFields(r *Certificate, o *CertificateConfigPublicKey) error { + return nil +} +func postReadExtractCertificateRevocationDetailsFields(r *Certificate, o *CertificateRevocationDetails) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionFields(r *Certificate, o *CertificateCertificateDescription) error { + vSubjectDescription := o.SubjectDescription + if vSubjectDescription == nil { + // note: explicitly not the empty object. + vSubjectDescription = &CertificateCertificateDescriptionSubjectDescription{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionFields(r, vSubjectDescription); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectDescription) { + o.SubjectDescription = vSubjectDescription + } + vX509Description := o.X509Description + if vX509Description == nil { + // note: explicitly not the empty object. + vX509Description = &CertificateCertificateDescriptionX509Description{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionFields(r, vX509Description); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vX509Description) { + o.X509Description = vX509Description + } + vPublicKey := o.PublicKey + if vPublicKey == nil { + // note: explicitly not the empty object. + vPublicKey = &CertificateCertificateDescriptionPublicKey{} + } + if err := extractCertificateCertificateDescriptionPublicKeyFields(r, vPublicKey); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPublicKey) { + o.PublicKey = vPublicKey + } + vSubjectKeyId := o.SubjectKeyId + if vSubjectKeyId == nil { + // note: explicitly not the empty object. + vSubjectKeyId = &CertificateCertificateDescriptionSubjectKeyId{} + } + if err := extractCertificateCertificateDescriptionSubjectKeyIdFields(r, vSubjectKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectKeyId) { + o.SubjectKeyId = vSubjectKeyId + } + vAuthorityKeyId := o.AuthorityKeyId + if vAuthorityKeyId == nil { + // note: explicitly not the empty object. + vAuthorityKeyId = &CertificateCertificateDescriptionAuthorityKeyId{} + } + if err := extractCertificateCertificateDescriptionAuthorityKeyIdFields(r, vAuthorityKeyId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vAuthorityKeyId) { + o.AuthorityKeyId = vAuthorityKeyId + } + vCertFingerprint := o.CertFingerprint + if vCertFingerprint == nil { + // note: explicitly not the empty object. + vCertFingerprint = &CertificateCertificateDescriptionCertFingerprint{} + } + if err := extractCertificateCertificateDescriptionCertFingerprintFields(r, vCertFingerprint); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCertFingerprint) { + o.CertFingerprint = vCertFingerprint + } + return nil +} +func postReadExtractCertificateCertificateDescriptionSubjectDescriptionFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescription) error { + vSubject := o.Subject + if vSubject == nil { + // note: explicitly not the empty object. + vSubject = &CertificateCertificateDescriptionSubjectDescriptionSubject{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionSubjectFields(r, vSubject); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubject) { + o.Subject = vSubject + } + vSubjectAltName := o.SubjectAltName + if vSubjectAltName == nil { + // note: explicitly not the empty object. + vSubjectAltName = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltName{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameFields(r, vSubjectAltName); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vSubjectAltName) { + o.SubjectAltName = vSubjectAltName + } + return nil +} +func postReadExtractCertificateCertificateDescriptionSubjectDescriptionSubjectFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubject) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubjectAltName) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId{} + } + if err := extractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectIdFields(r *Certificate, o *CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionFields(r *Certificate, o *CertificateCertificateDescriptionX509Description) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsage{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateCertificateDescriptionX509DescriptionCaOptions{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionKeyUsageFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsageFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsageFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsagesFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionCaOptionsFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionCaOptions) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionPolicyIdsFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionPolicyIds) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId{} + } + if err := extractCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectIdFields(r *Certificate, o *CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionPublicKeyFields(r *Certificate, o *CertificateCertificateDescriptionPublicKey) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionSubjectKeyIdFields(r *Certificate, o *CertificateCertificateDescriptionSubjectKeyId) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionAuthorityKeyIdFields(r *Certificate, o *CertificateCertificateDescriptionAuthorityKeyId) error { + return nil +} +func postReadExtractCertificateCertificateDescriptionCertFingerprintFields(r *Certificate, o *CertificateCertificateDescriptionCertFingerprint) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_schema.go new file mode 100644 index 00000000000..3ec265f4850 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_schema.go @@ -0,0 +1,1344 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLCertificateSchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "Privateca/Certificate", + Description: "The Privateca Certificate resource", + StructName: "Certificate", + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a Certificate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificate", + Required: true, + Description: "A full instance of a Certificate", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a Certificate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificate", + Required: true, + Description: "A full instance of a Certificate", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a Certificate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificate", + Required: true, + Description: "A full instance of a Certificate", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all Certificate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "caPool", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many Certificate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "caPool", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "Certificate": &dcl.Component{ + Title: "Certificate", + ID: "projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificates/{{name}}", + ParentContainer: "project", + LabelsField: "labels", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "name", + "lifetime", + "project", + "location", + "caPool", + }, + Properties: map[string]*dcl.Property{ + "caPool": &dcl.Property{ + Type: "string", + GoName: "CaPool", + Description: "The ca_pool for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Privateca/CaPool", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "certificateAuthority": &dcl.Property{ + Type: "string", + GoName: "CertificateAuthority", + Description: "The certificate authority for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Privateca/CertificateAuthority", + Field: "name", + }, + }, + Parameter: true, + }, + "certificateDescription": &dcl.Property{ + Type: "object", + GoName: "CertificateDescription", + GoType: "CertificateCertificateDescription", + ReadOnly: true, + Description: "Output only. A structured description of the issued X.509 certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "aiaIssuingCertificateUrls": &dcl.Property{ + Type: "array", + GoName: "AiaIssuingCertificateUrls", + Description: "Describes lists of issuer CA certificate URLs that appear in the \"Authority Information Access\" extension in the certificate.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "authorityKeyId": &dcl.Property{ + Type: "object", + GoName: "AuthorityKeyId", + GoType: "CertificateCertificateDescriptionAuthorityKeyId", + Description: "Identifies the subject_key_id of the parent certificate, per https://tools.ietf.org/html/rfc5280#section-4.2.1.1", + Immutable: true, + Properties: map[string]*dcl.Property{ + "keyId": &dcl.Property{ + Type: "string", + GoName: "KeyId", + Description: "Optional. The value of this KeyId encoded in lowercase hexadecimal. This is most likely the 160 bit SHA-1 hash of the public key.", + Immutable: true, + }, + }, + }, + "certFingerprint": &dcl.Property{ + Type: "object", + GoName: "CertFingerprint", + GoType: "CertificateCertificateDescriptionCertFingerprint", + Description: "The hash of the x.509 certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "sha256Hash": &dcl.Property{ + Type: "string", + GoName: "Sha256Hash", + Description: "The SHA 256 hash, encoded in hexadecimal, of the DER x509 certificate.", + Immutable: true, + }, + }, + }, + "crlDistributionPoints": &dcl.Property{ + Type: "array", + GoName: "CrlDistributionPoints", + Description: "Describes a list of locations to obtain CRL information, i.e. the DistributionPoint.fullName described by https://tools.ietf.org/html/rfc5280#section-4.2.1.13", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "publicKey": &dcl.Property{ + Type: "object", + GoName: "PublicKey", + GoType: "CertificateCertificateDescriptionPublicKey", + Description: "The public key that corresponds to an issued certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "format": &dcl.Property{ + Type: "string", + GoName: "Format", + GoType: "CertificateCertificateDescriptionPublicKeyFormatEnum", + Description: "Required. The format of the public key. Possible values: KEY_FORMAT_UNSPECIFIED, PEM", + Immutable: true, + Enum: []string{ + "KEY_FORMAT_UNSPECIFIED", + "PEM", + }, + }, + "key": &dcl.Property{ + Type: "string", + GoName: "Key", + Description: "Required. A public key. The padding and encoding must match with the `KeyFormat` value specified for the `format` field.", + Immutable: true, + }, + }, + }, + "subjectDescription": &dcl.Property{ + Type: "object", + GoName: "SubjectDescription", + GoType: "CertificateCertificateDescriptionSubjectDescription", + Description: "Describes some of the values in a certificate that are related to the subject and lifetime.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "hexSerialNumber": &dcl.Property{ + Type: "string", + GoName: "HexSerialNumber", + Description: "The serial number encoded in lowercase hexadecimal.", + Immutable: true, + }, + "lifetime": &dcl.Property{ + Type: "string", + GoName: "Lifetime", + Description: "For convenience, the actual lifetime of an issued certificate.", + Immutable: true, + }, + "notAfterTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "NotAfterTime", + Description: "The time after which the certificate is expired. Per RFC 5280, the validity period for a certificate is the period of time from not_before_time through not_after_time, inclusive. Corresponds to 'not_before_time' + 'lifetime' - 1 second.", + Immutable: true, + }, + "notBeforeTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "NotBeforeTime", + Description: "The time at which the certificate becomes valid.", + Immutable: true, + }, + "subject": &dcl.Property{ + Type: "object", + GoName: "Subject", + GoType: "CertificateCertificateDescriptionSubjectDescriptionSubject", + Description: "Contains distinguished name fields such as the common name, location and / organization.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "commonName": &dcl.Property{ + Type: "string", + GoName: "CommonName", + Description: "The \"common name\" of the subject.", + Immutable: true, + }, + "countryCode": &dcl.Property{ + Type: "string", + GoName: "CountryCode", + Description: "The country code of the subject.", + Immutable: true, + }, + "locality": &dcl.Property{ + Type: "string", + GoName: "Locality", + Description: "The locality or city of the subject.", + Immutable: true, + }, + "organization": &dcl.Property{ + Type: "string", + GoName: "Organization", + Description: "The organization of the subject.", + Immutable: true, + }, + "organizationalUnit": &dcl.Property{ + Type: "string", + GoName: "OrganizationalUnit", + Description: "The organizational_unit of the subject.", + Immutable: true, + }, + "postalCode": &dcl.Property{ + Type: "string", + GoName: "PostalCode", + Description: "The postal code of the subject.", + Immutable: true, + }, + "province": &dcl.Property{ + Type: "string", + GoName: "Province", + Description: "The province, territory, or regional state of the subject.", + Immutable: true, + }, + "streetAddress": &dcl.Property{ + Type: "string", + GoName: "StreetAddress", + Description: "The street address of the subject.", + Immutable: true, + }, + }, + }, + "subjectAltName": &dcl.Property{ + Type: "object", + GoName: "SubjectAltName", + GoType: "CertificateCertificateDescriptionSubjectDescriptionSubjectAltName", + Description: "The subject alternative name fields.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "customSans": &dcl.Property{ + Type: "array", + GoName: "CustomSans", + Description: "Contains additional subject alternative name values.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans", + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + Immutable: true, + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId", + Description: "Required. The OID for this X.509 extension.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + Immutable: true, + }, + }, + }, + }, + "dnsNames": &dcl.Property{ + Type: "array", + GoName: "DnsNames", + Description: "Contains only valid, fully-qualified host names.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "emailAddresses": &dcl.Property{ + Type: "array", + GoName: "EmailAddresses", + Description: "Contains only valid RFC 2822 E-mail addresses.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "ipAddresses": &dcl.Property{ + Type: "array", + GoName: "IPAddresses", + Description: "Contains only valid 32-bit IPv4 addresses or RFC 4291 IPv6 addresses.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "uris": &dcl.Property{ + Type: "array", + GoName: "Uris", + Description: "Contains only valid RFC 3986 URIs.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + "subjectKeyId": &dcl.Property{ + Type: "object", + GoName: "SubjectKeyId", + GoType: "CertificateCertificateDescriptionSubjectKeyId", + Description: "Provides a means of identifiying certificates that contain a particular public key, per https://tools.ietf.org/html/rfc5280#section-4.2.1.2.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "keyId": &dcl.Property{ + Type: "string", + GoName: "KeyId", + Description: "Optional. The value of this KeyId encoded in lowercase hexadecimal. This is most likely the 160 bit SHA-1 hash of the public key.", + Immutable: true, + }, + }, + }, + "x509Description": &dcl.Property{ + Type: "object", + GoName: "X509Description", + GoType: "CertificateCertificateDescriptionX509Description", + Description: "Describes some of the technical X.509 fields in a certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. Describes custom X.509 extensions.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateCertificateDescriptionX509DescriptionAdditionalExtensions", + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + Immutable: true, + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId", + Description: "Required. The OID for this X.509 extension.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + Immutable: true, + }, + }, + }, + }, + "aiaOcspServers": &dcl.Property{ + Type: "array", + GoName: "AiaOcspServers", + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "caOptions": &dcl.Property{ + Type: "object", + GoName: "CaOptions", + GoType: "CertificateCertificateDescriptionX509DescriptionCaOptions", + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "isCa": &dcl.Property{ + Type: "boolean", + GoName: "IsCa", + Description: "Optional. Refers to the \"CA\" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.", + Immutable: true, + }, + "maxIssuerPathLength": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxIssuerPathLength", + Description: "Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.", + Immutable: true, + }, + }, + }, + "keyUsage": &dcl.Property{ + Type: "object", + GoName: "KeyUsage", + GoType: "CertificateCertificateDescriptionX509DescriptionKeyUsage", + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "baseKeyUsage": &dcl.Property{ + Type: "object", + GoName: "BaseKeyUsage", + GoType: "CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage", + Description: "Describes high-level ways in which a key may be used.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "certSign": &dcl.Property{ + Type: "boolean", + GoName: "CertSign", + Description: "The key may be used to sign certificates.", + Immutable: true, + }, + "contentCommitment": &dcl.Property{ + Type: "boolean", + GoName: "ContentCommitment", + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + Immutable: true, + }, + "crlSign": &dcl.Property{ + Type: "boolean", + GoName: "CrlSign", + Description: "The key may be used sign certificate revocation lists.", + Immutable: true, + }, + "dataEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "DataEncipherment", + Description: "The key may be used to encipher data.", + Immutable: true, + }, + "decipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "DecipherOnly", + Description: "The key may be used to decipher only.", + Immutable: true, + }, + "digitalSignature": &dcl.Property{ + Type: "boolean", + GoName: "DigitalSignature", + Description: "The key may be used for digital signatures.", + Immutable: true, + }, + "encipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "EncipherOnly", + Description: "The key may be used to encipher only.", + Immutable: true, + }, + "keyAgreement": &dcl.Property{ + Type: "boolean", + GoName: "KeyAgreement", + Description: "The key may be used in a key agreement protocol.", + Immutable: true, + }, + "keyEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "KeyEncipherment", + Description: "The key may be used to encipher other keys.", + Immutable: true, + }, + }, + }, + "extendedKeyUsage": &dcl.Property{ + Type: "object", + GoName: "ExtendedKeyUsage", + GoType: "CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage", + Description: "Detailed scenarios in which a key may be used.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "clientAuth": &dcl.Property{ + Type: "boolean", + GoName: "ClientAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + Immutable: true, + }, + "codeSigning": &dcl.Property{ + Type: "boolean", + GoName: "CodeSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + Immutable: true, + }, + "emailProtection": &dcl.Property{ + Type: "boolean", + GoName: "EmailProtection", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + Immutable: true, + }, + "ocspSigning": &dcl.Property{ + Type: "boolean", + GoName: "OcspSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + Immutable: true, + }, + "serverAuth": &dcl.Property{ + Type: "boolean", + GoName: "ServerAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + Immutable: true, + }, + "timeStamping": &dcl.Property{ + Type: "boolean", + GoName: "TimeStamping", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + Immutable: true, + }, + }, + }, + "unknownExtendedKeyUsages": &dcl.Property{ + Type: "array", + GoName: "UnknownExtendedKeyUsages", + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages", + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "policyIds": &dcl.Property{ + Type: "array", + GoName: "PolicyIds", + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateCertificateDescriptionX509DescriptionPolicyIds", + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + }, + }, + "certificateTemplate": &dcl.Property{ + Type: "string", + GoName: "CertificateTemplate", + Description: "Immutable. The resource name for a CertificateTemplate used to issue this certificate, in the format `projects/*/locations/*/certificateTemplates/*`. If this is specified, the caller must have the necessary permission to use this template. If this is omitted, no template will be used. This template must be in the same location as the Certificate.", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Privateca/CertificateTemplate", + Field: "selfLink", + }, + }, + HasLongForm: true, + }, + "config": &dcl.Property{ + Type: "object", + GoName: "Config", + GoType: "CertificateConfig", + Description: "Immutable. A description of the certificate and key that does not require X.509 or ASN.1.", + Immutable: true, + Conflicts: []string{ + "pemCsr", + }, + Required: []string{ + "subjectConfig", + "x509Config", + }, + Properties: map[string]*dcl.Property{ + "publicKey": &dcl.Property{ + Type: "object", + GoName: "PublicKey", + GoType: "CertificateConfigPublicKey", + Description: "Optional. The public key that corresponds to this config. This is, for example, used when issuing Certificates, but not when creating a self-signed CertificateAuthority or CertificateAuthority CSR.", + Immutable: true, + Required: []string{ + "key", + "format", + }, + Properties: map[string]*dcl.Property{ + "format": &dcl.Property{ + Type: "string", + GoName: "Format", + GoType: "CertificateConfigPublicKeyFormatEnum", + Description: "Required. The format of the public key. Possible values: KEY_FORMAT_UNSPECIFIED, PEM", + Immutable: true, + Enum: []string{ + "KEY_FORMAT_UNSPECIFIED", + "PEM", + }, + }, + "key": &dcl.Property{ + Type: "string", + GoName: "Key", + Description: "Required. A public key. The padding and encoding must match with the `KeyFormat` value specified for the `format` field.", + Immutable: true, + }, + }, + }, + "subjectConfig": &dcl.Property{ + Type: "object", + GoName: "SubjectConfig", + GoType: "CertificateConfigSubjectConfig", + Description: "Required. Specifies some of the values in a certificate that are related to the subject.", + Immutable: true, + Required: []string{ + "subject", + }, + Properties: map[string]*dcl.Property{ + "subject": &dcl.Property{ + Type: "object", + GoName: "Subject", + GoType: "CertificateConfigSubjectConfigSubject", + Description: "Required. Contains distinguished name fields such as the common name, location and organization.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "commonName": &dcl.Property{ + Type: "string", + GoName: "CommonName", + Description: "The \"common name\" of the subject.", + Immutable: true, + }, + "countryCode": &dcl.Property{ + Type: "string", + GoName: "CountryCode", + Description: "The country code of the subject.", + Immutable: true, + }, + "locality": &dcl.Property{ + Type: "string", + GoName: "Locality", + Description: "The locality or city of the subject.", + Immutable: true, + }, + "organization": &dcl.Property{ + Type: "string", + GoName: "Organization", + Description: "The organization of the subject.", + Immutable: true, + }, + "organizationalUnit": &dcl.Property{ + Type: "string", + GoName: "OrganizationalUnit", + Description: "The organizational_unit of the subject.", + Immutable: true, + }, + "postalCode": &dcl.Property{ + Type: "string", + GoName: "PostalCode", + Description: "The postal code of the subject.", + Immutable: true, + }, + "province": &dcl.Property{ + Type: "string", + GoName: "Province", + Description: "The province, territory, or regional state of the subject.", + Immutable: true, + }, + "streetAddress": &dcl.Property{ + Type: "string", + GoName: "StreetAddress", + Description: "The street address of the subject.", + Immutable: true, + }, + }, + }, + "subjectAltName": &dcl.Property{ + Type: "object", + GoName: "SubjectAltName", + GoType: "CertificateConfigSubjectConfigSubjectAltName", + Description: "Optional. The subject alternative name fields.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "dnsNames": &dcl.Property{ + Type: "array", + GoName: "DnsNames", + Description: "Contains only valid, fully-qualified host names.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "emailAddresses": &dcl.Property{ + Type: "array", + GoName: "EmailAddresses", + Description: "Contains only valid RFC 2822 E-mail addresses.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "ipAddresses": &dcl.Property{ + Type: "array", + GoName: "IPAddresses", + Description: "Contains only valid 32-bit IPv4 addresses or RFC 4291 IPv6 addresses.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "uris": &dcl.Property{ + Type: "array", + GoName: "Uris", + Description: "Contains only valid RFC 3986 URIs.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + }, + }, + }, + }, + "x509Config": &dcl.Property{ + Type: "object", + GoName: "X509Config", + GoType: "CertificateConfigX509Config", + Description: "Required. Describes how some of the technical X.509 fields in a certificate should be populated.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. Describes custom X.509 extensions.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateConfigX509ConfigAdditionalExtensions", + Required: []string{ + "objectId", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + Immutable: true, + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateConfigX509ConfigAdditionalExtensionsObjectId", + Description: "Required. The OID for this X.509 extension.", + Immutable: true, + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + Immutable: true, + }, + }, + }, + }, + "aiaOcspServers": &dcl.Property{ + Type: "array", + GoName: "AiaOcspServers", + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "caOptions": &dcl.Property{ + Type: "object", + GoName: "CaOptions", + GoType: "CertificateConfigX509ConfigCaOptions", + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "isCa": &dcl.Property{ + Type: "boolean", + GoName: "IsCa", + Description: "Optional. When true, the \"CA\" in Basic Constraints extension will be set to true.", + Immutable: true, + }, + "maxIssuerPathLength": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxIssuerPathLength", + Description: "Optional. Refers to the \"path length constraint\" in Basic Constraints extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail.", + Immutable: true, + }, + "nonCa": &dcl.Property{ + Type: "boolean", + GoName: "NonCa", + Description: "Optional. When true, the \"CA\" in Basic Constraints extension will be set to false. If both `is_ca` and `non_ca` are unset, the extension will be omitted from the CA certificate.", + Immutable: true, + }, + "zeroMaxIssuerPathLength": &dcl.Property{ + Type: "boolean", + GoName: "ZeroMaxIssuerPathLength", + Description: "Optional. When true, the \"path length constraint\" in Basic Constraints extension will be set to 0. if both max_issuer_path_length and zero_max_issuer_path_length are unset, the max path length will be omitted from the CA certificate.", + Immutable: true, + }, + }, + }, + "keyUsage": &dcl.Property{ + Type: "object", + GoName: "KeyUsage", + GoType: "CertificateConfigX509ConfigKeyUsage", + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "baseKeyUsage": &dcl.Property{ + Type: "object", + GoName: "BaseKeyUsage", + GoType: "CertificateConfigX509ConfigKeyUsageBaseKeyUsage", + Description: "Describes high-level ways in which a key may be used.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "certSign": &dcl.Property{ + Type: "boolean", + GoName: "CertSign", + Description: "The key may be used to sign certificates.", + Immutable: true, + }, + "contentCommitment": &dcl.Property{ + Type: "boolean", + GoName: "ContentCommitment", + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + Immutable: true, + }, + "crlSign": &dcl.Property{ + Type: "boolean", + GoName: "CrlSign", + Description: "The key may be used sign certificate revocation lists.", + Immutable: true, + }, + "dataEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "DataEncipherment", + Description: "The key may be used to encipher data.", + Immutable: true, + }, + "decipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "DecipherOnly", + Description: "The key may be used to decipher only.", + Immutable: true, + }, + "digitalSignature": &dcl.Property{ + Type: "boolean", + GoName: "DigitalSignature", + Description: "The key may be used for digital signatures.", + Immutable: true, + }, + "encipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "EncipherOnly", + Description: "The key may be used to encipher only.", + Immutable: true, + }, + "keyAgreement": &dcl.Property{ + Type: "boolean", + GoName: "KeyAgreement", + Description: "The key may be used in a key agreement protocol.", + Immutable: true, + }, + "keyEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "KeyEncipherment", + Description: "The key may be used to encipher other keys.", + Immutable: true, + }, + }, + }, + "extendedKeyUsage": &dcl.Property{ + Type: "object", + GoName: "ExtendedKeyUsage", + GoType: "CertificateConfigX509ConfigKeyUsageExtendedKeyUsage", + Description: "Detailed scenarios in which a key may be used.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "clientAuth": &dcl.Property{ + Type: "boolean", + GoName: "ClientAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + Immutable: true, + }, + "codeSigning": &dcl.Property{ + Type: "boolean", + GoName: "CodeSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + Immutable: true, + }, + "emailProtection": &dcl.Property{ + Type: "boolean", + GoName: "EmailProtection", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + Immutable: true, + }, + "ocspSigning": &dcl.Property{ + Type: "boolean", + GoName: "OcspSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + Immutable: true, + }, + "serverAuth": &dcl.Property{ + Type: "boolean", + GoName: "ServerAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + Immutable: true, + }, + "timeStamping": &dcl.Property{ + Type: "boolean", + GoName: "TimeStamping", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + Immutable: true, + }, + }, + }, + "unknownExtendedKeyUsages": &dcl.Property{ + Type: "array", + GoName: "UnknownExtendedKeyUsages", + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "policyIds": &dcl.Property{ + Type: "array", + GoName: "PolicyIds", + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateConfigX509ConfigPolicyIds", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Immutable: true, + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + }, + }, + "createTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "CreateTime", + ReadOnly: true, + Description: "Output only. The time at which this Certificate was created.", + Immutable: true, + }, + "issuerCertificateAuthority": &dcl.Property{ + Type: "string", + GoName: "IssuerCertificateAuthority", + ReadOnly: true, + Description: "Output only. The resource name of the issuing CertificateAuthority in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`.", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Privateca/CertificateAuthority", + Field: "selfLink", + }, + }, + }, + "labels": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "string", + }, + GoName: "Labels", + Description: "Optional. Labels with user-defined metadata.", + }, + "lifetime": &dcl.Property{ + Type: "string", + GoName: "Lifetime", + Description: "Required. Immutable. The desired lifetime of a certificate. Used to create the \"not_before_time\" and \"not_after_time\" fields inside an X.509 certificate. Note that the lifetime may be truncated if it would extend past the life of any certificate authority in the issuing chain.", + Immutable: true, + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "The location for the resource", + Immutable: true, + Parameter: true, + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "The resource name for this Certificate in the format `projects/*/locations/*/caPools/*/certificates/*`.", + Immutable: true, + HasLongForm: true, + }, + "pemCertificate": &dcl.Property{ + Type: "string", + GoName: "PemCertificate", + ReadOnly: true, + Description: "Output only. The pem-encoded, signed X.509 certificate.", + Immutable: true, + }, + "pemCertificateChain": &dcl.Property{ + Type: "array", + GoName: "PemCertificateChain", + ReadOnly: true, + Description: "Output only. The chain that may be used to verify the X.509 certificate. Expected to be in issuer-to-root order according to RFC 5246.", + Immutable: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "pemCsr": &dcl.Property{ + Type: "string", + GoName: "PemCsr", + Description: "Immutable. A pem-encoded X.509 certificate signing request (CSR).", + Immutable: true, + Conflicts: []string{ + "config", + }, + }, + "project": &dcl.Property{ + Type: "string", + GoName: "Project", + Description: "The project for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "revocationDetails": &dcl.Property{ + Type: "object", + GoName: "RevocationDetails", + GoType: "CertificateRevocationDetails", + ReadOnly: true, + Description: "Output only. Details regarding the revocation of this Certificate. This Certificate is considered revoked if and only if this field is present.", + Immutable: true, + Properties: map[string]*dcl.Property{ + "revocationState": &dcl.Property{ + Type: "string", + GoName: "RevocationState", + GoType: "CertificateRevocationDetailsRevocationStateEnum", + Description: "Indicates why a Certificate was revoked. Possible values: REVOCATION_REASON_UNSPECIFIED, KEY_COMPROMISE, CERTIFICATE_AUTHORITY_COMPROMISE, AFFILIATION_CHANGED, SUPERSEDED, CESSATION_OF_OPERATION, CERTIFICATE_HOLD, PRIVILEGE_WITHDRAWN, ATTRIBUTE_AUTHORITY_COMPROMISE", + Immutable: true, + Enum: []string{ + "REVOCATION_REASON_UNSPECIFIED", + "KEY_COMPROMISE", + "CERTIFICATE_AUTHORITY_COMPROMISE", + "AFFILIATION_CHANGED", + "SUPERSEDED", + "CESSATION_OF_OPERATION", + "CERTIFICATE_HOLD", + "PRIVILEGE_WITHDRAWN", + "ATTRIBUTE_AUTHORITY_COMPROMISE", + }, + }, + "revocationTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "RevocationTime", + Description: "The time at which this Certificate was revoked.", + Immutable: true, + }, + }, + }, + "subjectMode": &dcl.Property{ + Type: "string", + GoName: "SubjectMode", + GoType: "CertificateSubjectModeEnum", + Description: "Immutable. Specifies how the Certificate's identity fields are to be decided. If this is omitted, the `DEFAULT` subject mode will be used. Possible values: SUBJECT_REQUEST_MODE_UNSPECIFIED, DEFAULT, REFLECTED_SPIFFE", + Immutable: true, + Enum: []string{ + "SUBJECT_REQUEST_MODE_UNSPECIFIED", + "DEFAULT", + "REFLECTED_SPIFFE", + }, + }, + "updateTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "UpdateTime", + ReadOnly: true, + Description: "Output only. The time at which this Certificate was updated.", + Immutable: true, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template.go new file mode 100644 index 00000000000..849625eb1bd --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template.go @@ -0,0 +1,1092 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "time" + + "google.golang.org/api/googleapi" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +type CertificateTemplate struct { + Name *string `json:"name"` + PredefinedValues *CertificateTemplatePredefinedValues `json:"predefinedValues"` + IdentityConstraints *CertificateTemplateIdentityConstraints `json:"identityConstraints"` + PassthroughExtensions *CertificateTemplatePassthroughExtensions `json:"passthroughExtensions"` + MaximumLifetime *string `json:"maximumLifetime"` + Description *string `json:"description"` + CreateTime *string `json:"createTime"` + UpdateTime *string `json:"updateTime"` + Labels map[string]string `json:"labels"` + Project *string `json:"project"` + Location *string `json:"location"` +} + +func (r *CertificateTemplate) String() string { + return dcl.SprintResource(r) +} + +// The enum CertificateTemplatePassthroughExtensionsKnownExtensionsEnum. +type CertificateTemplatePassthroughExtensionsKnownExtensionsEnum string + +// CertificateTemplatePassthroughExtensionsKnownExtensionsEnumRef returns a *CertificateTemplatePassthroughExtensionsKnownExtensionsEnum with the value of string s +// If the empty string is provided, nil is returned. +func CertificateTemplatePassthroughExtensionsKnownExtensionsEnumRef(s string) *CertificateTemplatePassthroughExtensionsKnownExtensionsEnum { + v := CertificateTemplatePassthroughExtensionsKnownExtensionsEnum(s) + return &v +} + +func (v CertificateTemplatePassthroughExtensionsKnownExtensionsEnum) Validate() error { + if string(v) == "" { + // Empty enum is okay. + return nil + } + for _, s := range []string{"KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED", "BASE_KEY_USAGE", "EXTENDED_KEY_USAGE", "CA_OPTIONS", "POLICY_IDS", "AIA_OCSP_SERVERS"} { + if string(v) == s { + return nil + } + } + return &dcl.EnumInvalidError{ + Enum: "CertificateTemplatePassthroughExtensionsKnownExtensionsEnum", + Value: string(v), + Valid: []string{}, + } +} + +type CertificateTemplatePredefinedValues struct { + empty bool `json:"-"` + KeyUsage *CertificateTemplatePredefinedValuesKeyUsage `json:"keyUsage"` + CaOptions *CertificateTemplatePredefinedValuesCaOptions `json:"caOptions"` + PolicyIds []CertificateTemplatePredefinedValuesPolicyIds `json:"policyIds"` + AiaOcspServers []string `json:"aiaOcspServers"` + AdditionalExtensions []CertificateTemplatePredefinedValuesAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCertificateTemplatePredefinedValues CertificateTemplatePredefinedValues + +func (r *CertificateTemplatePredefinedValues) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValues + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValues + } else { + + r.KeyUsage = res.KeyUsage + + r.CaOptions = res.CaOptions + + r.PolicyIds = res.PolicyIds + + r.AiaOcspServers = res.AiaOcspServers + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValues is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValues *CertificateTemplatePredefinedValues = &CertificateTemplatePredefinedValues{empty: true} + +func (r *CertificateTemplatePredefinedValues) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValues) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValues) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesKeyUsage struct { + empty bool `json:"-"` + BaseKeyUsage *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage `json:"baseKeyUsage"` + ExtendedKeyUsage *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage `json:"extendedKeyUsage"` + UnknownExtendedKeyUsages []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages `json:"unknownExtendedKeyUsages"` +} + +type jsonCertificateTemplatePredefinedValuesKeyUsage CertificateTemplatePredefinedValuesKeyUsage + +func (r *CertificateTemplatePredefinedValuesKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesKeyUsage + } else { + + r.BaseKeyUsage = res.BaseKeyUsage + + r.ExtendedKeyUsage = res.ExtendedKeyUsage + + r.UnknownExtendedKeyUsages = res.UnknownExtendedKeyUsages + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesKeyUsage *CertificateTemplatePredefinedValuesKeyUsage = &CertificateTemplatePredefinedValuesKeyUsage{empty: true} + +func (r *CertificateTemplatePredefinedValuesKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage struct { + empty bool `json:"-"` + DigitalSignature *bool `json:"digitalSignature"` + ContentCommitment *bool `json:"contentCommitment"` + KeyEncipherment *bool `json:"keyEncipherment"` + DataEncipherment *bool `json:"dataEncipherment"` + KeyAgreement *bool `json:"keyAgreement"` + CertSign *bool `json:"certSign"` + CrlSign *bool `json:"crlSign"` + EncipherOnly *bool `json:"encipherOnly"` + DecipherOnly *bool `json:"decipherOnly"` +} + +type jsonCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + +func (r *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + } else { + + r.DigitalSignature = res.DigitalSignature + + r.ContentCommitment = res.ContentCommitment + + r.KeyEncipherment = res.KeyEncipherment + + r.DataEncipherment = res.DataEncipherment + + r.KeyAgreement = res.KeyAgreement + + r.CertSign = res.CertSign + + r.CrlSign = res.CrlSign + + r.EncipherOnly = res.EncipherOnly + + r.DecipherOnly = res.DecipherOnly + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage = &CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{empty: true} + +func (r *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage struct { + empty bool `json:"-"` + ServerAuth *bool `json:"serverAuth"` + ClientAuth *bool `json:"clientAuth"` + CodeSigning *bool `json:"codeSigning"` + EmailProtection *bool `json:"emailProtection"` + TimeStamping *bool `json:"timeStamping"` + OcspSigning *bool `json:"ocspSigning"` +} + +type jsonCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + +func (r *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + } else { + + r.ServerAuth = res.ServerAuth + + r.ClientAuth = res.ClientAuth + + r.CodeSigning = res.CodeSigning + + r.EmailProtection = res.EmailProtection + + r.TimeStamping = res.TimeStamping + + r.OcspSigning = res.OcspSigning + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage = &CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{empty: true} + +func (r *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + +func (r *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages = &CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{empty: true} + +func (r *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesCaOptions struct { + empty bool `json:"-"` + IsCa *bool `json:"isCa"` + MaxIssuerPathLength *int64 `json:"maxIssuerPathLength"` +} + +type jsonCertificateTemplatePredefinedValuesCaOptions CertificateTemplatePredefinedValuesCaOptions + +func (r *CertificateTemplatePredefinedValuesCaOptions) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesCaOptions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesCaOptions + } else { + + r.IsCa = res.IsCa + + r.MaxIssuerPathLength = res.MaxIssuerPathLength + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesCaOptions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesCaOptions *CertificateTemplatePredefinedValuesCaOptions = &CertificateTemplatePredefinedValuesCaOptions{empty: true} + +func (r *CertificateTemplatePredefinedValuesCaOptions) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesCaOptions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesCaOptions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesPolicyIds struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateTemplatePredefinedValuesPolicyIds CertificateTemplatePredefinedValuesPolicyIds + +func (r *CertificateTemplatePredefinedValuesPolicyIds) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesPolicyIds + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesPolicyIds + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesPolicyIds is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesPolicyIds *CertificateTemplatePredefinedValuesPolicyIds = &CertificateTemplatePredefinedValuesPolicyIds{empty: true} + +func (r *CertificateTemplatePredefinedValuesPolicyIds) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesPolicyIds) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesPolicyIds) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesAdditionalExtensions struct { + empty bool `json:"-"` + ObjectId *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId `json:"objectId"` + Critical *bool `json:"critical"` + Value *string `json:"value"` +} + +type jsonCertificateTemplatePredefinedValuesAdditionalExtensions CertificateTemplatePredefinedValuesAdditionalExtensions + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesAdditionalExtensions + } else { + + r.ObjectId = res.ObjectId + + r.Critical = res.Critical + + r.Value = res.Value + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesAdditionalExtensions *CertificateTemplatePredefinedValuesAdditionalExtensions = &CertificateTemplatePredefinedValuesAdditionalExtensions{empty: true} + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId = &CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{empty: true} + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplateIdentityConstraints struct { + empty bool `json:"-"` + CelExpression *CertificateTemplateIdentityConstraintsCelExpression `json:"celExpression"` + AllowSubjectPassthrough *bool `json:"allowSubjectPassthrough"` + AllowSubjectAltNamesPassthrough *bool `json:"allowSubjectAltNamesPassthrough"` +} + +type jsonCertificateTemplateIdentityConstraints CertificateTemplateIdentityConstraints + +func (r *CertificateTemplateIdentityConstraints) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplateIdentityConstraints + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplateIdentityConstraints + } else { + + r.CelExpression = res.CelExpression + + r.AllowSubjectPassthrough = res.AllowSubjectPassthrough + + r.AllowSubjectAltNamesPassthrough = res.AllowSubjectAltNamesPassthrough + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplateIdentityConstraints is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplateIdentityConstraints *CertificateTemplateIdentityConstraints = &CertificateTemplateIdentityConstraints{empty: true} + +func (r *CertificateTemplateIdentityConstraints) Empty() bool { + return r.empty +} + +func (r *CertificateTemplateIdentityConstraints) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplateIdentityConstraints) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplateIdentityConstraintsCelExpression struct { + empty bool `json:"-"` + Expression *string `json:"expression"` + Title *string `json:"title"` + Description *string `json:"description"` + Location *string `json:"location"` +} + +type jsonCertificateTemplateIdentityConstraintsCelExpression CertificateTemplateIdentityConstraintsCelExpression + +func (r *CertificateTemplateIdentityConstraintsCelExpression) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplateIdentityConstraintsCelExpression + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplateIdentityConstraintsCelExpression + } else { + + r.Expression = res.Expression + + r.Title = res.Title + + r.Description = res.Description + + r.Location = res.Location + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplateIdentityConstraintsCelExpression is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplateIdentityConstraintsCelExpression *CertificateTemplateIdentityConstraintsCelExpression = &CertificateTemplateIdentityConstraintsCelExpression{empty: true} + +func (r *CertificateTemplateIdentityConstraintsCelExpression) Empty() bool { + return r.empty +} + +func (r *CertificateTemplateIdentityConstraintsCelExpression) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplateIdentityConstraintsCelExpression) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePassthroughExtensions struct { + empty bool `json:"-"` + KnownExtensions []CertificateTemplatePassthroughExtensionsKnownExtensionsEnum `json:"knownExtensions"` + AdditionalExtensions []CertificateTemplatePassthroughExtensionsAdditionalExtensions `json:"additionalExtensions"` +} + +type jsonCertificateTemplatePassthroughExtensions CertificateTemplatePassthroughExtensions + +func (r *CertificateTemplatePassthroughExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePassthroughExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePassthroughExtensions + } else { + + r.KnownExtensions = res.KnownExtensions + + r.AdditionalExtensions = res.AdditionalExtensions + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePassthroughExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePassthroughExtensions *CertificateTemplatePassthroughExtensions = &CertificateTemplatePassthroughExtensions{empty: true} + +func (r *CertificateTemplatePassthroughExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePassthroughExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePassthroughExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type CertificateTemplatePassthroughExtensionsAdditionalExtensions struct { + empty bool `json:"-"` + ObjectIdPath []int64 `json:"objectIdPath"` +} + +type jsonCertificateTemplatePassthroughExtensionsAdditionalExtensions CertificateTemplatePassthroughExtensionsAdditionalExtensions + +func (r *CertificateTemplatePassthroughExtensionsAdditionalExtensions) UnmarshalJSON(data []byte) error { + var res jsonCertificateTemplatePassthroughExtensionsAdditionalExtensions + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyCertificateTemplatePassthroughExtensionsAdditionalExtensions + } else { + + r.ObjectIdPath = res.ObjectIdPath + + } + return nil +} + +// This object is used to assert a desired state where this CertificateTemplatePassthroughExtensionsAdditionalExtensions is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyCertificateTemplatePassthroughExtensionsAdditionalExtensions *CertificateTemplatePassthroughExtensionsAdditionalExtensions = &CertificateTemplatePassthroughExtensionsAdditionalExtensions{empty: true} + +func (r *CertificateTemplatePassthroughExtensionsAdditionalExtensions) Empty() bool { + return r.empty +} + +func (r *CertificateTemplatePassthroughExtensionsAdditionalExtensions) String() string { + return dcl.SprintResource(r) +} + +func (r *CertificateTemplatePassthroughExtensionsAdditionalExtensions) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +// Describe returns a simple description of this resource to ensure that automated tools +// can identify it. +func (r *CertificateTemplate) Describe() dcl.ServiceTypeVersion { + return dcl.ServiceTypeVersion{ + Service: "privateca", + Type: "CertificateTemplate", + Version: "privateca", + } +} + +func (r *CertificateTemplate) ID() (string, error) { + if err := extractCertificateTemplateFields(r); err != nil { + return "", err + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "name": dcl.ValueOrEmptyString(nr.Name), + "predefined_values": dcl.ValueOrEmptyString(nr.PredefinedValues), + "identity_constraints": dcl.ValueOrEmptyString(nr.IdentityConstraints), + "passthrough_extensions": dcl.ValueOrEmptyString(nr.PassthroughExtensions), + "maximum_lifetime": dcl.ValueOrEmptyString(nr.MaximumLifetime), + "description": dcl.ValueOrEmptyString(nr.Description), + "create_time": dcl.ValueOrEmptyString(nr.CreateTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + } + return dcl.Nprintf("projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}", params), nil +} + +const CertificateTemplateMaxPage = -1 + +type CertificateTemplateList struct { + Items []*CertificateTemplate + + nextToken string + + pageSize int32 + + resource *CertificateTemplate +} + +func (l *CertificateTemplateList) HasNext() bool { + return l.nextToken != "" +} + +func (l *CertificateTemplateList) Next(ctx context.Context, c *Client) error { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if !l.HasNext() { + return fmt.Errorf("no next page") + } + items, token, err := c.listCertificateTemplate(ctx, l.resource, l.nextToken, l.pageSize) + if err != nil { + return err + } + l.Items = items + l.nextToken = token + return err +} + +func (c *Client) ListCertificateTemplate(ctx context.Context, project, location string) (*CertificateTemplateList, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + return c.ListCertificateTemplateWithMaxResults(ctx, project, location, CertificateTemplateMaxPage) + +} + +func (c *Client) ListCertificateTemplateWithMaxResults(ctx context.Context, project, location string, pageSize int32) (*CertificateTemplateList, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // Create a resource object so that we can use proper url normalization methods. + r := &CertificateTemplate{ + Project: &project, + Location: &location, + } + items, token, err := c.listCertificateTemplate(ctx, r, "", pageSize) + if err != nil { + return nil, err + } + return &CertificateTemplateList{ + Items: items, + nextToken: token, + pageSize: pageSize, + resource: r, + }, nil +} + +func (c *Client) GetCertificateTemplate(ctx context.Context, r *CertificateTemplate) (*CertificateTemplate, error) { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + // This is *purposefully* supressing errors. + // This function is used with url-normalized values + not URL normalized values. + // URL Normalized values will throw unintentional errors, since those values are not of the proper parent form. + extractCertificateTemplateFields(r) + + b, err := c.getCertificateTemplateRaw(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + return nil, &googleapi.Error{ + Code: 404, + Message: err.Error(), + } + } + return nil, err + } + result, err := unmarshalCertificateTemplate(b, c, r) + if err != nil { + return nil, err + } + result.Project = r.Project + result.Location = r.Location + result.Name = r.Name + + c.Config.Logger.InfoWithContextf(ctx, "Retrieved raw result state: %v", result) + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with specified state: %v", r) + result, err = canonicalizeCertificateTemplateNewState(c, result, r) + if err != nil { + return nil, err + } + if err := postReadExtractCertificateTemplateFields(result); err != nil { + return result, err + } + c.Config.Logger.InfoWithContextf(ctx, "Created result state: %v", result) + + return result, nil +} + +func (c *Client) DeleteCertificateTemplate(ctx context.Context, r *CertificateTemplate) error { + ctx = dcl.ContextWithRequestID(ctx) + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + if r == nil { + return fmt.Errorf("CertificateTemplate resource is nil") + } + c.Config.Logger.InfoWithContext(ctx, "Deleting CertificateTemplate...") + deleteOp := deleteCertificateTemplateOperation{} + return deleteOp.do(ctx, r, c) +} + +// DeleteAllCertificateTemplate deletes all resources that the filter functions returns true on. +func (c *Client) DeleteAllCertificateTemplate(ctx context.Context, project, location string, filter func(*CertificateTemplate) bool) error { + listObj, err := c.ListCertificateTemplate(ctx, project, location) + if err != nil { + return err + } + + err = c.deleteAllCertificateTemplate(ctx, filter, listObj.Items) + if err != nil { + return err + } + for listObj.HasNext() { + err = listObj.Next(ctx, c) + if err != nil { + return nil + } + err = c.deleteAllCertificateTemplate(ctx, filter, listObj.Items) + if err != nil { + return err + } + } + return nil +} + +func (c *Client) ApplyCertificateTemplate(ctx context.Context, rawDesired *CertificateTemplate, opts ...dcl.ApplyOption) (*CertificateTemplate, error) { + ctx, cancel := context.WithTimeout(ctx, c.Config.TimeoutOr(0*time.Second)) + defer cancel() + + ctx = dcl.ContextWithRequestID(ctx) + var resultNewState *CertificateTemplate + err := dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + newState, err := applyCertificateTemplateHelper(c, ctx, rawDesired, opts...) + resultNewState = newState + if err != nil { + // If the error is 409, there is conflict in resource update. + // Here we want to apply changes based on latest state. + if dcl.IsConflictError(err) { + return &dcl.RetryDetails{}, dcl.OperationNotDone{Err: err} + } + return nil, err + } + return nil, nil + }, c.Config.RetryProvider) + return resultNewState, err +} + +func applyCertificateTemplateHelper(c *Client, ctx context.Context, rawDesired *CertificateTemplate, opts ...dcl.ApplyOption) (*CertificateTemplate, error) { + c.Config.Logger.InfoWithContext(ctx, "Beginning ApplyCertificateTemplate...") + c.Config.Logger.InfoWithContextf(ctx, "User specified desired state: %v", rawDesired) + + // 1.1: Validation of user-specified fields in desired state. + if err := rawDesired.validate(); err != nil { + return nil, err + } + + if err := extractCertificateTemplateFields(rawDesired); err != nil { + return nil, err + } + + initial, desired, fieldDiffs, err := c.certificateTemplateDiffsForRawDesired(ctx, rawDesired, opts...) + if err != nil { + return nil, fmt.Errorf("failed to create a diff: %w", err) + } + + diffs, err := convertFieldDiffsToCertificateTemplateDiffs(c.Config, fieldDiffs, opts) + if err != nil { + return nil, err + } + + // TODO(magic-modules-eng): 2.2 Feasibility check (all updates are feasible so far). + + // 2.3: Lifecycle Directive Check + var create bool + lp := dcl.FetchLifecycleParams(opts) + if initial == nil { + if dcl.HasLifecycleParam(lp, dcl.BlockCreation) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Creation blocked by lifecycle params: %#v.", desired)} + } + create = true + } else if dcl.HasLifecycleParam(lp, dcl.BlockAcquire) { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("Resource already exists - apply blocked by lifecycle params: %#v.", initial), + } + } else { + for _, d := range diffs { + if d.RequiresRecreate { + return nil, dcl.ApplyInfeasibleError{ + Message: fmt.Sprintf("infeasible update: (%v) would require recreation", d), + } + } + if dcl.HasLifecycleParam(lp, dcl.BlockModification) { + return nil, dcl.ApplyInfeasibleError{Message: fmt.Sprintf("Modification blocked, diff (%v) unresolvable.", d)} + } + } + } + + // 2.4 Imperative Request Planning + var ops []certificateTemplateApiOperation + if create { + ops = append(ops, &createCertificateTemplateOperation{}) + } else { + for _, d := range diffs { + ops = append(ops, d.UpdateOp) + } + } + c.Config.Logger.InfoWithContextf(ctx, "Created plan: %#v", ops) + + // 2.5 Request Actuation + for _, op := range ops { + c.Config.Logger.InfoWithContextf(ctx, "Performing operation %T %+v", op, op) + if err := op.do(ctx, desired, c); err != nil { + c.Config.Logger.InfoWithContextf(ctx, "Failed operation %T %+v: %v", op, op, err) + return nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Finished operation %T %+v", op, op) + } + return applyCertificateTemplateDiff(c, ctx, desired, rawDesired, ops, opts...) +} + +func applyCertificateTemplateDiff(c *Client, ctx context.Context, desired *CertificateTemplate, rawDesired *CertificateTemplate, ops []certificateTemplateApiOperation, opts ...dcl.ApplyOption) (*CertificateTemplate, error) { + // 3.1, 3.2a Retrieval of raw new state & canonicalization with desired state + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state...") + rawNew, err := c.GetCertificateTemplate(ctx, desired) + if err != nil { + return nil, err + } + // Get additional values from the first response. + // These values should be merged into the newState above. + if len(ops) > 0 { + lastOp := ops[len(ops)-1] + if o, ok := lastOp.(*createCertificateTemplateOperation); ok { + if r, hasR := o.FirstResponse(); hasR { + + c.Config.Logger.InfoWithContext(ctx, "Retrieving raw new state from operation...") + + fullResp, err := unmarshalMapCertificateTemplate(r, c, rawDesired) + if err != nil { + return nil, err + } + + rawNew, err = canonicalizeCertificateTemplateNewState(c, rawNew, fullResp) + if err != nil { + return nil, err + } + } + } + } + + c.Config.Logger.InfoWithContextf(ctx, "Canonicalizing with raw desired state: %v", rawDesired) + // 3.2b Canonicalization of raw new state using raw desired state + newState, err := canonicalizeCertificateTemplateNewState(c, rawNew, rawDesired) + if err != nil { + return rawNew, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created canonical new state: %v", newState) + // 3.3 Comparison of the new state and raw desired state. + // TODO(magic-modules-eng): EVENTUALLY_CONSISTENT_UPDATE + newDesired, err := canonicalizeCertificateTemplateDesiredState(rawDesired, newState) + if err != nil { + return newState, err + } + + if err := postReadExtractCertificateTemplateFields(newState); err != nil { + return newState, err + } + + // Need to ensure any transformations made here match acceptably in differ. + if err := postReadExtractCertificateTemplateFields(newDesired); err != nil { + return newState, err + } + + c.Config.Logger.InfoWithContextf(ctx, "Diffing using canonicalized desired state: %v", newDesired) + newDiffs, err := diffCertificateTemplate(c, newDesired, newState) + if err != nil { + return newState, err + } + + if len(newDiffs) == 0 { + c.Config.Logger.InfoWithContext(ctx, "No diffs found. Apply was successful.") + } else { + c.Config.Logger.InfoWithContextf(ctx, "Found diffs: %v", newDiffs) + diffMessages := make([]string, len(newDiffs)) + for i, d := range newDiffs { + diffMessages[i] = fmt.Sprintf("%v", d) + } + return newState, dcl.DiffAfterApplyError{Diffs: diffMessages} + } + c.Config.Logger.InfoWithContext(ctx, "Done Apply.") + return newState, nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template.yaml b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template.yaml new file mode 100644 index 00000000000..92dfb05040a --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template.yaml @@ -0,0 +1,481 @@ +# Copyright 2024 Google LLC. All Rights Reserved. +# +# 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. +info: + title: Privateca/CertificateTemplate + description: Certificate Authority Service provides reusable and parameterized templates + that you can use for common certificate issuance scenarios. A certificate template + represents a relatively static and well-defined certificate issuance schema within + an organization. A certificate template can essentially become a full-fledged + vertical certificate issuance framework. + x-dcl-struct-name: CertificateTemplate + x-dcl-has-iam: false + x-dcl-ref: + text: REST API + url: https://cloud.google.com/certificate-authority-service/docs/reference/rest/v1/projects.locations.certificateTemplates + x-dcl-guides: + - text: Understanding Certificate Templates + url: https://cloud.google.com/certificate-authority-service/docs/certificate-template + - text: Common configurations and Certificate Profiles + url: https://cloud.google.com/certificate-authority-service/docs/certificate-profile +paths: + get: + description: The function used to get information about a CertificateTemplate + parameters: + - name: certificateTemplate + required: true + description: A full instance of a CertificateTemplate + apply: + description: The function used to apply information about a CertificateTemplate + parameters: + - name: certificateTemplate + required: true + description: A full instance of a CertificateTemplate + delete: + description: The function used to delete a CertificateTemplate + parameters: + - name: certificateTemplate + required: true + description: A full instance of a CertificateTemplate + deleteAll: + description: The function used to delete all CertificateTemplate + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string + list: + description: The function used to list information about many CertificateTemplate + parameters: + - name: project + required: true + schema: + type: string + - name: location + required: true + schema: + type: string +components: + schemas: + CertificateTemplate: + title: CertificateTemplate + x-dcl-id: projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}} + x-dcl-parent-container: project + x-dcl-labels: labels + x-dcl-has-create: true + x-dcl-has-iam: false + x-dcl-read-timeout: 0 + x-dcl-apply-timeout: 0 + x-dcl-delete-timeout: 0 + type: object + required: + - name + - project + - location + properties: + createTime: + type: string + format: date-time + x-dcl-go-name: CreateTime + readOnly: true + description: Output only. The time at which this CertificateTemplate was + created. + x-kubernetes-immutable: true + description: + type: string + x-dcl-go-name: Description + description: Optional. A human-readable description of scenarios this template + is intended for. + identityConstraints: + type: object + x-dcl-go-name: IdentityConstraints + x-dcl-go-type: CertificateTemplateIdentityConstraints + description: Optional. Describes constraints on identities that may be appear + in Certificates issued using this template. If this is omitted, then this + template will not add restrictions on a certificate's identity. + required: + - allowSubjectPassthrough + - allowSubjectAltNamesPassthrough + properties: + allowSubjectAltNamesPassthrough: + type: boolean + x-dcl-go-name: AllowSubjectAltNamesPassthrough + description: Required. If this is true, the SubjectAltNames extension + may be copied from a certificate request into the signed certificate. + Otherwise, the requested SubjectAltNames will be discarded. + allowSubjectPassthrough: + type: boolean + x-dcl-go-name: AllowSubjectPassthrough + description: Required. If this is true, the Subject field may be copied + from a certificate request into the signed certificate. Otherwise, + the requested Subject will be discarded. + celExpression: + type: object + x-dcl-go-name: CelExpression + x-dcl-go-type: CertificateTemplateIdentityConstraintsCelExpression + description: Optional. A CEL expression that may be used to validate + the resolved X.509 Subject and/or Subject Alternative Name before + a certificate is signed. To see the full allowed syntax and some examples, + see https://cloud.google.com/certificate-authority-service/docs/using-cel + properties: + description: + type: string + x-dcl-go-name: Description + description: Optional. Description of the expression. This is a + longer text which describes the expression, e.g. when hovered + over it in a UI. + expression: + type: string + x-dcl-go-name: Expression + description: Textual representation of an expression in Common Expression + Language syntax. + location: + type: string + x-dcl-go-name: Location + description: Optional. String indicating the location of the expression + for error reporting, e.g. a file name and a position in the file. + title: + type: string + x-dcl-go-name: Title + description: Optional. Title for the expression, i.e. a short string + describing its purpose. This can be used e.g. in UIs which allow + to enter the expression. + labels: + type: object + additionalProperties: + type: string + x-dcl-go-name: Labels + description: Optional. Labels with user-defined metadata. + location: + type: string + x-dcl-go-name: Location + description: The location for the resource + x-kubernetes-immutable: true + x-dcl-parameter: true + maximumLifetime: + type: string + x-dcl-go-name: MaximumLifetime + description: Optional. The maximum lifetime allowed for all issued certificates + that use this template. If the issuing CaPool's IssuancePolicy specifies + a maximum lifetime the minimum of the two durations will be the maximum + lifetime for issued. Note that if the issuing CertificateAuthority expires + before a Certificate's requested maximum_lifetime, the effective lifetime + will be explicitly truncated to match it. + name: + type: string + x-dcl-go-name: Name + description: The resource name for this CertificateTemplate in the format + `projects/*/locations/*/certificateTemplates/*`. + x-kubernetes-immutable: true + x-dcl-has-long-form: true + passthroughExtensions: + type: object + x-dcl-go-name: PassthroughExtensions + x-dcl-go-type: CertificateTemplatePassthroughExtensions + description: Optional. Describes the set of X.509 extensions that may appear + in a Certificate issued using this CertificateTemplate. If a certificate + request sets extensions that don't appear in the passthrough_extensions, + those extensions will be dropped. If the issuing CaPool's IssuancePolicy + defines baseline_values that don't appear here, the certificate issuance + request will fail. If this is omitted, then this template will not add + restrictions on a certificate's X.509 extensions. These constraints do + not apply to X.509 extensions set in this CertificateTemplate's predefined_values. + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. A set of ObjectIds identifying custom X.509 extensions. + Will be combined with known_extensions to determine the full set of + X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateTemplatePassthroughExtensionsAdditionalExtensions + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most significant + parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + knownExtensions: + type: array + x-dcl-go-name: KnownExtensions + description: Optional. A set of named X.509 extensions. Will be combined + with additional_extensions to determine the full set of X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: CertificateTemplatePassthroughExtensionsKnownExtensionsEnum + enum: + - KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED + - BASE_KEY_USAGE + - EXTENDED_KEY_USAGE + - CA_OPTIONS + - POLICY_IDS + - AIA_OCSP_SERVERS + predefinedValues: + type: object + x-dcl-go-name: PredefinedValues + x-dcl-go-type: CertificateTemplatePredefinedValues + description: Optional. A set of X.509 values that will be applied to all + issued certificates that use this template. If the certificate request + includes conflicting values for the same properties, they will be overwritten + by the values defined here. If the issuing CaPool's IssuancePolicy defines + conflicting baseline_values for the same properties, the certificate issuance + request will fail. + properties: + additionalExtensions: + type: array + x-dcl-go-name: AdditionalExtensions + description: Optional. Describes custom X.509 extensions. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateTemplatePredefinedValuesAdditionalExtensions + required: + - objectId + - value + properties: + critical: + type: boolean + x-dcl-go-name: Critical + description: Optional. Indicates whether or not this extension + is critical (i.e., if the client does not know how to handle + this extension, the client should consider this to be an error). + objectId: + type: object + x-dcl-go-name: ObjectId + x-dcl-go-type: CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + description: Required. The OID for this X.509 extension. + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + value: + type: string + x-dcl-go-name: Value + description: Required. The value of this X.509 extension. + aiaOcspServers: + type: array + x-dcl-go-name: AiaOcspServers + description: Optional. Describes Online Certificate Status Protocol + (OCSP) endpoint addresses that appear in the "Authority Information + Access" extension in the certificate. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + caOptions: + type: object + x-dcl-go-name: CaOptions + x-dcl-go-type: CertificateTemplatePredefinedValuesCaOptions + description: Optional. Describes options in this X509Parameters that + are relevant in a CA certificate. + properties: + isCa: + type: boolean + x-dcl-go-name: IsCa + description: Optional. Refers to the "CA" X.509 extension, which + is a boolean value. When this value is missing, the extension + will be omitted from the CA certificate. + maxIssuerPathLength: + type: integer + format: int64 + x-dcl-go-name: MaxIssuerPathLength + description: Optional. Refers to the path length restriction X.509 + extension. For a CA certificate, this value describes the depth + of subordinate CA certificates that are allowed. If this value + is less than 0, the request will fail. If this value is missing, + the max path length will be omitted from the CA certificate. + keyUsage: + type: object + x-dcl-go-name: KeyUsage + x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsage + description: Optional. Indicates the intended use for keys that correspond + to a certificate. + properties: + baseKeyUsage: + type: object + x-dcl-go-name: BaseKeyUsage + x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + description: Describes high-level ways in which a key may be used. + properties: + certSign: + type: boolean + x-dcl-go-name: CertSign + description: The key may be used to sign certificates. + contentCommitment: + type: boolean + x-dcl-go-name: ContentCommitment + description: The key may be used for cryptographic commitments. + Note that this may also be referred to as "non-repudiation". + crlSign: + type: boolean + x-dcl-go-name: CrlSign + description: The key may be used sign certificate revocation + lists. + dataEncipherment: + type: boolean + x-dcl-go-name: DataEncipherment + description: The key may be used to encipher data. + decipherOnly: + type: boolean + x-dcl-go-name: DecipherOnly + description: The key may be used to decipher only. + digitalSignature: + type: boolean + x-dcl-go-name: DigitalSignature + description: The key may be used for digital signatures. + encipherOnly: + type: boolean + x-dcl-go-name: EncipherOnly + description: The key may be used to encipher only. + keyAgreement: + type: boolean + x-dcl-go-name: KeyAgreement + description: The key may be used in a key agreement protocol. + keyEncipherment: + type: boolean + x-dcl-go-name: KeyEncipherment + description: The key may be used to encipher other keys. + extendedKeyUsage: + type: object + x-dcl-go-name: ExtendedKeyUsage + x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + description: Detailed scenarios in which a key may be used. + properties: + clientAuth: + type: boolean + x-dcl-go-name: ClientAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially + described as "TLS WWW client authentication", though regularly + used for non-WWW TLS. + codeSigning: + type: boolean + x-dcl-go-name: CodeSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially + described as "Signing of downloadable executable code client + authentication". + emailProtection: + type: boolean + x-dcl-go-name: EmailProtection + description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially + described as "Email protection". + ocspSigning: + type: boolean + x-dcl-go-name: OcspSigning + description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially + described as "Signing OCSP responses". + serverAuth: + type: boolean + x-dcl-go-name: ServerAuth + description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially + described as "TLS WWW server authentication", though regularly + used for non-WWW TLS. + timeStamping: + type: boolean + x-dcl-go-name: TimeStamping + description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially + described as "Binding the hash of an object to a time". + unknownExtendedKeyUsages: + type: array + x-dcl-go-name: UnknownExtendedKeyUsages + description: Used to describe extended key usages that are not listed + in the KeyUsage.ExtendedKeyUsageOptions message. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most + significant parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + policyIds: + type: array + x-dcl-go-name: PolicyIds + description: Optional. Describes the X.509 certificate policy object + identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: CertificateTemplatePredefinedValuesPolicyIds + required: + - objectIdPath + properties: + objectIdPath: + type: array + x-dcl-go-name: ObjectIdPath + description: Required. The parts of an OID path. The most significant + parts of the path come first. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: integer + format: int64 + x-dcl-go-type: int64 + project: + type: string + x-dcl-go-name: Project + description: The project for the resource + x-kubernetes-immutable: true + x-dcl-references: + - resource: Cloudresourcemanager/Project + field: name + parent: true + x-dcl-parameter: true + updateTime: + type: string + format: date-time + x-dcl-go-name: UpdateTime + readOnly: true + description: Output only. The time at which this CertificateTemplate was + updated. + x-kubernetes-immutable: true diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_internal.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_internal.go new file mode 100644 index 00000000000..da29ae01890 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_internal.go @@ -0,0 +1,5201 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strings" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" +) + +func (r *CertificateTemplate) validate() error { + + if err := dcl.Required(r, "name"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Project, "Project"); err != nil { + return err + } + if err := dcl.RequiredParameter(r.Location, "Location"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.PredefinedValues) { + if err := r.PredefinedValues.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.IdentityConstraints) { + if err := r.IdentityConstraints.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.PassthroughExtensions) { + if err := r.PassthroughExtensions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateTemplatePredefinedValues) validate() error { + if !dcl.IsEmptyValueIndirect(r.KeyUsage) { + if err := r.KeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.CaOptions) { + if err := r.CaOptions.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateTemplatePredefinedValuesKeyUsage) validate() error { + if !dcl.IsEmptyValueIndirect(r.BaseKeyUsage) { + if err := r.BaseKeyUsage.validate(); err != nil { + return err + } + } + if !dcl.IsEmptyValueIndirect(r.ExtendedKeyUsage) { + if err := r.ExtendedKeyUsage.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) validate() error { + return nil +} +func (r *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) validate() error { + return nil +} +func (r *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateTemplatePredefinedValuesCaOptions) validate() error { + return nil +} +func (r *CertificateTemplatePredefinedValuesPolicyIds) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateTemplatePredefinedValuesAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectId"); err != nil { + return err + } + if err := dcl.Required(r, "value"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.ObjectId) { + if err := r.ObjectId.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateTemplateIdentityConstraints) validate() error { + if err := dcl.Required(r, "allowSubjectPassthrough"); err != nil { + return err + } + if err := dcl.Required(r, "allowSubjectAltNamesPassthrough"); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(r.CelExpression) { + if err := r.CelExpression.validate(); err != nil { + return err + } + } + return nil +} +func (r *CertificateTemplateIdentityConstraintsCelExpression) validate() error { + return nil +} +func (r *CertificateTemplatePassthroughExtensions) validate() error { + return nil +} +func (r *CertificateTemplatePassthroughExtensionsAdditionalExtensions) validate() error { + if err := dcl.Required(r, "objectIdPath"); err != nil { + return err + } + return nil +} +func (r *CertificateTemplate) basePath() string { + params := map[string]interface{}{} + return dcl.Nprintf("https://privateca.googleapis.com/v1/", params) +} + +func (r *CertificateTemplate) getURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}", nr.basePath(), userBasePath, params), nil +} + +func (r *CertificateTemplate) listURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/certificateTemplates", nr.basePath(), userBasePath, params), nil + +} + +func (r *CertificateTemplate) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/certificateTemplates?certificateTemplateId={{name}}", nr.basePath(), userBasePath, params), nil + +} + +func (r *CertificateTemplate) deleteURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}", nr.basePath(), userBasePath, params), nil +} + +// certificateTemplateApiOperation represents a mutable operation in the underlying REST +// API such as Create, Update, or Delete. +type certificateTemplateApiOperation interface { + do(context.Context, *CertificateTemplate, *Client) error +} + +// newUpdateCertificateTemplateUpdateCertificateTemplateRequest creates a request for an +// CertificateTemplate resource's UpdateCertificateTemplate update type by filling in the update +// fields based on the intended state of the resource. +func newUpdateCertificateTemplateUpdateCertificateTemplateRequest(ctx context.Context, f *CertificateTemplate, c *Client) (map[string]interface{}, error) { + req := map[string]interface{}{} + res := f + _ = res + + if v, err := expandCertificateTemplatePredefinedValues(c, f.PredefinedValues, res); err != nil { + return nil, fmt.Errorf("error expanding PredefinedValues into predefinedValues: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["predefinedValues"] = v + } + if v, err := expandCertificateTemplateIdentityConstraints(c, f.IdentityConstraints, res); err != nil { + return nil, fmt.Errorf("error expanding IdentityConstraints into identityConstraints: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["identityConstraints"] = v + } + if v, err := expandCertificateTemplatePassthroughExtensions(c, f.PassthroughExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding PassthroughExtensions into passthroughExtensions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["passthroughExtensions"] = v + } + if v := f.MaximumLifetime; !dcl.IsEmptyValueIndirect(v) { + req["maximumLifetime"] = v + } + if v := f.Description; !dcl.IsEmptyValueIndirect(v) { + req["description"] = v + } + if v := f.Labels; !dcl.IsEmptyValueIndirect(v) { + req["labels"] = v + } + req["name"] = fmt.Sprintf("projects/%s/locations/%s/certificateTemplates/%s", *f.Project, *f.Location, *f.Name) + + return req, nil +} + +// marshalUpdateCertificateTemplateUpdateCertificateTemplateRequest converts the update into +// the final JSON request body. +func marshalUpdateCertificateTemplateUpdateCertificateTemplateRequest(c *Client, m map[string]interface{}) ([]byte, error) { + + return json.Marshal(m) +} + +type updateCertificateTemplateUpdateCertificateTemplateOperation struct { + // If the update operation has the REQUIRES_APPLY_OPTIONS trait, this will be populated. + // Usually it will be nil - this is to prevent us from accidentally depending on apply + // options, which should usually be unnecessary. + ApplyOptions []dcl.ApplyOption + FieldDiffs []*dcl.FieldDiff +} + +// do creates a request and sends it to the appropriate URL. In most operations, +// do will transcribe a subset of the resource into a request object and send a +// PUT request to a single URL. + +func (op *updateCertificateTemplateUpdateCertificateTemplateOperation) do(ctx context.Context, r *CertificateTemplate, c *Client) error { + _, err := c.GetCertificateTemplate(ctx, r) + if err != nil { + return err + } + + u, err := r.updateURL(c.Config.BasePath, "UpdateCertificateTemplate") + if err != nil { + return err + } + mask := dcl.TopLevelUpdateMask(op.FieldDiffs) + u, err = dcl.AddQueryParams(u, map[string]string{"updateMask": mask}) + if err != nil { + return err + } + + req, err := newUpdateCertificateTemplateUpdateCertificateTemplateRequest(ctx, r, c) + if err != nil { + return err + } + + c.Config.Logger.InfoWithContextf(ctx, "Created update: %#v", req) + body, err := marshalUpdateCertificateTemplateUpdateCertificateTemplateRequest(c, req) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "PATCH", u, bytes.NewBuffer(body), c.Config.RetryProvider) + if err != nil { + return err + } + + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + err = o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET") + + if err != nil { + return err + } + + return nil +} + +func (c *Client) listCertificateTemplateRaw(ctx context.Context, r *CertificateTemplate, pageToken string, pageSize int32) ([]byte, error) { + u, err := r.urlNormalized().listURL(c.Config.BasePath) + if err != nil { + return nil, err + } + + m := make(map[string]string) + if pageToken != "" { + m["pageToken"] = pageToken + } + + if pageSize != CertificateTemplateMaxPage { + m["pageSize"] = fmt.Sprintf("%v", pageSize) + } + + u, err = dcl.AddQueryParams(u, m) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + return ioutil.ReadAll(resp.Response.Body) +} + +type listCertificateTemplateOperation struct { + CertificateTemplates []map[string]interface{} `json:"certificateTemplates"` + Token string `json:"nextPageToken"` +} + +func (c *Client) listCertificateTemplate(ctx context.Context, r *CertificateTemplate, pageToken string, pageSize int32) ([]*CertificateTemplate, string, error) { + b, err := c.listCertificateTemplateRaw(ctx, r, pageToken, pageSize) + if err != nil { + return nil, "", err + } + + var m listCertificateTemplateOperation + if err := json.Unmarshal(b, &m); err != nil { + return nil, "", err + } + + var l []*CertificateTemplate + for _, v := range m.CertificateTemplates { + res, err := unmarshalMapCertificateTemplate(v, c, r) + if err != nil { + return nil, m.Token, err + } + res.Project = r.Project + res.Location = r.Location + l = append(l, res) + } + + return l, m.Token, nil +} + +func (c *Client) deleteAllCertificateTemplate(ctx context.Context, f func(*CertificateTemplate) bool, resources []*CertificateTemplate) error { + var errors []string + for _, res := range resources { + if f(res) { + // We do not want deleteAll to fail on a deletion or else it will stop deleting other resources. + err := c.DeleteCertificateTemplate(ctx, res) + if err != nil { + errors = append(errors, err.Error()) + } + } + } + if len(errors) > 0 { + return fmt.Errorf("%v", strings.Join(errors, "\n")) + } else { + return nil + } +} + +type deleteCertificateTemplateOperation struct{} + +func (op *deleteCertificateTemplateOperation) do(ctx context.Context, r *CertificateTemplate, c *Client) error { + r, err := c.GetCertificateTemplate(ctx, r) + if err != nil { + if dcl.IsNotFound(err) { + c.Config.Logger.InfoWithContextf(ctx, "CertificateTemplate not found, returning. Original error: %v", err) + return nil + } + c.Config.Logger.WarningWithContextf(ctx, "GetCertificateTemplate checking for existence. error: %v", err) + return err + } + + u, err := r.deleteURL(c.Config.BasePath) + if err != nil { + return err + } + + // Delete should never have a body + body := &bytes.Buffer{} + resp, err := dcl.SendRequest(ctx, c.Config, "DELETE", u, body, c.Config.RetryProvider) + if err != nil { + return err + } + + // wait for object to be deleted. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET"); err != nil { + return err + } + + // We saw a race condition where for some successful delete operation, the Get calls returned resources for a short duration. + // This is the reason we are adding retry to handle that case. + retriesRemaining := 10 + dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + _, err := c.GetCertificateTemplate(ctx, r) + if dcl.IsNotFound(err) { + return nil, nil + } + if retriesRemaining > 0 { + retriesRemaining-- + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + } + return nil, dcl.NotDeletedError{ExistingResource: r} + }, c.Config.RetryProvider) + return nil +} + +// Create operations are similar to Update operations, although they do not have +// specific request objects. The Create request object is the json encoding of +// the resource, which is modified by res.marshal to form the base request body. +type createCertificateTemplateOperation struct { + response map[string]interface{} +} + +func (op *createCertificateTemplateOperation) FirstResponse() (map[string]interface{}, bool) { + return op.response, len(op.response) > 0 +} + +func (op *createCertificateTemplateOperation) do(ctx context.Context, r *CertificateTemplate, c *Client) error { + c.Config.Logger.InfoWithContextf(ctx, "Attempting to create %v", r) + u, err := r.createURL(c.Config.BasePath) + if err != nil { + return err + } + + req, err := r.marshal(c) + if err != nil { + return err + } + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, bytes.NewBuffer(req), c.Config.RetryProvider) + if err != nil { + return err + } + // wait for object to be created. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(context.WithValue(ctx, dcl.DoNotLogRequestsKey, true), c.Config, r.basePath(), "GET"); err != nil { + c.Config.Logger.Warningf("Creation failed after waiting for operation: %v", err) + return err + } + c.Config.Logger.InfoWithContextf(ctx, "Successfully waited for operation") + op.response, _ = o.FirstResponse() + + if _, err := c.GetCertificateTemplate(ctx, r); err != nil { + c.Config.Logger.WarningWithContextf(ctx, "get returned error: %v", err) + return err + } + + return nil +} + +func (c *Client) getCertificateTemplateRaw(ctx context.Context, r *CertificateTemplate) ([]byte, error) { + + u, err := r.getURL(c.Config.BasePath) + if err != nil { + return nil, err + } + resp, err := dcl.SendRequest(ctx, c.Config, "GET", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return nil, err + } + defer resp.Response.Body.Close() + b, err := ioutil.ReadAll(resp.Response.Body) + if err != nil { + return nil, err + } + + return b, nil +} + +func (c *Client) certificateTemplateDiffsForRawDesired(ctx context.Context, rawDesired *CertificateTemplate, opts ...dcl.ApplyOption) (initial, desired *CertificateTemplate, diffs []*dcl.FieldDiff, err error) { + c.Config.Logger.InfoWithContext(ctx, "Fetching initial state...") + // First, let us see if the user provided a state hint. If they did, we will start fetching based on that. + var fetchState *CertificateTemplate + if sh := dcl.FetchStateHint(opts); sh != nil { + if r, ok := sh.(*CertificateTemplate); !ok { + c.Config.Logger.WarningWithContextf(ctx, "Initial state hint was of the wrong type; expected CertificateTemplate, got %T", sh) + } else { + fetchState = r + } + } + if fetchState == nil { + fetchState = rawDesired + } + + // 1.2: Retrieval of raw initial state from API + rawInitial, err := c.GetCertificateTemplate(ctx, fetchState) + if rawInitial == nil { + if !dcl.IsNotFound(err) { + c.Config.Logger.WarningWithContextf(ctx, "Failed to retrieve whether a CertificateTemplate resource already exists: %s", err) + return nil, nil, nil, fmt.Errorf("failed to retrieve CertificateTemplate resource: %v", err) + } + c.Config.Logger.InfoWithContext(ctx, "Found that CertificateTemplate resource did not exist.") + // Perform canonicalization to pick up defaults. + desired, err = canonicalizeCertificateTemplateDesiredState(rawDesired, rawInitial) + return nil, desired, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Found initial state for CertificateTemplate: %v", rawInitial) + c.Config.Logger.InfoWithContextf(ctx, "Initial desired state for CertificateTemplate: %v", rawDesired) + + // The Get call applies postReadExtract and so the result may contain fields that are not part of API version. + if err := extractCertificateTemplateFields(rawInitial); err != nil { + return nil, nil, nil, err + } + + // 1.3: Canonicalize raw initial state into initial state. + initial, err = canonicalizeCertificateTemplateInitialState(rawInitial, rawDesired) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized initial state for CertificateTemplate: %v", initial) + + // 1.4: Canonicalize raw desired state into desired state. + desired, err = canonicalizeCertificateTemplateDesiredState(rawDesired, rawInitial, opts...) + if err != nil { + return nil, nil, nil, err + } + c.Config.Logger.InfoWithContextf(ctx, "Canonicalized desired state for CertificateTemplate: %v", desired) + + // 2.1: Comparison of initial and desired state. + diffs, err = diffCertificateTemplate(c, desired, initial, opts...) + return initial, desired, diffs, err +} + +func canonicalizeCertificateTemplateInitialState(rawInitial, rawDesired *CertificateTemplate) (*CertificateTemplate, error) { + // TODO(magic-modules-eng): write canonicalizer once relevant traits are added. + return rawInitial, nil +} + +/* +* Canonicalizers +* +* These are responsible for converting either a user-specified config or a +* GCP API response to a standard format that can be used for difference checking. +* */ + +func canonicalizeCertificateTemplateDesiredState(rawDesired, rawInitial *CertificateTemplate, opts ...dcl.ApplyOption) (*CertificateTemplate, error) { + + if rawInitial == nil { + // Since the initial state is empty, the desired state is all we have. + // We canonicalize the remaining nested objects with nil to pick up defaults. + rawDesired.PredefinedValues = canonicalizeCertificateTemplatePredefinedValues(rawDesired.PredefinedValues, nil, opts...) + rawDesired.IdentityConstraints = canonicalizeCertificateTemplateIdentityConstraints(rawDesired.IdentityConstraints, nil, opts...) + rawDesired.PassthroughExtensions = canonicalizeCertificateTemplatePassthroughExtensions(rawDesired.PassthroughExtensions, nil, opts...) + + return rawDesired, nil + } + canonicalDesired := &CertificateTemplate{} + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawInitial.Name) { + canonicalDesired.Name = rawInitial.Name + } else { + canonicalDesired.Name = rawDesired.Name + } + canonicalDesired.PredefinedValues = canonicalizeCertificateTemplatePredefinedValues(rawDesired.PredefinedValues, rawInitial.PredefinedValues, opts...) + canonicalDesired.IdentityConstraints = canonicalizeCertificateTemplateIdentityConstraints(rawDesired.IdentityConstraints, rawInitial.IdentityConstraints, opts...) + canonicalDesired.PassthroughExtensions = canonicalizeCertificateTemplatePassthroughExtensions(rawDesired.PassthroughExtensions, rawInitial.PassthroughExtensions, opts...) + if dcl.StringCanonicalize(rawDesired.MaximumLifetime, rawInitial.MaximumLifetime) { + canonicalDesired.MaximumLifetime = rawInitial.MaximumLifetime + } else { + canonicalDesired.MaximumLifetime = rawDesired.MaximumLifetime + } + if dcl.StringCanonicalize(rawDesired.Description, rawInitial.Description) { + canonicalDesired.Description = rawInitial.Description + } else { + canonicalDesired.Description = rawDesired.Description + } + if dcl.IsZeroValue(rawDesired.Labels) || (dcl.IsEmptyValueIndirect(rawDesired.Labels) && dcl.IsEmptyValueIndirect(rawInitial.Labels)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.Labels = rawInitial.Labels + } else { + canonicalDesired.Labels = rawDesired.Labels + } + if dcl.NameToSelfLink(rawDesired.Project, rawInitial.Project) { + canonicalDesired.Project = rawInitial.Project + } else { + canonicalDesired.Project = rawDesired.Project + } + if dcl.NameToSelfLink(rawDesired.Location, rawInitial.Location) { + canonicalDesired.Location = rawInitial.Location + } else { + canonicalDesired.Location = rawDesired.Location + } + return canonicalDesired, nil +} + +func canonicalizeCertificateTemplateNewState(c *Client, rawNew, rawDesired *CertificateTemplate) (*CertificateTemplate, error) { + + if dcl.IsEmptyValueIndirect(rawNew.Name) && dcl.IsEmptyValueIndirect(rawDesired.Name) { + rawNew.Name = rawDesired.Name + } else { + if dcl.PartialSelfLinkToSelfLink(rawDesired.Name, rawNew.Name) { + rawNew.Name = rawDesired.Name + } + } + + if dcl.IsEmptyValueIndirect(rawNew.PredefinedValues) && dcl.IsEmptyValueIndirect(rawDesired.PredefinedValues) { + rawNew.PredefinedValues = rawDesired.PredefinedValues + } else { + rawNew.PredefinedValues = canonicalizeNewCertificateTemplatePredefinedValues(c, rawDesired.PredefinedValues, rawNew.PredefinedValues) + } + + if dcl.IsEmptyValueIndirect(rawNew.IdentityConstraints) && dcl.IsEmptyValueIndirect(rawDesired.IdentityConstraints) { + rawNew.IdentityConstraints = rawDesired.IdentityConstraints + } else { + rawNew.IdentityConstraints = canonicalizeNewCertificateTemplateIdentityConstraints(c, rawDesired.IdentityConstraints, rawNew.IdentityConstraints) + } + + if dcl.IsEmptyValueIndirect(rawNew.PassthroughExtensions) && dcl.IsEmptyValueIndirect(rawDesired.PassthroughExtensions) { + rawNew.PassthroughExtensions = rawDesired.PassthroughExtensions + } else { + rawNew.PassthroughExtensions = canonicalizeNewCertificateTemplatePassthroughExtensions(c, rawDesired.PassthroughExtensions, rawNew.PassthroughExtensions) + } + + if dcl.IsEmptyValueIndirect(rawNew.MaximumLifetime) && dcl.IsEmptyValueIndirect(rawDesired.MaximumLifetime) { + rawNew.MaximumLifetime = rawDesired.MaximumLifetime + } else { + if dcl.StringCanonicalize(rawDesired.MaximumLifetime, rawNew.MaximumLifetime) { + rawNew.MaximumLifetime = rawDesired.MaximumLifetime + } + } + + if dcl.IsEmptyValueIndirect(rawNew.Description) && dcl.IsEmptyValueIndirect(rawDesired.Description) { + rawNew.Description = rawDesired.Description + } else { + if dcl.StringCanonicalize(rawDesired.Description, rawNew.Description) { + rawNew.Description = rawDesired.Description + } + } + + if dcl.IsEmptyValueIndirect(rawNew.CreateTime) && dcl.IsEmptyValueIndirect(rawDesired.CreateTime) { + rawNew.CreateTime = rawDesired.CreateTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.UpdateTime) && dcl.IsEmptyValueIndirect(rawDesired.UpdateTime) { + rawNew.UpdateTime = rawDesired.UpdateTime + } else { + } + + if dcl.IsEmptyValueIndirect(rawNew.Labels) && dcl.IsEmptyValueIndirect(rawDesired.Labels) { + rawNew.Labels = rawDesired.Labels + } else { + } + + rawNew.Project = rawDesired.Project + + rawNew.Location = rawDesired.Location + + return rawNew, nil +} + +func canonicalizeCertificateTemplatePredefinedValues(des, initial *CertificateTemplatePredefinedValues, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValues { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValues{} + + cDes.KeyUsage = canonicalizeCertificateTemplatePredefinedValuesKeyUsage(des.KeyUsage, initial.KeyUsage, opts...) + cDes.CaOptions = canonicalizeCertificateTemplatePredefinedValuesCaOptions(des.CaOptions, initial.CaOptions, opts...) + cDes.PolicyIds = canonicalizeCertificateTemplatePredefinedValuesPolicyIdsSlice(des.PolicyIds, initial.PolicyIds, opts...) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, initial.AiaOcspServers) { + cDes.AiaOcspServers = initial.AiaOcspServers + } else { + cDes.AiaOcspServers = des.AiaOcspServers + } + cDes.AdditionalExtensions = canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesSlice(des, initial []CertificateTemplatePredefinedValues, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValues { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValues, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValues(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValues, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValues(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValues(c *Client, des, nw *CertificateTemplatePredefinedValues) *CertificateTemplatePredefinedValues { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValues while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.KeyUsage = canonicalizeNewCertificateTemplatePredefinedValuesKeyUsage(c, des.KeyUsage, nw.KeyUsage) + nw.CaOptions = canonicalizeNewCertificateTemplatePredefinedValuesCaOptions(c, des.CaOptions, nw.CaOptions) + nw.PolicyIds = canonicalizeNewCertificateTemplatePredefinedValuesPolicyIdsSlice(c, des.PolicyIds, nw.PolicyIds) + if dcl.StringArrayCanonicalize(des.AiaOcspServers, nw.AiaOcspServers) { + nw.AiaOcspServers = des.AiaOcspServers + } + nw.AdditionalExtensions = canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesSet(c *Client, des, nw []CertificateTemplatePredefinedValues) []CertificateTemplatePredefinedValues { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValues + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValues(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesSlice(c *Client, des, nw []CertificateTemplatePredefinedValues) []CertificateTemplatePredefinedValues { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValues + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValues(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsage(des, initial *CertificateTemplatePredefinedValuesKeyUsage, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesKeyUsage{} + + cDes.BaseKeyUsage = canonicalizeCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(des.BaseKeyUsage, initial.BaseKeyUsage, opts...) + cDes.ExtendedKeyUsage = canonicalizeCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(des.ExtendedKeyUsage, initial.ExtendedKeyUsage, opts...) + cDes.UnknownExtendedKeyUsages = canonicalizeCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(des.UnknownExtendedKeyUsages, initial.UnknownExtendedKeyUsages, opts...) + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageSlice(des, initial []CertificateTemplatePredefinedValuesKeyUsage, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsage(c *Client, des, nw *CertificateTemplatePredefinedValuesKeyUsage) *CertificateTemplatePredefinedValuesKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.BaseKeyUsage = canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, des.BaseKeyUsage, nw.BaseKeyUsage) + nw.ExtendedKeyUsage = canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, des.ExtendedKeyUsage, nw.ExtendedKeyUsage) + nw.UnknownExtendedKeyUsages = canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(c, des.UnknownExtendedKeyUsages, nw.UnknownExtendedKeyUsages) + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageSet(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsage) []CertificateTemplatePredefinedValuesKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsage) []CertificateTemplatePredefinedValuesKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(des, initial *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + + if dcl.BoolCanonicalize(des.DigitalSignature, initial.DigitalSignature) || dcl.IsZeroValue(des.DigitalSignature) { + cDes.DigitalSignature = initial.DigitalSignature + } else { + cDes.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, initial.ContentCommitment) || dcl.IsZeroValue(des.ContentCommitment) { + cDes.ContentCommitment = initial.ContentCommitment + } else { + cDes.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, initial.KeyEncipherment) || dcl.IsZeroValue(des.KeyEncipherment) { + cDes.KeyEncipherment = initial.KeyEncipherment + } else { + cDes.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, initial.DataEncipherment) || dcl.IsZeroValue(des.DataEncipherment) { + cDes.DataEncipherment = initial.DataEncipherment + } else { + cDes.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, initial.KeyAgreement) || dcl.IsZeroValue(des.KeyAgreement) { + cDes.KeyAgreement = initial.KeyAgreement + } else { + cDes.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, initial.CertSign) || dcl.IsZeroValue(des.CertSign) { + cDes.CertSign = initial.CertSign + } else { + cDes.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, initial.CrlSign) || dcl.IsZeroValue(des.CrlSign) { + cDes.CrlSign = initial.CrlSign + } else { + cDes.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, initial.EncipherOnly) || dcl.IsZeroValue(des.EncipherOnly) { + cDes.EncipherOnly = initial.EncipherOnly + } else { + cDes.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, initial.DecipherOnly) || dcl.IsZeroValue(des.DecipherOnly) { + cDes.DecipherOnly = initial.DecipherOnly + } else { + cDes.DecipherOnly = des.DecipherOnly + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSlice(des, initial []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c *Client, des, nw *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.DigitalSignature, nw.DigitalSignature) { + nw.DigitalSignature = des.DigitalSignature + } + if dcl.BoolCanonicalize(des.ContentCommitment, nw.ContentCommitment) { + nw.ContentCommitment = des.ContentCommitment + } + if dcl.BoolCanonicalize(des.KeyEncipherment, nw.KeyEncipherment) { + nw.KeyEncipherment = des.KeyEncipherment + } + if dcl.BoolCanonicalize(des.DataEncipherment, nw.DataEncipherment) { + nw.DataEncipherment = des.DataEncipherment + } + if dcl.BoolCanonicalize(des.KeyAgreement, nw.KeyAgreement) { + nw.KeyAgreement = des.KeyAgreement + } + if dcl.BoolCanonicalize(des.CertSign, nw.CertSign) { + nw.CertSign = des.CertSign + } + if dcl.BoolCanonicalize(des.CrlSign, nw.CrlSign) { + nw.CrlSign = des.CrlSign + } + if dcl.BoolCanonicalize(des.EncipherOnly, nw.EncipherOnly) { + nw.EncipherOnly = des.EncipherOnly + } + if dcl.BoolCanonicalize(des.DecipherOnly, nw.DecipherOnly) { + nw.DecipherOnly = des.DecipherOnly + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSet(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(des, initial *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + + if dcl.BoolCanonicalize(des.ServerAuth, initial.ServerAuth) || dcl.IsZeroValue(des.ServerAuth) { + cDes.ServerAuth = initial.ServerAuth + } else { + cDes.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, initial.ClientAuth) || dcl.IsZeroValue(des.ClientAuth) { + cDes.ClientAuth = initial.ClientAuth + } else { + cDes.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, initial.CodeSigning) || dcl.IsZeroValue(des.CodeSigning) { + cDes.CodeSigning = initial.CodeSigning + } else { + cDes.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, initial.EmailProtection) || dcl.IsZeroValue(des.EmailProtection) { + cDes.EmailProtection = initial.EmailProtection + } else { + cDes.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, initial.TimeStamping) || dcl.IsZeroValue(des.TimeStamping) { + cDes.TimeStamping = initial.TimeStamping + } else { + cDes.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, initial.OcspSigning) || dcl.IsZeroValue(des.OcspSigning) { + cDes.OcspSigning = initial.OcspSigning + } else { + cDes.OcspSigning = des.OcspSigning + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSlice(des, initial []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c *Client, des, nw *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.ServerAuth, nw.ServerAuth) { + nw.ServerAuth = des.ServerAuth + } + if dcl.BoolCanonicalize(des.ClientAuth, nw.ClientAuth) { + nw.ClientAuth = des.ClientAuth + } + if dcl.BoolCanonicalize(des.CodeSigning, nw.CodeSigning) { + nw.CodeSigning = des.CodeSigning + } + if dcl.BoolCanonicalize(des.EmailProtection, nw.EmailProtection) { + nw.EmailProtection = des.EmailProtection + } + if dcl.BoolCanonicalize(des.TimeStamping, nw.TimeStamping) { + nw.TimeStamping = des.TimeStamping + } + if dcl.BoolCanonicalize(des.OcspSigning, nw.OcspSigning) { + nw.OcspSigning = des.OcspSigning + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSet(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(des, initial *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(des, initial []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c *Client, des, nw *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSet(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesCaOptions(des, initial *CertificateTemplatePredefinedValuesCaOptions, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesCaOptions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesCaOptions{} + + if dcl.BoolCanonicalize(des.IsCa, initial.IsCa) || dcl.IsZeroValue(des.IsCa) { + cDes.IsCa = initial.IsCa + } else { + cDes.IsCa = des.IsCa + } + if dcl.IsZeroValue(des.MaxIssuerPathLength) || (dcl.IsEmptyValueIndirect(des.MaxIssuerPathLength) && dcl.IsEmptyValueIndirect(initial.MaxIssuerPathLength)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.MaxIssuerPathLength = initial.MaxIssuerPathLength + } else { + cDes.MaxIssuerPathLength = des.MaxIssuerPathLength + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesCaOptionsSlice(des, initial []CertificateTemplatePredefinedValuesCaOptions, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesCaOptions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesCaOptions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesCaOptions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesCaOptions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesCaOptions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesCaOptions(c *Client, des, nw *CertificateTemplatePredefinedValuesCaOptions) *CertificateTemplatePredefinedValuesCaOptions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesCaOptions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.BoolCanonicalize(des.IsCa, nw.IsCa) { + nw.IsCa = des.IsCa + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesCaOptionsSet(c *Client, des, nw []CertificateTemplatePredefinedValuesCaOptions) []CertificateTemplatePredefinedValuesCaOptions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesCaOptions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesCaOptionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesCaOptions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesCaOptionsSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesCaOptions) []CertificateTemplatePredefinedValuesCaOptions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesCaOptions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesCaOptions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesPolicyIds(des, initial *CertificateTemplatePredefinedValuesPolicyIds, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesPolicyIds { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesPolicyIds{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesPolicyIdsSlice(des, initial []CertificateTemplatePredefinedValuesPolicyIds, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesPolicyIds { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesPolicyIds, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesPolicyIds(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesPolicyIds, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesPolicyIds(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesPolicyIds(c *Client, des, nw *CertificateTemplatePredefinedValuesPolicyIds) *CertificateTemplatePredefinedValuesPolicyIds { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesPolicyIds while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesPolicyIdsSet(c *Client, des, nw []CertificateTemplatePredefinedValuesPolicyIds) []CertificateTemplatePredefinedValuesPolicyIds { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesPolicyIds + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesPolicyIdsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesPolicyIds(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesPolicyIdsSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesPolicyIds) []CertificateTemplatePredefinedValuesPolicyIds { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesPolicyIds + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesPolicyIds(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensions(des, initial *CertificateTemplatePredefinedValuesAdditionalExtensions, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesAdditionalExtensions{} + + cDes.ObjectId = canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(des.ObjectId, initial.ObjectId, opts...) + if dcl.BoolCanonicalize(des.Critical, initial.Critical) || dcl.IsZeroValue(des.Critical) { + cDes.Critical = initial.Critical + } else { + cDes.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, initial.Value) || dcl.IsZeroValue(des.Value) { + cDes.Value = initial.Value + } else { + cDes.Value = des.Value + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(des, initial []CertificateTemplatePredefinedValuesAdditionalExtensions, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensions(c *Client, des, nw *CertificateTemplatePredefinedValuesAdditionalExtensions) *CertificateTemplatePredefinedValuesAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.ObjectId = canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, des.ObjectId, nw.ObjectId) + if dcl.BoolCanonicalize(des.Critical, nw.Critical) { + nw.Critical = des.Critical + } + if dcl.StringCanonicalize(des.Value, nw.Value) { + nw.Value = des.Value + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsSet(c *Client, des, nw []CertificateTemplatePredefinedValuesAdditionalExtensions) []CertificateTemplatePredefinedValuesAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesAdditionalExtensions) []CertificateTemplatePredefinedValuesAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(des, initial *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSlice(des, initial []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, opts ...dcl.ApplyOption) []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c *Client, des, nw *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSet(c *Client, des, nw []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSlice(c *Client, des, nw []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplateIdentityConstraints(des, initial *CertificateTemplateIdentityConstraints, opts ...dcl.ApplyOption) *CertificateTemplateIdentityConstraints { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplateIdentityConstraints{} + + cDes.CelExpression = canonicalizeCertificateTemplateIdentityConstraintsCelExpression(des.CelExpression, initial.CelExpression, opts...) + if dcl.BoolCanonicalize(des.AllowSubjectPassthrough, initial.AllowSubjectPassthrough) || dcl.IsZeroValue(des.AllowSubjectPassthrough) { + cDes.AllowSubjectPassthrough = initial.AllowSubjectPassthrough + } else { + cDes.AllowSubjectPassthrough = des.AllowSubjectPassthrough + } + if dcl.BoolCanonicalize(des.AllowSubjectAltNamesPassthrough, initial.AllowSubjectAltNamesPassthrough) || dcl.IsZeroValue(des.AllowSubjectAltNamesPassthrough) { + cDes.AllowSubjectAltNamesPassthrough = initial.AllowSubjectAltNamesPassthrough + } else { + cDes.AllowSubjectAltNamesPassthrough = des.AllowSubjectAltNamesPassthrough + } + + return cDes +} + +func canonicalizeCertificateTemplateIdentityConstraintsSlice(des, initial []CertificateTemplateIdentityConstraints, opts ...dcl.ApplyOption) []CertificateTemplateIdentityConstraints { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplateIdentityConstraints, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplateIdentityConstraints(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplateIdentityConstraints, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplateIdentityConstraints(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplateIdentityConstraints(c *Client, des, nw *CertificateTemplateIdentityConstraints) *CertificateTemplateIdentityConstraints { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplateIdentityConstraints while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.CelExpression = canonicalizeNewCertificateTemplateIdentityConstraintsCelExpression(c, des.CelExpression, nw.CelExpression) + if dcl.BoolCanonicalize(des.AllowSubjectPassthrough, nw.AllowSubjectPassthrough) { + nw.AllowSubjectPassthrough = des.AllowSubjectPassthrough + } + if dcl.BoolCanonicalize(des.AllowSubjectAltNamesPassthrough, nw.AllowSubjectAltNamesPassthrough) { + nw.AllowSubjectAltNamesPassthrough = des.AllowSubjectAltNamesPassthrough + } + + return nw +} + +func canonicalizeNewCertificateTemplateIdentityConstraintsSet(c *Client, des, nw []CertificateTemplateIdentityConstraints) []CertificateTemplateIdentityConstraints { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplateIdentityConstraints + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplateIdentityConstraintsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplateIdentityConstraints(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplateIdentityConstraintsSlice(c *Client, des, nw []CertificateTemplateIdentityConstraints) []CertificateTemplateIdentityConstraints { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplateIdentityConstraints + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplateIdentityConstraints(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplateIdentityConstraintsCelExpression(des, initial *CertificateTemplateIdentityConstraintsCelExpression, opts ...dcl.ApplyOption) *CertificateTemplateIdentityConstraintsCelExpression { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplateIdentityConstraintsCelExpression{} + + if dcl.StringCanonicalize(des.Expression, initial.Expression) || dcl.IsZeroValue(des.Expression) { + cDes.Expression = initial.Expression + } else { + cDes.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, initial.Title) || dcl.IsZeroValue(des.Title) { + cDes.Title = initial.Title + } else { + cDes.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, initial.Description) || dcl.IsZeroValue(des.Description) { + cDes.Description = initial.Description + } else { + cDes.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, initial.Location) || dcl.IsZeroValue(des.Location) { + cDes.Location = initial.Location + } else { + cDes.Location = des.Location + } + + return cDes +} + +func canonicalizeCertificateTemplateIdentityConstraintsCelExpressionSlice(des, initial []CertificateTemplateIdentityConstraintsCelExpression, opts ...dcl.ApplyOption) []CertificateTemplateIdentityConstraintsCelExpression { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplateIdentityConstraintsCelExpression, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplateIdentityConstraintsCelExpression(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplateIdentityConstraintsCelExpression, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplateIdentityConstraintsCelExpression(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplateIdentityConstraintsCelExpression(c *Client, des, nw *CertificateTemplateIdentityConstraintsCelExpression) *CertificateTemplateIdentityConstraintsCelExpression { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplateIdentityConstraintsCelExpression while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringCanonicalize(des.Expression, nw.Expression) { + nw.Expression = des.Expression + } + if dcl.StringCanonicalize(des.Title, nw.Title) { + nw.Title = des.Title + } + if dcl.StringCanonicalize(des.Description, nw.Description) { + nw.Description = des.Description + } + if dcl.StringCanonicalize(des.Location, nw.Location) { + nw.Location = des.Location + } + + return nw +} + +func canonicalizeNewCertificateTemplateIdentityConstraintsCelExpressionSet(c *Client, des, nw []CertificateTemplateIdentityConstraintsCelExpression) []CertificateTemplateIdentityConstraintsCelExpression { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplateIdentityConstraintsCelExpression + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplateIdentityConstraintsCelExpressionNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplateIdentityConstraintsCelExpression(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplateIdentityConstraintsCelExpressionSlice(c *Client, des, nw []CertificateTemplateIdentityConstraintsCelExpression) []CertificateTemplateIdentityConstraintsCelExpression { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplateIdentityConstraintsCelExpression + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplateIdentityConstraintsCelExpression(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePassthroughExtensions(des, initial *CertificateTemplatePassthroughExtensions, opts ...dcl.ApplyOption) *CertificateTemplatePassthroughExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePassthroughExtensions{} + + if dcl.IsZeroValue(des.KnownExtensions) || (dcl.IsEmptyValueIndirect(des.KnownExtensions) && dcl.IsEmptyValueIndirect(initial.KnownExtensions)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.KnownExtensions = initial.KnownExtensions + } else { + cDes.KnownExtensions = des.KnownExtensions + } + cDes.AdditionalExtensions = canonicalizeCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(des.AdditionalExtensions, initial.AdditionalExtensions, opts...) + + return cDes +} + +func canonicalizeCertificateTemplatePassthroughExtensionsSlice(des, initial []CertificateTemplatePassthroughExtensions, opts ...dcl.ApplyOption) []CertificateTemplatePassthroughExtensions { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePassthroughExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePassthroughExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePassthroughExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePassthroughExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePassthroughExtensions(c *Client, des, nw *CertificateTemplatePassthroughExtensions) *CertificateTemplatePassthroughExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePassthroughExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + nw.AdditionalExtensions = canonicalizeNewCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(c, des.AdditionalExtensions, nw.AdditionalExtensions) + + return nw +} + +func canonicalizeNewCertificateTemplatePassthroughExtensionsSet(c *Client, des, nw []CertificateTemplatePassthroughExtensions) []CertificateTemplatePassthroughExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePassthroughExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePassthroughExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePassthroughExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePassthroughExtensionsSlice(c *Client, des, nw []CertificateTemplatePassthroughExtensions) []CertificateTemplatePassthroughExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePassthroughExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePassthroughExtensions(c, &d, &n)) + } + + return items +} + +func canonicalizeCertificateTemplatePassthroughExtensionsAdditionalExtensions(des, initial *CertificateTemplatePassthroughExtensionsAdditionalExtensions, opts ...dcl.ApplyOption) *CertificateTemplatePassthroughExtensionsAdditionalExtensions { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &CertificateTemplatePassthroughExtensionsAdditionalExtensions{} + + if dcl.IsZeroValue(des.ObjectIdPath) || (dcl.IsEmptyValueIndirect(des.ObjectIdPath) && dcl.IsEmptyValueIndirect(initial.ObjectIdPath)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.ObjectIdPath = initial.ObjectIdPath + } else { + cDes.ObjectIdPath = des.ObjectIdPath + } + + return cDes +} + +func canonicalizeCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(des, initial []CertificateTemplatePassthroughExtensionsAdditionalExtensions, opts ...dcl.ApplyOption) []CertificateTemplatePassthroughExtensionsAdditionalExtensions { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]CertificateTemplatePassthroughExtensionsAdditionalExtensions, 0, len(des)) + for _, d := range des { + cd := canonicalizeCertificateTemplatePassthroughExtensionsAdditionalExtensions(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]CertificateTemplatePassthroughExtensionsAdditionalExtensions, 0, len(des)) + for i, d := range des { + cd := canonicalizeCertificateTemplatePassthroughExtensionsAdditionalExtensions(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewCertificateTemplatePassthroughExtensionsAdditionalExtensions(c *Client, des, nw *CertificateTemplatePassthroughExtensionsAdditionalExtensions) *CertificateTemplatePassthroughExtensionsAdditionalExtensions { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for CertificateTemplatePassthroughExtensionsAdditionalExtensions while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + return nw +} + +func canonicalizeNewCertificateTemplatePassthroughExtensionsAdditionalExtensionsSet(c *Client, des, nw []CertificateTemplatePassthroughExtensionsAdditionalExtensions) []CertificateTemplatePassthroughExtensionsAdditionalExtensions { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []CertificateTemplatePassthroughExtensionsAdditionalExtensions + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareCertificateTemplatePassthroughExtensionsAdditionalExtensionsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewCertificateTemplatePassthroughExtensionsAdditionalExtensions(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(c *Client, des, nw []CertificateTemplatePassthroughExtensionsAdditionalExtensions) []CertificateTemplatePassthroughExtensionsAdditionalExtensions { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []CertificateTemplatePassthroughExtensionsAdditionalExtensions + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewCertificateTemplatePassthroughExtensionsAdditionalExtensions(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffCertificateTemplate(c *Client, desired, actual *CertificateTemplate, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PredefinedValues, actual.PredefinedValues, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValues, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("PredefinedValues")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.IdentityConstraints, actual.IdentityConstraints, dcl.DiffInfo{ObjectFunction: compareCertificateTemplateIdentityConstraintsNewStyle, EmptyObject: EmptyCertificateTemplateIdentityConstraints, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("IdentityConstraints")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.PassthroughExtensions, actual.PassthroughExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePassthroughExtensionsNewStyle, EmptyObject: EmptyCertificateTemplatePassthroughExtensions, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("PassthroughExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaximumLifetime, actual.MaximumLifetime, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("MaximumLifetime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareCertificateTemplatePredefinedValuesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValues) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValues or *CertificateTemplatePredefinedValues", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValues) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValues) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValues", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KeyUsage, actual.KeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesKeyUsageNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesKeyUsage, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("KeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CaOptions, actual.CaOptions, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesCaOptionsNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesCaOptions, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("CaOptions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PolicyIds, actual.PolicyIds, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesPolicyIdsNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesPolicyIds, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("PolicyIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AiaOcspServers, actual.AiaOcspServers, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("AiaOcspServers")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesAdditionalExtensionsNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesAdditionalExtensions, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsage or *CertificateTemplatePredefinedValuesKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.BaseKeyUsage, actual.BaseKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("BaseKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExtendedKeyUsage, actual.ExtendedKeyUsage, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ExtendedKeyUsage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.UnknownExtendedKeyUsages, actual.UnknownExtendedKeyUsages, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("UnknownExtendedKeyUsages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage or *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DigitalSignature, actual.DigitalSignature, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("DigitalSignature")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ContentCommitment, actual.ContentCommitment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ContentCommitment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyEncipherment, actual.KeyEncipherment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("KeyEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DataEncipherment, actual.DataEncipherment, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("DataEncipherment")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.KeyAgreement, actual.KeyAgreement, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("KeyAgreement")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CertSign, actual.CertSign, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("CertSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CrlSign, actual.CrlSign, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("CrlSign")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EncipherOnly, actual.EncipherOnly, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("EncipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.DecipherOnly, actual.DecipherOnly, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("DecipherOnly")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage or *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ServerAuth, actual.ServerAuth, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ServerAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ClientAuth, actual.ClientAuth, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ClientAuth")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.CodeSigning, actual.CodeSigning, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("CodeSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.EmailProtection, actual.EmailProtection, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("EmailProtection")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.TimeStamping, actual.TimeStamping, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("TimeStamping")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.OcspSigning, actual.OcspSigning, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("OcspSigning")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages or *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesCaOptionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesCaOptions) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesCaOptions or *CertificateTemplatePredefinedValuesCaOptions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesCaOptions) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesCaOptions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesCaOptions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.IsCa, actual.IsCa, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("IsCa")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.MaxIssuerPathLength, actual.MaxIssuerPathLength, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("MaxIssuerPathLength")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesPolicyIdsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesPolicyIds) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesPolicyIds or *CertificateTemplatePredefinedValuesPolicyIds", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesPolicyIds) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesPolicyIds) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesPolicyIds", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesAdditionalExtensions or *CertificateTemplatePredefinedValuesAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectId, actual.ObjectId, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdNewStyle, EmptyObject: EmptyCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ObjectId")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Critical, actual.Critical, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Critical")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Value, actual.Value, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Value")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId or *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplateIdentityConstraintsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplateIdentityConstraints) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplateIdentityConstraints) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplateIdentityConstraints or *CertificateTemplateIdentityConstraints", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplateIdentityConstraints) + if !ok { + actualNotPointer, ok := a.(CertificateTemplateIdentityConstraints) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplateIdentityConstraints", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.CelExpression, actual.CelExpression, dcl.DiffInfo{ObjectFunction: compareCertificateTemplateIdentityConstraintsCelExpressionNewStyle, EmptyObject: EmptyCertificateTemplateIdentityConstraintsCelExpression, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("CelExpression")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowSubjectPassthrough, actual.AllowSubjectPassthrough, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("AllowSubjectPassthrough")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AllowSubjectAltNamesPassthrough, actual.AllowSubjectAltNamesPassthrough, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("AllowSubjectAltNamesPassthrough")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplateIdentityConstraintsCelExpressionNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplateIdentityConstraintsCelExpression) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplateIdentityConstraintsCelExpression) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplateIdentityConstraintsCelExpression or *CertificateTemplateIdentityConstraintsCelExpression", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplateIdentityConstraintsCelExpression) + if !ok { + actualNotPointer, ok := a.(CertificateTemplateIdentityConstraintsCelExpression) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplateIdentityConstraintsCelExpression", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Expression, actual.Expression, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Expression")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Title, actual.Title, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Title")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePassthroughExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePassthroughExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePassthroughExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePassthroughExtensions or *CertificateTemplatePassthroughExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePassthroughExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePassthroughExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePassthroughExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.KnownExtensions, actual.KnownExtensions, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("KnownExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AdditionalExtensions, actual.AdditionalExtensions, dcl.DiffInfo{ObjectFunction: compareCertificateTemplatePassthroughExtensionsAdditionalExtensionsNewStyle, EmptyObject: EmptyCertificateTemplatePassthroughExtensionsAdditionalExtensions, OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("AdditionalExtensions")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareCertificateTemplatePassthroughExtensionsAdditionalExtensionsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*CertificateTemplatePassthroughExtensionsAdditionalExtensions) + if !ok { + desiredNotPointer, ok := d.(CertificateTemplatePassthroughExtensionsAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePassthroughExtensionsAdditionalExtensions or *CertificateTemplatePassthroughExtensionsAdditionalExtensions", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*CertificateTemplatePassthroughExtensionsAdditionalExtensions) + if !ok { + actualNotPointer, ok := a.(CertificateTemplatePassthroughExtensionsAdditionalExtensions) + if !ok { + return nil, fmt.Errorf("obj %v is not a CertificateTemplatePassthroughExtensionsAdditionalExtensions", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.ObjectIdPath, actual.ObjectIdPath, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateCertificateTemplateUpdateCertificateTemplateOperation")}, fn.AddNest("ObjectIdPath")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *CertificateTemplate) urlNormalized() *CertificateTemplate { + normalized := dcl.Copy(*r).(CertificateTemplate) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.MaximumLifetime = dcl.SelfLinkToName(r.MaximumLifetime) + normalized.Description = dcl.SelfLinkToName(r.Description) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + return &normalized +} + +func (r *CertificateTemplate) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateCertificateTemplate" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the CertificateTemplate resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *CertificateTemplate) marshal(c *Client) ([]byte, error) { + m, err := expandCertificateTemplate(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling CertificateTemplate: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalCertificateTemplate decodes JSON responses into the CertificateTemplate resource schema. +func unmarshalCertificateTemplate(b []byte, c *Client, res *CertificateTemplate) (*CertificateTemplate, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapCertificateTemplate(m, c, res) +} + +func unmarshalMapCertificateTemplate(m map[string]interface{}, c *Client, res *CertificateTemplate) (*CertificateTemplate, error) { + + flattened := flattenCertificateTemplate(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandCertificateTemplate expands CertificateTemplate into a JSON request object. +func expandCertificateTemplate(c *Client, f *CertificateTemplate) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.DeriveField("projects/%s/locations/%s/certificateTemplates/%s", f.Name, dcl.SelfLinkToName(f.Project), dcl.SelfLinkToName(f.Location), dcl.SelfLinkToName(f.Name)); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v, err := expandCertificateTemplatePredefinedValues(c, f.PredefinedValues, res); err != nil { + return nil, fmt.Errorf("error expanding PredefinedValues into predefinedValues: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["predefinedValues"] = v + } + if v, err := expandCertificateTemplateIdentityConstraints(c, f.IdentityConstraints, res); err != nil { + return nil, fmt.Errorf("error expanding IdentityConstraints into identityConstraints: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["identityConstraints"] = v + } + if v, err := expandCertificateTemplatePassthroughExtensions(c, f.PassthroughExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding PassthroughExtensions into passthroughExtensions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["passthroughExtensions"] = v + } + if v := f.MaximumLifetime; dcl.ValueShouldBeSent(v) { + m["maximumLifetime"] = v + } + if v := f.Description; dcl.ValueShouldBeSent(v) { + m["description"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenCertificateTemplate flattens CertificateTemplate from a JSON request object into the +// CertificateTemplate type. +func flattenCertificateTemplate(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplate { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &CertificateTemplate{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.PredefinedValues = flattenCertificateTemplatePredefinedValues(c, m["predefinedValues"], res) + resultRes.IdentityConstraints = flattenCertificateTemplateIdentityConstraints(c, m["identityConstraints"], res) + resultRes.PassthroughExtensions = flattenCertificateTemplatePassthroughExtensions(c, m["passthroughExtensions"], res) + resultRes.MaximumLifetime = dcl.FlattenString(m["maximumLifetime"]) + resultRes.Description = dcl.FlattenString(m["description"]) + resultRes.CreateTime = dcl.FlattenString(m["createTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + + return resultRes +} + +// expandCertificateTemplatePredefinedValuesMap expands the contents of CertificateTemplatePredefinedValues into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesMap(c *Client, f map[string]CertificateTemplatePredefinedValues, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValues(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesSlice expands the contents of CertificateTemplatePredefinedValues into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesSlice(c *Client, f []CertificateTemplatePredefinedValues, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValues(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesMap flattens the contents of CertificateTemplatePredefinedValues from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValues { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValues{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValues{} + } + + items := make(map[string]CertificateTemplatePredefinedValues) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValues(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesSlice flattens the contents of CertificateTemplatePredefinedValues from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValues { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValues{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValues{} + } + + items := make([]CertificateTemplatePredefinedValues, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValues(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValues expands an instance of CertificateTemplatePredefinedValues into a JSON +// request object. +func expandCertificateTemplatePredefinedValues(c *Client, f *CertificateTemplatePredefinedValues, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateTemplatePredefinedValuesKeyUsage(c, f.KeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding KeyUsage into keyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["keyUsage"] = v + } + if v, err := expandCertificateTemplatePredefinedValuesCaOptions(c, f.CaOptions, res); err != nil { + return nil, fmt.Errorf("error expanding CaOptions into caOptions: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["caOptions"] = v + } + if v, err := expandCertificateTemplatePredefinedValuesPolicyIdsSlice(c, f.PolicyIds, res); err != nil { + return nil, fmt.Errorf("error expanding PolicyIds into policyIds: %w", err) + } else if v != nil { + m["policyIds"] = v + } + if v := f.AiaOcspServers; v != nil { + m["aiaOcspServers"] = v + } + if v, err := expandCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValues flattens an instance of CertificateTemplatePredefinedValues from a JSON +// response object. +func flattenCertificateTemplatePredefinedValues(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValues { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValues{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValues + } + r.KeyUsage = flattenCertificateTemplatePredefinedValuesKeyUsage(c, m["keyUsage"], res) + r.CaOptions = flattenCertificateTemplatePredefinedValuesCaOptions(c, m["caOptions"], res) + r.PolicyIds = flattenCertificateTemplatePredefinedValuesPolicyIdsSlice(c, m["policyIds"], res) + r.AiaOcspServers = dcl.FlattenStringSlice(m["aiaOcspServers"]) + r.AdditionalExtensions = flattenCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCertificateTemplatePredefinedValuesKeyUsageMap expands the contents of CertificateTemplatePredefinedValuesKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageMap(c *Client, f map[string]CertificateTemplatePredefinedValuesKeyUsage, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesKeyUsageSlice expands the contents of CertificateTemplatePredefinedValuesKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageSlice(c *Client, f []CertificateTemplatePredefinedValuesKeyUsage, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageMap flattens the contents of CertificateTemplatePredefinedValuesKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesKeyUsage{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageSlice flattens the contents of CertificateTemplatePredefinedValuesKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesKeyUsage{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesKeyUsage{} + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesKeyUsage expands an instance of CertificateTemplatePredefinedValuesKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsage(c *Client, f *CertificateTemplatePredefinedValuesKeyUsage, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, f.BaseKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding BaseKeyUsage into baseKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["baseKeyUsage"] = v + } + if v, err := expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, f.ExtendedKeyUsage, res); err != nil { + return nil, fmt.Errorf("error expanding ExtendedKeyUsage into extendedKeyUsage: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["extendedKeyUsage"] = v + } + if v, err := expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(c, f.UnknownExtendedKeyUsages, res); err != nil { + return nil, fmt.Errorf("error expanding UnknownExtendedKeyUsages into unknownExtendedKeyUsages: %w", err) + } else if v != nil { + m["unknownExtendedKeyUsages"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsage flattens an instance of CertificateTemplatePredefinedValuesKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsage(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesKeyUsage + } + r.BaseKeyUsage = flattenCertificateTemplateBaseKeyUsage(c, m["baseKeyUsage"], res) + r.ExtendedKeyUsage = flattenCertificateTemplateExtendedKeyUsage(c, m["extendedKeyUsage"], res) + r.UnknownExtendedKeyUsages = flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(c, m["unknownExtendedKeyUsages"], res) + + return r +} + +// expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageMap expands the contents of CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageMap(c *Client, f map[string]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSlice expands the contents of CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSlice(c *Client, f []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageMap flattens the contents of CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSlice flattens the contents of CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage expands an instance of CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c *Client, f *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DigitalSignature; !dcl.IsEmptyValueIndirect(v) { + m["digitalSignature"] = v + } + if v := f.ContentCommitment; !dcl.IsEmptyValueIndirect(v) { + m["contentCommitment"] = v + } + if v := f.KeyEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["keyEncipherment"] = v + } + if v := f.DataEncipherment; !dcl.IsEmptyValueIndirect(v) { + m["dataEncipherment"] = v + } + if v := f.KeyAgreement; !dcl.IsEmptyValueIndirect(v) { + m["keyAgreement"] = v + } + if v := f.CertSign; !dcl.IsEmptyValueIndirect(v) { + m["certSign"] = v + } + if v := f.CrlSign; !dcl.IsEmptyValueIndirect(v) { + m["crlSign"] = v + } + if v := f.EncipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["encipherOnly"] = v + } + if v := f.DecipherOnly; !dcl.IsEmptyValueIndirect(v) { + m["decipherOnly"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage flattens an instance of CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageMap expands the contents of CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageMap(c *Client, f map[string]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSlice expands the contents of CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSlice(c *Client, f []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageMap flattens the contents of CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSlice flattens the contents of CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage expands an instance of CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c *Client, f *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ServerAuth; !dcl.IsEmptyValueIndirect(v) { + m["serverAuth"] = v + } + if v := f.ClientAuth; !dcl.IsEmptyValueIndirect(v) { + m["clientAuth"] = v + } + if v := f.CodeSigning; !dcl.IsEmptyValueIndirect(v) { + m["codeSigning"] = v + } + if v := f.EmailProtection; !dcl.IsEmptyValueIndirect(v) { + m["emailProtection"] = v + } + if v := f.TimeStamping; !dcl.IsEmptyValueIndirect(v) { + m["timeStamping"] = v + } + if v := f.OcspSigning; !dcl.IsEmptyValueIndirect(v) { + m["ocspSigning"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage flattens an instance of CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +// expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesMap expands the contents of CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesMap(c *Client, f map[string]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice expands the contents of CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, f []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesMap flattens the contents of CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice flattens the contents of CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{} + } + + items := make([]CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages expands an instance of CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c *Client, f *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages flattens an instance of CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateTemplatePredefinedValuesCaOptionsMap expands the contents of CertificateTemplatePredefinedValuesCaOptions into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesCaOptionsMap(c *Client, f map[string]CertificateTemplatePredefinedValuesCaOptions, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesCaOptions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesCaOptionsSlice expands the contents of CertificateTemplatePredefinedValuesCaOptions into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesCaOptionsSlice(c *Client, f []CertificateTemplatePredefinedValuesCaOptions, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesCaOptions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesCaOptionsMap flattens the contents of CertificateTemplatePredefinedValuesCaOptions from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesCaOptionsMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesCaOptions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesCaOptions{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesCaOptions{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesCaOptions) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesCaOptions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesCaOptionsSlice flattens the contents of CertificateTemplatePredefinedValuesCaOptions from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesCaOptionsSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesCaOptions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesCaOptions{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesCaOptions{} + } + + items := make([]CertificateTemplatePredefinedValuesCaOptions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesCaOptions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesCaOptions expands an instance of CertificateTemplatePredefinedValuesCaOptions into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesCaOptions(c *Client, f *CertificateTemplatePredefinedValuesCaOptions, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + if v := f.MaxIssuerPathLength; !dcl.IsEmptyValueIndirect(v) { + m["maxIssuerPathLength"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesCaOptions flattens an instance of CertificateTemplatePredefinedValuesCaOptions from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesCaOptions(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesCaOptions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesCaOptions + } + r.IsCa = dcl.FlattenBool(m["isCa"]) + r.MaxIssuerPathLength = dcl.FlattenInteger(m["maxIssuerPathLength"]) + + return r +} + +// expandCertificateTemplatePredefinedValuesPolicyIdsMap expands the contents of CertificateTemplatePredefinedValuesPolicyIds into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesPolicyIdsMap(c *Client, f map[string]CertificateTemplatePredefinedValuesPolicyIds, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesPolicyIdsSlice expands the contents of CertificateTemplatePredefinedValuesPolicyIds into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesPolicyIdsSlice(c *Client, f []CertificateTemplatePredefinedValuesPolicyIds, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesPolicyIds(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesPolicyIdsMap flattens the contents of CertificateTemplatePredefinedValuesPolicyIds from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesPolicyIdsMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesPolicyIds { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesPolicyIds{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesPolicyIds{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesPolicyIds) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesPolicyIds(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesPolicyIdsSlice flattens the contents of CertificateTemplatePredefinedValuesPolicyIds from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesPolicyIdsSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesPolicyIds { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesPolicyIds{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesPolicyIds{} + } + + items := make([]CertificateTemplatePredefinedValuesPolicyIds, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesPolicyIds(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesPolicyIds expands an instance of CertificateTemplatePredefinedValuesPolicyIds into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesPolicyIds(c *Client, f *CertificateTemplatePredefinedValuesPolicyIds, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesPolicyIds flattens an instance of CertificateTemplatePredefinedValuesPolicyIds from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesPolicyIds(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesPolicyIds { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesPolicyIds{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesPolicyIds + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateTemplatePredefinedValuesAdditionalExtensionsMap expands the contents of CertificateTemplatePredefinedValuesAdditionalExtensions into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesAdditionalExtensionsMap(c *Client, f map[string]CertificateTemplatePredefinedValuesAdditionalExtensions, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesAdditionalExtensionsSlice expands the contents of CertificateTemplatePredefinedValuesAdditionalExtensions into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(c *Client, f []CertificateTemplatePredefinedValuesAdditionalExtensions, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesAdditionalExtensionsMap flattens the contents of CertificateTemplatePredefinedValuesAdditionalExtensions from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesAdditionalExtensionsMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesAdditionalExtensions{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesAdditionalExtensionsSlice flattens the contents of CertificateTemplatePredefinedValuesAdditionalExtensions from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesAdditionalExtensionsSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesAdditionalExtensions{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesAdditionalExtensions{} + } + + items := make([]CertificateTemplatePredefinedValuesAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesAdditionalExtensions expands an instance of CertificateTemplatePredefinedValuesAdditionalExtensions into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesAdditionalExtensions(c *Client, f *CertificateTemplatePredefinedValuesAdditionalExtensions, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, f.ObjectId, res); err != nil { + return nil, fmt.Errorf("error expanding ObjectId into objectId: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["objectId"] = v + } + if v := f.Critical; !dcl.IsEmptyValueIndirect(v) { + m["critical"] = v + } + if v := f.Value; !dcl.IsEmptyValueIndirect(v) { + m["value"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesAdditionalExtensions flattens an instance of CertificateTemplatePredefinedValuesAdditionalExtensions from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesAdditionalExtensions(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesAdditionalExtensions + } + r.ObjectId = flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, m["objectId"], res) + r.Critical = dcl.FlattenBool(m["critical"]) + r.Value = dcl.FlattenString(m["value"]) + + return r +} + +// expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdMap expands the contents of CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdMap(c *Client, f map[string]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSlice expands the contents of CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSlice(c *Client, f []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdMap flattens the contents of CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + } + + items := make(map[string]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) + for k, item := range a { + items[k] = *flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSlice flattens the contents of CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + } + + if len(a) == 0 { + return []CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + } + + items := make([]CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId expands an instance of CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId into a JSON +// request object. +func expandCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c *Client, f *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId flattens an instance of CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId from a JSON +// response object. +func flattenCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// expandCertificateTemplateIdentityConstraintsMap expands the contents of CertificateTemplateIdentityConstraints into a JSON +// request object. +func expandCertificateTemplateIdentityConstraintsMap(c *Client, f map[string]CertificateTemplateIdentityConstraints, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplateIdentityConstraints(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplateIdentityConstraintsSlice expands the contents of CertificateTemplateIdentityConstraints into a JSON +// request object. +func expandCertificateTemplateIdentityConstraintsSlice(c *Client, f []CertificateTemplateIdentityConstraints, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplateIdentityConstraints(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplateIdentityConstraintsMap flattens the contents of CertificateTemplateIdentityConstraints from a JSON +// response object. +func flattenCertificateTemplateIdentityConstraintsMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplateIdentityConstraints { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplateIdentityConstraints{} + } + + if len(a) == 0 { + return map[string]CertificateTemplateIdentityConstraints{} + } + + items := make(map[string]CertificateTemplateIdentityConstraints) + for k, item := range a { + items[k] = *flattenCertificateTemplateIdentityConstraints(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplateIdentityConstraintsSlice flattens the contents of CertificateTemplateIdentityConstraints from a JSON +// response object. +func flattenCertificateTemplateIdentityConstraintsSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplateIdentityConstraints { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplateIdentityConstraints{} + } + + if len(a) == 0 { + return []CertificateTemplateIdentityConstraints{} + } + + items := make([]CertificateTemplateIdentityConstraints, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplateIdentityConstraints(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplateIdentityConstraints expands an instance of CertificateTemplateIdentityConstraints into a JSON +// request object. +func expandCertificateTemplateIdentityConstraints(c *Client, f *CertificateTemplateIdentityConstraints, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v, err := expandCertificateTemplateIdentityConstraintsCelExpression(c, f.CelExpression, res); err != nil { + return nil, fmt.Errorf("error expanding CelExpression into celExpression: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["celExpression"] = v + } + if v := f.AllowSubjectPassthrough; !dcl.IsEmptyValueIndirect(v) { + m["allowSubjectPassthrough"] = v + } + if v := f.AllowSubjectAltNamesPassthrough; !dcl.IsEmptyValueIndirect(v) { + m["allowSubjectAltNamesPassthrough"] = v + } + + return m, nil +} + +// flattenCertificateTemplateIdentityConstraints flattens an instance of CertificateTemplateIdentityConstraints from a JSON +// response object. +func flattenCertificateTemplateIdentityConstraints(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplateIdentityConstraints { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplateIdentityConstraints{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplateIdentityConstraints + } + r.CelExpression = flattenCertificateTemplateIdentityConstraintsCelExpression(c, m["celExpression"], res) + r.AllowSubjectPassthrough = dcl.FlattenBool(m["allowSubjectPassthrough"]) + r.AllowSubjectAltNamesPassthrough = dcl.FlattenBool(m["allowSubjectAltNamesPassthrough"]) + + return r +} + +// expandCertificateTemplateIdentityConstraintsCelExpressionMap expands the contents of CertificateTemplateIdentityConstraintsCelExpression into a JSON +// request object. +func expandCertificateTemplateIdentityConstraintsCelExpressionMap(c *Client, f map[string]CertificateTemplateIdentityConstraintsCelExpression, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplateIdentityConstraintsCelExpression(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplateIdentityConstraintsCelExpressionSlice expands the contents of CertificateTemplateIdentityConstraintsCelExpression into a JSON +// request object. +func expandCertificateTemplateIdentityConstraintsCelExpressionSlice(c *Client, f []CertificateTemplateIdentityConstraintsCelExpression, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplateIdentityConstraintsCelExpression(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplateIdentityConstraintsCelExpressionMap flattens the contents of CertificateTemplateIdentityConstraintsCelExpression from a JSON +// response object. +func flattenCertificateTemplateIdentityConstraintsCelExpressionMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplateIdentityConstraintsCelExpression { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplateIdentityConstraintsCelExpression{} + } + + if len(a) == 0 { + return map[string]CertificateTemplateIdentityConstraintsCelExpression{} + } + + items := make(map[string]CertificateTemplateIdentityConstraintsCelExpression) + for k, item := range a { + items[k] = *flattenCertificateTemplateIdentityConstraintsCelExpression(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplateIdentityConstraintsCelExpressionSlice flattens the contents of CertificateTemplateIdentityConstraintsCelExpression from a JSON +// response object. +func flattenCertificateTemplateIdentityConstraintsCelExpressionSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplateIdentityConstraintsCelExpression { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplateIdentityConstraintsCelExpression{} + } + + if len(a) == 0 { + return []CertificateTemplateIdentityConstraintsCelExpression{} + } + + items := make([]CertificateTemplateIdentityConstraintsCelExpression, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplateIdentityConstraintsCelExpression(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplateIdentityConstraintsCelExpression expands an instance of CertificateTemplateIdentityConstraintsCelExpression into a JSON +// request object. +func expandCertificateTemplateIdentityConstraintsCelExpression(c *Client, f *CertificateTemplateIdentityConstraintsCelExpression, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Expression; !dcl.IsEmptyValueIndirect(v) { + m["expression"] = v + } + if v := f.Title; !dcl.IsEmptyValueIndirect(v) { + m["title"] = v + } + if v := f.Description; !dcl.IsEmptyValueIndirect(v) { + m["description"] = v + } + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + + return m, nil +} + +// flattenCertificateTemplateIdentityConstraintsCelExpression flattens an instance of CertificateTemplateIdentityConstraintsCelExpression from a JSON +// response object. +func flattenCertificateTemplateIdentityConstraintsCelExpression(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplateIdentityConstraintsCelExpression { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplateIdentityConstraintsCelExpression{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplateIdentityConstraintsCelExpression + } + r.Expression = dcl.FlattenString(m["expression"]) + r.Title = dcl.FlattenString(m["title"]) + r.Description = dcl.FlattenString(m["description"]) + r.Location = dcl.FlattenString(m["location"]) + + return r +} + +// expandCertificateTemplatePassthroughExtensionsMap expands the contents of CertificateTemplatePassthroughExtensions into a JSON +// request object. +func expandCertificateTemplatePassthroughExtensionsMap(c *Client, f map[string]CertificateTemplatePassthroughExtensions, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePassthroughExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePassthroughExtensionsSlice expands the contents of CertificateTemplatePassthroughExtensions into a JSON +// request object. +func expandCertificateTemplatePassthroughExtensionsSlice(c *Client, f []CertificateTemplatePassthroughExtensions, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePassthroughExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePassthroughExtensionsMap flattens the contents of CertificateTemplatePassthroughExtensions from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePassthroughExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePassthroughExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePassthroughExtensions{} + } + + items := make(map[string]CertificateTemplatePassthroughExtensions) + for k, item := range a { + items[k] = *flattenCertificateTemplatePassthroughExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePassthroughExtensionsSlice flattens the contents of CertificateTemplatePassthroughExtensions from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePassthroughExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePassthroughExtensions{} + } + + if len(a) == 0 { + return []CertificateTemplatePassthroughExtensions{} + } + + items := make([]CertificateTemplatePassthroughExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePassthroughExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePassthroughExtensions expands an instance of CertificateTemplatePassthroughExtensions into a JSON +// request object. +func expandCertificateTemplatePassthroughExtensions(c *Client, f *CertificateTemplatePassthroughExtensions, res *CertificateTemplate) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.KnownExtensions; v != nil { + m["knownExtensions"] = v + } + if v, err := expandCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(c, f.AdditionalExtensions, res); err != nil { + return nil, fmt.Errorf("error expanding AdditionalExtensions into additionalExtensions: %w", err) + } else if v != nil { + m["additionalExtensions"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePassthroughExtensions flattens an instance of CertificateTemplatePassthroughExtensions from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensions(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePassthroughExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePassthroughExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePassthroughExtensions + } + r.KnownExtensions = flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnumSlice(c, m["knownExtensions"], res) + r.AdditionalExtensions = flattenCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(c, m["additionalExtensions"], res) + + return r +} + +// expandCertificateTemplatePassthroughExtensionsAdditionalExtensionsMap expands the contents of CertificateTemplatePassthroughExtensionsAdditionalExtensions into a JSON +// request object. +func expandCertificateTemplatePassthroughExtensionsAdditionalExtensionsMap(c *Client, f map[string]CertificateTemplatePassthroughExtensionsAdditionalExtensions, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandCertificateTemplatePassthroughExtensionsAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice expands the contents of CertificateTemplatePassthroughExtensionsAdditionalExtensions into a JSON +// request object. +func expandCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(c *Client, f []CertificateTemplatePassthroughExtensionsAdditionalExtensions, res *CertificateTemplate) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandCertificateTemplatePassthroughExtensionsAdditionalExtensions(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenCertificateTemplatePassthroughExtensionsAdditionalExtensionsMap flattens the contents of CertificateTemplatePassthroughExtensionsAdditionalExtensions from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsAdditionalExtensionsMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePassthroughExtensionsAdditionalExtensions { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePassthroughExtensionsAdditionalExtensions{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePassthroughExtensionsAdditionalExtensions{} + } + + items := make(map[string]CertificateTemplatePassthroughExtensionsAdditionalExtensions) + for k, item := range a { + items[k] = *flattenCertificateTemplatePassthroughExtensionsAdditionalExtensions(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice flattens the contents of CertificateTemplatePassthroughExtensionsAdditionalExtensions from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsAdditionalExtensionsSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePassthroughExtensionsAdditionalExtensions { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePassthroughExtensionsAdditionalExtensions{} + } + + if len(a) == 0 { + return []CertificateTemplatePassthroughExtensionsAdditionalExtensions{} + } + + items := make([]CertificateTemplatePassthroughExtensionsAdditionalExtensions, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePassthroughExtensionsAdditionalExtensions(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandCertificateTemplatePassthroughExtensionsAdditionalExtensions expands an instance of CertificateTemplatePassthroughExtensionsAdditionalExtensions into a JSON +// request object. +func expandCertificateTemplatePassthroughExtensionsAdditionalExtensions(c *Client, f *CertificateTemplatePassthroughExtensionsAdditionalExtensions, res *CertificateTemplate) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.ObjectIdPath; v != nil { + m["objectIdPath"] = v + } + + return m, nil +} + +// flattenCertificateTemplatePassthroughExtensionsAdditionalExtensions flattens an instance of CertificateTemplatePassthroughExtensionsAdditionalExtensions from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsAdditionalExtensions(c *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePassthroughExtensionsAdditionalExtensions { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &CertificateTemplatePassthroughExtensionsAdditionalExtensions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePassthroughExtensionsAdditionalExtensions + } + r.ObjectIdPath = dcl.FlattenIntSlice(m["objectIdPath"]) + + return r +} + +// flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnumMap flattens the contents of CertificateTemplatePassthroughExtensionsKnownExtensionsEnum from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnumMap(c *Client, i interface{}, res *CertificateTemplate) map[string]CertificateTemplatePassthroughExtensionsKnownExtensionsEnum { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]CertificateTemplatePassthroughExtensionsKnownExtensionsEnum{} + } + + if len(a) == 0 { + return map[string]CertificateTemplatePassthroughExtensionsKnownExtensionsEnum{} + } + + items := make(map[string]CertificateTemplatePassthroughExtensionsKnownExtensionsEnum) + for k, item := range a { + items[k] = *flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnum(item.(interface{})) + } + + return items +} + +// flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnumSlice flattens the contents of CertificateTemplatePassthroughExtensionsKnownExtensionsEnum from a JSON +// response object. +func flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnumSlice(c *Client, i interface{}, res *CertificateTemplate) []CertificateTemplatePassthroughExtensionsKnownExtensionsEnum { + a, ok := i.([]interface{}) + if !ok { + return []CertificateTemplatePassthroughExtensionsKnownExtensionsEnum{} + } + + if len(a) == 0 { + return []CertificateTemplatePassthroughExtensionsKnownExtensionsEnum{} + } + + items := make([]CertificateTemplatePassthroughExtensionsKnownExtensionsEnum, 0, len(a)) + for _, item := range a { + items = append(items, *flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnum(item.(interface{}))) + } + + return items +} + +// flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnum asserts that an interface is a string, and returns a +// pointer to a *CertificateTemplatePassthroughExtensionsKnownExtensionsEnum with the same value as that string. +func flattenCertificateTemplatePassthroughExtensionsKnownExtensionsEnum(i interface{}) *CertificateTemplatePassthroughExtensionsKnownExtensionsEnum { + s, ok := i.(string) + if !ok { + return nil + } + + return CertificateTemplatePassthroughExtensionsKnownExtensionsEnumRef(s) +} + +// This function returns a matcher that checks whether a serialized resource matches this resource +// in its parameters (as defined by the fields in a Get, which definitionally define resource +// identity). This is useful in extracting the element from a List call. +func (r *CertificateTemplate) matcher(c *Client) func([]byte) bool { + return func(b []byte) bool { + cr, err := unmarshalCertificateTemplate(b, c, r) + if err != nil { + c.Config.Logger.Warning("failed to unmarshal provided resource in matcher.") + return false + } + nr := r.urlNormalized() + ncr := cr.urlNormalized() + c.Config.Logger.Infof("looking for %v\nin %v", nr, ncr) + + if nr.Project == nil && ncr.Project == nil { + c.Config.Logger.Info("Both Project fields null - considering equal.") + } else if nr.Project == nil || ncr.Project == nil { + c.Config.Logger.Info("Only one Project field is null - considering unequal.") + return false + } else if *nr.Project != *ncr.Project { + return false + } + if nr.Location == nil && ncr.Location == nil { + c.Config.Logger.Info("Both Location fields null - considering equal.") + } else if nr.Location == nil || ncr.Location == nil { + c.Config.Logger.Info("Only one Location field is null - considering unequal.") + return false + } else if *nr.Location != *ncr.Location { + return false + } + if nr.Name == nil && ncr.Name == nil { + c.Config.Logger.Info("Both Name fields null - considering equal.") + } else if nr.Name == nil || ncr.Name == nil { + c.Config.Logger.Info("Only one Name field is null - considering unequal.") + return false + } else if *nr.Name != *ncr.Name { + return false + } + return true + } +} + +type certificateTemplateDiff struct { + // The diff should include one or the other of RequiresRecreate or UpdateOp. + RequiresRecreate bool + UpdateOp certificateTemplateApiOperation + FieldName string // used for error logging +} + +func convertFieldDiffsToCertificateTemplateDiffs(config *dcl.Config, fds []*dcl.FieldDiff, opts []dcl.ApplyOption) ([]certificateTemplateDiff, error) { + opNamesToFieldDiffs := make(map[string][]*dcl.FieldDiff) + // Map each operation name to the field diffs associated with it. + for _, fd := range fds { + for _, ro := range fd.ResultingOperation { + if fieldDiffs, ok := opNamesToFieldDiffs[ro]; ok { + fieldDiffs = append(fieldDiffs, fd) + opNamesToFieldDiffs[ro] = fieldDiffs + } else { + config.Logger.Infof("%s required due to diff: %v", ro, fd) + opNamesToFieldDiffs[ro] = []*dcl.FieldDiff{fd} + } + } + } + var diffs []certificateTemplateDiff + // For each operation name, create a certificateTemplateDiff which contains the operation. + for opName, fieldDiffs := range opNamesToFieldDiffs { + // Use the first field diff's field name for logging required recreate error. + diff := certificateTemplateDiff{FieldName: fieldDiffs[0].FieldName} + if opName == "Recreate" { + diff.RequiresRecreate = true + } else { + apiOp, err := convertOpNameToCertificateTemplateApiOperation(opName, fieldDiffs, opts...) + if err != nil { + return diffs, err + } + diff.UpdateOp = apiOp + } + diffs = append(diffs, diff) + } + return diffs, nil +} + +func convertOpNameToCertificateTemplateApiOperation(opName string, fieldDiffs []*dcl.FieldDiff, opts ...dcl.ApplyOption) (certificateTemplateApiOperation, error) { + switch opName { + + case "updateCertificateTemplateUpdateCertificateTemplateOperation": + return &updateCertificateTemplateUpdateCertificateTemplateOperation{FieldDiffs: fieldDiffs}, nil + + default: + return nil, fmt.Errorf("no such operation with name: %v", opName) + } +} + +func extractCertificateTemplateFields(r *CertificateTemplate) error { + vPredefinedValues := r.PredefinedValues + if vPredefinedValues == nil { + // note: explicitly not the empty object. + vPredefinedValues = &CertificateTemplatePredefinedValues{} + } + if err := extractCertificateTemplatePredefinedValuesFields(r, vPredefinedValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPredefinedValues) { + r.PredefinedValues = vPredefinedValues + } + vIdentityConstraints := r.IdentityConstraints + if vIdentityConstraints == nil { + // note: explicitly not the empty object. + vIdentityConstraints = &CertificateTemplateIdentityConstraints{} + } + if err := extractCertificateTemplateIdentityConstraintsFields(r, vIdentityConstraints); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vIdentityConstraints) { + r.IdentityConstraints = vIdentityConstraints + } + vPassthroughExtensions := r.PassthroughExtensions + if vPassthroughExtensions == nil { + // note: explicitly not the empty object. + vPassthroughExtensions = &CertificateTemplatePassthroughExtensions{} + } + if err := extractCertificateTemplatePassthroughExtensionsFields(r, vPassthroughExtensions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPassthroughExtensions) { + r.PassthroughExtensions = vPassthroughExtensions + } + return nil +} +func extractCertificateTemplatePredefinedValuesFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValues) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateTemplatePredefinedValuesKeyUsage{} + } + if err := extractCertificateTemplatePredefinedValuesKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateTemplatePredefinedValuesCaOptions{} + } + if err := extractCertificateTemplatePredefinedValuesCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func extractCertificateTemplatePredefinedValuesKeyUsageFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + } + if err := extractCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func extractCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) error { + return nil +} +func extractCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) error { + return nil +} +func extractCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func extractCertificateTemplatePredefinedValuesCaOptionsFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesCaOptions) error { + return nil +} +func extractCertificateTemplatePredefinedValuesPolicyIdsFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesPolicyIds) error { + return nil +} +func extractCertificateTemplatePredefinedValuesAdditionalExtensionsFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + } + if err := extractCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func extractCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) error { + return nil +} +func extractCertificateTemplateIdentityConstraintsFields(r *CertificateTemplate, o *CertificateTemplateIdentityConstraints) error { + vCelExpression := o.CelExpression + if vCelExpression == nil { + // note: explicitly not the empty object. + vCelExpression = &CertificateTemplateIdentityConstraintsCelExpression{} + } + if err := extractCertificateTemplateIdentityConstraintsCelExpressionFields(r, vCelExpression); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCelExpression) { + o.CelExpression = vCelExpression + } + return nil +} +func extractCertificateTemplateIdentityConstraintsCelExpressionFields(r *CertificateTemplate, o *CertificateTemplateIdentityConstraintsCelExpression) error { + return nil +} +func extractCertificateTemplatePassthroughExtensionsFields(r *CertificateTemplate, o *CertificateTemplatePassthroughExtensions) error { + return nil +} +func extractCertificateTemplatePassthroughExtensionsAdditionalExtensionsFields(r *CertificateTemplate, o *CertificateTemplatePassthroughExtensionsAdditionalExtensions) error { + return nil +} + +func postReadExtractCertificateTemplateFields(r *CertificateTemplate) error { + vPredefinedValues := r.PredefinedValues + if vPredefinedValues == nil { + // note: explicitly not the empty object. + vPredefinedValues = &CertificateTemplatePredefinedValues{} + } + if err := postReadExtractCertificateTemplatePredefinedValuesFields(r, vPredefinedValues); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPredefinedValues) { + r.PredefinedValues = vPredefinedValues + } + vIdentityConstraints := r.IdentityConstraints + if vIdentityConstraints == nil { + // note: explicitly not the empty object. + vIdentityConstraints = &CertificateTemplateIdentityConstraints{} + } + if err := postReadExtractCertificateTemplateIdentityConstraintsFields(r, vIdentityConstraints); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vIdentityConstraints) { + r.IdentityConstraints = vIdentityConstraints + } + vPassthroughExtensions := r.PassthroughExtensions + if vPassthroughExtensions == nil { + // note: explicitly not the empty object. + vPassthroughExtensions = &CertificateTemplatePassthroughExtensions{} + } + if err := postReadExtractCertificateTemplatePassthroughExtensionsFields(r, vPassthroughExtensions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vPassthroughExtensions) { + r.PassthroughExtensions = vPassthroughExtensions + } + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValues) error { + vKeyUsage := o.KeyUsage + if vKeyUsage == nil { + // note: explicitly not the empty object. + vKeyUsage = &CertificateTemplatePredefinedValuesKeyUsage{} + } + if err := extractCertificateTemplatePredefinedValuesKeyUsageFields(r, vKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vKeyUsage) { + o.KeyUsage = vKeyUsage + } + vCaOptions := o.CaOptions + if vCaOptions == nil { + // note: explicitly not the empty object. + vCaOptions = &CertificateTemplatePredefinedValuesCaOptions{} + } + if err := extractCertificateTemplatePredefinedValuesCaOptionsFields(r, vCaOptions); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCaOptions) { + o.CaOptions = vCaOptions + } + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesKeyUsageFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsage) error { + vBaseKeyUsage := o.BaseKeyUsage + if vBaseKeyUsage == nil { + // note: explicitly not the empty object. + vBaseKeyUsage = &CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + } + if err := extractCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageFields(r, vBaseKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vBaseKeyUsage) { + o.BaseKeyUsage = vBaseKeyUsage + } + vExtendedKeyUsage := o.ExtendedKeyUsage + if vExtendedKeyUsage == nil { + // note: explicitly not the empty object. + vExtendedKeyUsage = &CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + } + if err := extractCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageFields(r, vExtendedKeyUsage); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vExtendedKeyUsage) { + o.ExtendedKeyUsage = vExtendedKeyUsage + } + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) error { + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) error { + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) error { + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesCaOptionsFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesCaOptions) error { + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesPolicyIdsFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesPolicyIds) error { + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesAdditionalExtensionsFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesAdditionalExtensions) error { + vObjectId := o.ObjectId + if vObjectId == nil { + // note: explicitly not the empty object. + vObjectId = &CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{} + } + if err := extractCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdFields(r, vObjectId); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vObjectId) { + o.ObjectId = vObjectId + } + return nil +} +func postReadExtractCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdFields(r *CertificateTemplate, o *CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) error { + return nil +} +func postReadExtractCertificateTemplateIdentityConstraintsFields(r *CertificateTemplate, o *CertificateTemplateIdentityConstraints) error { + vCelExpression := o.CelExpression + if vCelExpression == nil { + // note: explicitly not the empty object. + vCelExpression = &CertificateTemplateIdentityConstraintsCelExpression{} + } + if err := extractCertificateTemplateIdentityConstraintsCelExpressionFields(r, vCelExpression); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vCelExpression) { + o.CelExpression = vCelExpression + } + return nil +} +func postReadExtractCertificateTemplateIdentityConstraintsCelExpressionFields(r *CertificateTemplate, o *CertificateTemplateIdentityConstraintsCelExpression) error { + return nil +} +func postReadExtractCertificateTemplatePassthroughExtensionsFields(r *CertificateTemplate, o *CertificateTemplatePassthroughExtensions) error { + return nil +} +func postReadExtractCertificateTemplatePassthroughExtensionsAdditionalExtensionsFields(r *CertificateTemplate, o *CertificateTemplatePassthroughExtensionsAdditionalExtensions) error { + return nil +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_schema.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_schema.go new file mode 100644 index 00000000000..2164e11b9c8 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_schema.go @@ -0,0 +1,543 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +package privateca + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +func DCLCertificateTemplateSchema() *dcl.Schema { + return &dcl.Schema{ + Info: &dcl.Info{ + Title: "Privateca/CertificateTemplate", + Description: "Certificate Authority Service provides reusable and parameterized templates that you can use for common certificate issuance scenarios. A certificate template represents a relatively static and well-defined certificate issuance schema within an organization. A certificate template can essentially become a full-fledged vertical certificate issuance framework.", + StructName: "CertificateTemplate", + Reference: &dcl.Link{ + Text: "REST API", + URL: "https://cloud.google.com/certificate-authority-service/docs/reference/rest/v1/projects.locations.certificateTemplates", + }, + Guides: []*dcl.Link{ + &dcl.Link{ + Text: "Understanding Certificate Templates", + URL: "https://cloud.google.com/certificate-authority-service/docs/certificate-template", + }, + &dcl.Link{ + Text: "Common configurations and Certificate Profiles", + URL: "https://cloud.google.com/certificate-authority-service/docs/certificate-profile", + }, + }, + }, + Paths: &dcl.Paths{ + Get: &dcl.Path{ + Description: "The function used to get information about a CertificateTemplate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificateTemplate", + Required: true, + Description: "A full instance of a CertificateTemplate", + }, + }, + }, + Apply: &dcl.Path{ + Description: "The function used to apply information about a CertificateTemplate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificateTemplate", + Required: true, + Description: "A full instance of a CertificateTemplate", + }, + }, + }, + Delete: &dcl.Path{ + Description: "The function used to delete a CertificateTemplate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "certificateTemplate", + Required: true, + Description: "A full instance of a CertificateTemplate", + }, + }, + }, + DeleteAll: &dcl.Path{ + Description: "The function used to delete all CertificateTemplate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + List: &dcl.Path{ + Description: "The function used to list information about many CertificateTemplate", + Parameters: []dcl.PathParameters{ + dcl.PathParameters{ + Name: "project", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + dcl.PathParameters{ + Name: "location", + Required: true, + Schema: &dcl.PathParametersSchema{ + Type: "string", + }, + }, + }, + }, + }, + Components: &dcl.Components{ + Schemas: map[string]*dcl.Component{ + "CertificateTemplate": &dcl.Component{ + Title: "CertificateTemplate", + ID: "projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}", + ParentContainer: "project", + LabelsField: "labels", + HasCreate: true, + SchemaProperty: dcl.Property{ + Type: "object", + Required: []string{ + "name", + "project", + "location", + }, + Properties: map[string]*dcl.Property{ + "createTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "CreateTime", + ReadOnly: true, + Description: "Output only. The time at which this CertificateTemplate was created.", + Immutable: true, + }, + "description": &dcl.Property{ + Type: "string", + GoName: "Description", + Description: "Optional. A human-readable description of scenarios this template is intended for.", + }, + "identityConstraints": &dcl.Property{ + Type: "object", + GoName: "IdentityConstraints", + GoType: "CertificateTemplateIdentityConstraints", + Description: "Optional. Describes constraints on identities that may be appear in Certificates issued using this template. If this is omitted, then this template will not add restrictions on a certificate's identity.", + Required: []string{ + "allowSubjectPassthrough", + "allowSubjectAltNamesPassthrough", + }, + Properties: map[string]*dcl.Property{ + "allowSubjectAltNamesPassthrough": &dcl.Property{ + Type: "boolean", + GoName: "AllowSubjectAltNamesPassthrough", + Description: "Required. If this is true, the SubjectAltNames extension may be copied from a certificate request into the signed certificate. Otherwise, the requested SubjectAltNames will be discarded.", + }, + "allowSubjectPassthrough": &dcl.Property{ + Type: "boolean", + GoName: "AllowSubjectPassthrough", + Description: "Required. If this is true, the Subject field may be copied from a certificate request into the signed certificate. Otherwise, the requested Subject will be discarded.", + }, + "celExpression": &dcl.Property{ + Type: "object", + GoName: "CelExpression", + GoType: "CertificateTemplateIdentityConstraintsCelExpression", + Description: "Optional. A CEL expression that may be used to validate the resolved X.509 Subject and/or Subject Alternative Name before a certificate is signed. To see the full allowed syntax and some examples, see https://cloud.google.com/certificate-authority-service/docs/using-cel", + Properties: map[string]*dcl.Property{ + "description": &dcl.Property{ + Type: "string", + GoName: "Description", + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, + "expression": &dcl.Property{ + Type: "string", + GoName: "Expression", + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, + "title": &dcl.Property{ + Type: "string", + GoName: "Title", + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, + }, + }, + }, + "labels": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "string", + }, + GoName: "Labels", + Description: "Optional. Labels with user-defined metadata.", + }, + "location": &dcl.Property{ + Type: "string", + GoName: "Location", + Description: "The location for the resource", + Immutable: true, + Parameter: true, + }, + "maximumLifetime": &dcl.Property{ + Type: "string", + GoName: "MaximumLifetime", + Description: "Optional. The maximum lifetime allowed for all issued certificates that use this template. If the issuing CaPool's IssuancePolicy specifies a maximum lifetime the minimum of the two durations will be the maximum lifetime for issued. Note that if the issuing CertificateAuthority expires before a Certificate's requested maximum_lifetime, the effective lifetime will be explicitly truncated to match it.", + }, + "name": &dcl.Property{ + Type: "string", + GoName: "Name", + Description: "The resource name for this CertificateTemplate in the format `projects/*/locations/*/certificateTemplates/*`.", + Immutable: true, + HasLongForm: true, + }, + "passthroughExtensions": &dcl.Property{ + Type: "object", + GoName: "PassthroughExtensions", + GoType: "CertificateTemplatePassthroughExtensions", + Description: "Optional. Describes the set of X.509 extensions that may appear in a Certificate issued using this CertificateTemplate. If a certificate request sets extensions that don't appear in the passthrough_extensions, those extensions will be dropped. If the issuing CaPool's IssuancePolicy defines baseline_values that don't appear here, the certificate issuance request will fail. If this is omitted, then this template will not add restrictions on a certificate's X.509 extensions. These constraints do not apply to X.509 extensions set in this CertificateTemplate's predefined_values.", + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. A set of ObjectIds identifying custom X.509 extensions. Will be combined with known_extensions to determine the full set of X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateTemplatePassthroughExtensionsAdditionalExtensions", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + "knownExtensions": &dcl.Property{ + Type: "array", + GoName: "KnownExtensions", + Description: "Optional. A set of named X.509 extensions. Will be combined with additional_extensions to determine the full set of X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "CertificateTemplatePassthroughExtensionsKnownExtensionsEnum", + Enum: []string{ + "KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED", + "BASE_KEY_USAGE", + "EXTENDED_KEY_USAGE", + "CA_OPTIONS", + "POLICY_IDS", + "AIA_OCSP_SERVERS", + }, + }, + }, + }, + }, + "predefinedValues": &dcl.Property{ + Type: "object", + GoName: "PredefinedValues", + GoType: "CertificateTemplatePredefinedValues", + Description: "Optional. A set of X.509 values that will be applied to all issued certificates that use this template. If the certificate request includes conflicting values for the same properties, they will be overwritten by the values defined here. If the issuing CaPool's IssuancePolicy defines conflicting baseline_values for the same properties, the certificate issuance request will fail.", + Properties: map[string]*dcl.Property{ + "additionalExtensions": &dcl.Property{ + Type: "array", + GoName: "AdditionalExtensions", + Description: "Optional. Describes custom X.509 extensions.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateTemplatePredefinedValuesAdditionalExtensions", + Required: []string{ + "objectId", + "value", + }, + Properties: map[string]*dcl.Property{ + "critical": &dcl.Property{ + Type: "boolean", + GoName: "Critical", + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + }, + "objectId": &dcl.Property{ + Type: "object", + GoName: "ObjectId", + GoType: "CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId", + Description: "Required. The OID for this X.509 extension.", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + "value": &dcl.Property{ + Type: "string", + GoName: "Value", + Description: "Required. The value of this X.509 extension.", + }, + }, + }, + }, + "aiaOcspServers": &dcl.Property{ + Type: "array", + GoName: "AiaOcspServers", + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "caOptions": &dcl.Property{ + Type: "object", + GoName: "CaOptions", + GoType: "CertificateTemplatePredefinedValuesCaOptions", + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + Properties: map[string]*dcl.Property{ + "isCa": &dcl.Property{ + Type: "boolean", + GoName: "IsCa", + Description: "Optional. Refers to the \"CA\" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.", + }, + "maxIssuerPathLength": &dcl.Property{ + Type: "integer", + Format: "int64", + GoName: "MaxIssuerPathLength", + Description: "Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.", + }, + }, + }, + "keyUsage": &dcl.Property{ + Type: "object", + GoName: "KeyUsage", + GoType: "CertificateTemplatePredefinedValuesKeyUsage", + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + Properties: map[string]*dcl.Property{ + "baseKeyUsage": &dcl.Property{ + Type: "object", + GoName: "BaseKeyUsage", + GoType: "CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage", + Description: "Describes high-level ways in which a key may be used.", + Properties: map[string]*dcl.Property{ + "certSign": &dcl.Property{ + Type: "boolean", + GoName: "CertSign", + Description: "The key may be used to sign certificates.", + }, + "contentCommitment": &dcl.Property{ + Type: "boolean", + GoName: "ContentCommitment", + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + }, + "crlSign": &dcl.Property{ + Type: "boolean", + GoName: "CrlSign", + Description: "The key may be used sign certificate revocation lists.", + }, + "dataEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "DataEncipherment", + Description: "The key may be used to encipher data.", + }, + "decipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "DecipherOnly", + Description: "The key may be used to decipher only.", + }, + "digitalSignature": &dcl.Property{ + Type: "boolean", + GoName: "DigitalSignature", + Description: "The key may be used for digital signatures.", + }, + "encipherOnly": &dcl.Property{ + Type: "boolean", + GoName: "EncipherOnly", + Description: "The key may be used to encipher only.", + }, + "keyAgreement": &dcl.Property{ + Type: "boolean", + GoName: "KeyAgreement", + Description: "The key may be used in a key agreement protocol.", + }, + "keyEncipherment": &dcl.Property{ + Type: "boolean", + GoName: "KeyEncipherment", + Description: "The key may be used to encipher other keys.", + }, + }, + }, + "extendedKeyUsage": &dcl.Property{ + Type: "object", + GoName: "ExtendedKeyUsage", + GoType: "CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage", + Description: "Detailed scenarios in which a key may be used.", + Properties: map[string]*dcl.Property{ + "clientAuth": &dcl.Property{ + Type: "boolean", + GoName: "ClientAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + }, + "codeSigning": &dcl.Property{ + Type: "boolean", + GoName: "CodeSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + }, + "emailProtection": &dcl.Property{ + Type: "boolean", + GoName: "EmailProtection", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + }, + "ocspSigning": &dcl.Property{ + Type: "boolean", + GoName: "OcspSigning", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + }, + "serverAuth": &dcl.Property{ + Type: "boolean", + GoName: "ServerAuth", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + }, + "timeStamping": &dcl.Property{ + Type: "boolean", + GoName: "TimeStamping", + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + }, + }, + }, + "unknownExtendedKeyUsages": &dcl.Property{ + Type: "array", + GoName: "UnknownExtendedKeyUsages", + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "policyIds": &dcl.Property{ + Type: "array", + GoName: "PolicyIds", + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "CertificateTemplatePredefinedValuesPolicyIds", + Required: []string{ + "objectIdPath", + }, + Properties: map[string]*dcl.Property{ + "objectIdPath": &dcl.Property{ + Type: "array", + GoName: "ObjectIdPath", + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "integer", + Format: "int64", + GoType: "int64", + }, + }, + }, + }, + }, + }, + }, + "project": &dcl.Property{ + Type: "string", + GoName: "Project", + Description: "The project for the resource", + Immutable: true, + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Cloudresourcemanager/Project", + Field: "name", + Parent: true, + }, + }, + Parameter: true, + }, + "updateTime": &dcl.Property{ + Type: "string", + Format: "date-time", + GoName: "UpdateTime", + ReadOnly: true, + Description: "Output only. The time at which this CertificateTemplate was updated.", + Immutable: true, + }, + }, + }, + }, + }, + }, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_yaml_embed.go new file mode 100644 index 00000000000..9ae6aad1917 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_template_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package privateca -var YAML_certificate_template blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/certificate_template.yaml + +package privateca + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/certificate_template.yaml +var YAML_certificate_template = []byte("info:\n title: Privateca/CertificateTemplate\n description: Certificate Authority Service provides reusable and parameterized templates\n that you can use for common certificate issuance scenarios. A certificate template\n represents a relatively static and well-defined certificate issuance schema within\n an organization. A certificate template can essentially become a full-fledged\n vertical certificate issuance framework.\n x-dcl-struct-name: CertificateTemplate\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/certificate-authority-service/docs/reference/rest/v1/projects.locations.certificateTemplates\n x-dcl-guides:\n - text: Understanding Certificate Templates\n url: https://cloud.google.com/certificate-authority-service/docs/certificate-template\n - text: Common configurations and Certificate Profiles\n url: https://cloud.google.com/certificate-authority-service/docs/certificate-profile\npaths:\n get:\n description: The function used to get information about a CertificateTemplate\n parameters:\n - name: certificateTemplate\n required: true\n description: A full instance of a CertificateTemplate\n apply:\n description: The function used to apply information about a CertificateTemplate\n parameters:\n - name: certificateTemplate\n required: true\n description: A full instance of a CertificateTemplate\n delete:\n description: The function used to delete a CertificateTemplate\n parameters:\n - name: certificateTemplate\n required: true\n description: A full instance of a CertificateTemplate\n deleteAll:\n description: The function used to delete all CertificateTemplate\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many CertificateTemplate\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n CertificateTemplate:\n title: CertificateTemplate\n x-dcl-id: projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}\n x-dcl-parent-container: project\n x-dcl-labels: labels\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. The time at which this CertificateTemplate was\n created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. A human-readable description of scenarios this template\n is intended for.\n identityConstraints:\n type: object\n x-dcl-go-name: IdentityConstraints\n x-dcl-go-type: CertificateTemplateIdentityConstraints\n description: Optional. Describes constraints on identities that may be appear\n in Certificates issued using this template. If this is omitted, then this\n template will not add restrictions on a certificate's identity.\n required:\n - allowSubjectPassthrough\n - allowSubjectAltNamesPassthrough\n properties:\n allowSubjectAltNamesPassthrough:\n type: boolean\n x-dcl-go-name: AllowSubjectAltNamesPassthrough\n description: Required. If this is true, the SubjectAltNames extension\n may be copied from a certificate request into the signed certificate.\n Otherwise, the requested SubjectAltNames will be discarded.\n allowSubjectPassthrough:\n type: boolean\n x-dcl-go-name: AllowSubjectPassthrough\n description: Required. If this is true, the Subject field may be copied\n from a certificate request into the signed certificate. Otherwise,\n the requested Subject will be discarded.\n celExpression:\n type: object\n x-dcl-go-name: CelExpression\n x-dcl-go-type: CertificateTemplateIdentityConstraintsCelExpression\n description: Optional. A CEL expression that may be used to validate\n the resolved X.509 Subject and/or Subject Alternative Name before\n a certificate is signed. To see the full allowed syntax and some examples,\n see https://cloud.google.com/certificate-authority-service/docs/using-cel\n properties:\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the expression. This is a\n longer text which describes the expression, e.g. when hovered\n over it in a UI.\n expression:\n type: string\n x-dcl-go-name: Expression\n description: Textual representation of an expression in Common Expression\n Language syntax.\n location:\n type: string\n x-dcl-go-name: Location\n description: Optional. String indicating the location of the expression\n for error reporting, e.g. a file name and a position in the file.\n title:\n type: string\n x-dcl-go-name: Title\n description: Optional. Title for the expression, i.e. a short string\n describing its purpose. This can be used e.g. in UIs which allow\n to enter the expression.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: Optional. Labels with user-defined metadata.\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n maximumLifetime:\n type: string\n x-dcl-go-name: MaximumLifetime\n description: Optional. The maximum lifetime allowed for all issued certificates\n that use this template. If the issuing CaPool's IssuancePolicy specifies\n a maximum lifetime the minimum of the two durations will be the maximum\n lifetime for issued. Note that if the issuing CertificateAuthority expires\n before a Certificate's requested maximum_lifetime, the effective lifetime\n will be explicitly truncated to match it.\n name:\n type: string\n x-dcl-go-name: Name\n description: The resource name for this CertificateTemplate in the format\n `projects/*/locations/*/certificateTemplates/*`.\n x-kubernetes-immutable: true\n x-dcl-has-long-form: true\n passthroughExtensions:\n type: object\n x-dcl-go-name: PassthroughExtensions\n x-dcl-go-type: CertificateTemplatePassthroughExtensions\n description: Optional. Describes the set of X.509 extensions that may appear\n in a Certificate issued using this CertificateTemplate. If a certificate\n request sets extensions that don't appear in the passthrough_extensions,\n those extensions will be dropped. If the issuing CaPool's IssuancePolicy\n defines baseline_values that don't appear here, the certificate issuance\n request will fail. If this is omitted, then this template will not add\n restrictions on a certificate's X.509 extensions. These constraints do\n not apply to X.509 extensions set in this CertificateTemplate's predefined_values.\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. A set of ObjectIds identifying custom X.509 extensions.\n Will be combined with known_extensions to determine the full set of\n X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateTemplatePassthroughExtensionsAdditionalExtensions\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most significant\n parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n knownExtensions:\n type: array\n x-dcl-go-name: KnownExtensions\n description: Optional. A set of named X.509 extensions. Will be combined\n with additional_extensions to determine the full set of X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: CertificateTemplatePassthroughExtensionsKnownExtensionsEnum\n enum:\n - KNOWN_CERTIFICATE_EXTENSION_UNSPECIFIED\n - BASE_KEY_USAGE\n - EXTENDED_KEY_USAGE\n - CA_OPTIONS\n - POLICY_IDS\n - AIA_OCSP_SERVERS\n predefinedValues:\n type: object\n x-dcl-go-name: PredefinedValues\n x-dcl-go-type: CertificateTemplatePredefinedValues\n description: Optional. A set of X.509 values that will be applied to all\n issued certificates that use this template. If the certificate request\n includes conflicting values for the same properties, they will be overwritten\n by the values defined here. If the issuing CaPool's IssuancePolicy defines\n conflicting baseline_values for the same properties, the certificate issuance\n request will fail.\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. Describes custom X.509 extensions.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateTemplatePredefinedValuesAdditionalExtensions\n required:\n - objectId\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to handle\n this extension, the client should consider this to be an error).\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId\n description: Required. The OID for this X.509 extension.\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n aiaOcspServers:\n type: array\n x-dcl-go-name: AiaOcspServers\n description: Optional. Describes Online Certificate Status Protocol\n (OCSP) endpoint addresses that appear in the \"Authority Information\n Access\" extension in the certificate.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caOptions:\n type: object\n x-dcl-go-name: CaOptions\n x-dcl-go-type: CertificateTemplatePredefinedValuesCaOptions\n description: Optional. Describes options in this X509Parameters that\n are relevant in a CA certificate.\n properties:\n isCa:\n type: boolean\n x-dcl-go-name: IsCa\n description: Optional. Refers to the \"CA\" X.509 extension, which\n is a boolean value. When this value is missing, the extension\n will be omitted from the CA certificate.\n maxIssuerPathLength:\n type: integer\n format: int64\n x-dcl-go-name: MaxIssuerPathLength\n description: Optional. Refers to the path length restriction X.509\n extension. For a CA certificate, this value describes the depth\n of subordinate CA certificates that are allowed. If this value\n is less than 0, the request will fail. If this value is missing,\n the max path length will be omitted from the CA certificate.\n keyUsage:\n type: object\n x-dcl-go-name: KeyUsage\n x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsage\n description: Optional. Indicates the intended use for keys that correspond\n to a certificate.\n properties:\n baseKeyUsage:\n type: object\n x-dcl-go-name: BaseKeyUsage\n x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage\n description: Describes high-level ways in which a key may be used.\n properties:\n certSign:\n type: boolean\n x-dcl-go-name: CertSign\n description: The key may be used to sign certificates.\n contentCommitment:\n type: boolean\n x-dcl-go-name: ContentCommitment\n description: The key may be used for cryptographic commitments.\n Note that this may also be referred to as \"non-repudiation\".\n crlSign:\n type: boolean\n x-dcl-go-name: CrlSign\n description: The key may be used sign certificate revocation\n lists.\n dataEncipherment:\n type: boolean\n x-dcl-go-name: DataEncipherment\n description: The key may be used to encipher data.\n decipherOnly:\n type: boolean\n x-dcl-go-name: DecipherOnly\n description: The key may be used to decipher only.\n digitalSignature:\n type: boolean\n x-dcl-go-name: DigitalSignature\n description: The key may be used for digital signatures.\n encipherOnly:\n type: boolean\n x-dcl-go-name: EncipherOnly\n description: The key may be used to encipher only.\n keyAgreement:\n type: boolean\n x-dcl-go-name: KeyAgreement\n description: The key may be used in a key agreement protocol.\n keyEncipherment:\n type: boolean\n x-dcl-go-name: KeyEncipherment\n description: The key may be used to encipher other keys.\n extendedKeyUsage:\n type: object\n x-dcl-go-name: ExtendedKeyUsage\n x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage\n description: Detailed scenarios in which a key may be used.\n properties:\n clientAuth:\n type: boolean\n x-dcl-go-name: ClientAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially\n described as \"TLS WWW client authentication\", though regularly\n used for non-WWW TLS.\n codeSigning:\n type: boolean\n x-dcl-go-name: CodeSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially\n described as \"Signing of downloadable executable code client\n authentication\".\n emailProtection:\n type: boolean\n x-dcl-go-name: EmailProtection\n description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially\n described as \"Email protection\".\n ocspSigning:\n type: boolean\n x-dcl-go-name: OcspSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially\n described as \"Signing OCSP responses\".\n serverAuth:\n type: boolean\n x-dcl-go-name: ServerAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially\n described as \"TLS WWW server authentication\", though regularly\n used for non-WWW TLS.\n timeStamping:\n type: boolean\n x-dcl-go-name: TimeStamping\n description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially\n described as \"Binding the hash of an object to a time\".\n unknownExtendedKeyUsages:\n type: array\n x-dcl-go-name: UnknownExtendedKeyUsages\n description: Used to describe extended key usages that are not listed\n in the KeyUsage.ExtendedKeyUsageOptions message.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n policyIds:\n type: array\n x-dcl-go-name: PolicyIds\n description: Optional. Describes the X.509 certificate policy object\n identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateTemplatePredefinedValuesPolicyIds\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most significant\n parts of the path come first.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. The time at which this CertificateTemplate was\n updated.\n x-kubernetes-immutable: true\n") + +// 21678 bytes +// MD5: c29cea95b323f1099b7839764f9ea279 diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_yaml_embed.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_yaml_embed.go new file mode 100644 index 00000000000..8c38011f614 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/certificate_yaml_embed.go @@ -0,0 +1,23 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// GENERATED BY gen_go_data.go +// gen_go_data -package privateca -var YAML_certificate blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/certificate.yaml + +package privateca + +// blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/privateca/certificate.yaml +var YAML_certificate = []byte("info:\n title: Privateca/Certificate\n description: The Privateca Certificate resource\n x-dcl-struct-name: Certificate\n x-dcl-has-iam: false\npaths:\n get:\n description: The function used to get information about a Certificate\n parameters:\n - name: certificate\n required: true\n description: A full instance of a Certificate\n apply:\n description: The function used to apply information about a Certificate\n parameters:\n - name: certificate\n required: true\n description: A full instance of a Certificate\n delete:\n description: The function used to delete a Certificate\n parameters:\n - name: certificate\n required: true\n description: A full instance of a Certificate\n deleteAll:\n description: The function used to delete all Certificate\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n - name: caPool\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Certificate\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n - name: caPool\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Certificate:\n title: Certificate\n x-dcl-id: projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificates/{{name}}\n x-dcl-parent-container: project\n x-dcl-labels: labels\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - lifetime\n - project\n - location\n - caPool\n properties:\n caPool:\n type: string\n x-dcl-go-name: CaPool\n description: The ca_pool for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Privateca/CaPool\n field: name\n parent: true\n x-dcl-parameter: true\n certificateAuthority:\n type: string\n x-dcl-go-name: CertificateAuthority\n description: The certificate authority for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Privateca/CertificateAuthority\n field: name\n x-dcl-parameter: true\n certificateDescription:\n type: object\n x-dcl-go-name: CertificateDescription\n x-dcl-go-type: CertificateCertificateDescription\n readOnly: true\n description: Output only. A structured description of the issued X.509 certificate.\n x-kubernetes-immutable: true\n properties:\n aiaIssuingCertificateUrls:\n type: array\n x-dcl-go-name: AiaIssuingCertificateUrls\n description: Describes lists of issuer CA certificate URLs that appear\n in the \"Authority Information Access\" extension in the certificate.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n authorityKeyId:\n type: object\n x-dcl-go-name: AuthorityKeyId\n x-dcl-go-type: CertificateCertificateDescriptionAuthorityKeyId\n description: Identifies the subject_key_id of the parent certificate,\n per https://tools.ietf.org/html/rfc5280#section-4.2.1.1\n x-kubernetes-immutable: true\n properties:\n keyId:\n type: string\n x-dcl-go-name: KeyId\n description: Optional. The value of this KeyId encoded in lowercase\n hexadecimal. This is most likely the 160 bit SHA-1 hash of the\n public key.\n x-kubernetes-immutable: true\n certFingerprint:\n type: object\n x-dcl-go-name: CertFingerprint\n x-dcl-go-type: CertificateCertificateDescriptionCertFingerprint\n description: The hash of the x.509 certificate.\n x-kubernetes-immutable: true\n properties:\n sha256Hash:\n type: string\n x-dcl-go-name: Sha256Hash\n description: The SHA 256 hash, encoded in hexadecimal, of the DER\n x509 certificate.\n x-kubernetes-immutable: true\n crlDistributionPoints:\n type: array\n x-dcl-go-name: CrlDistributionPoints\n description: Describes a list of locations to obtain CRL information,\n i.e. the DistributionPoint.fullName described by https://tools.ietf.org/html/rfc5280#section-4.2.1.13\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n publicKey:\n type: object\n x-dcl-go-name: PublicKey\n x-dcl-go-type: CertificateCertificateDescriptionPublicKey\n description: The public key that corresponds to an issued certificate.\n x-kubernetes-immutable: true\n properties:\n format:\n type: string\n x-dcl-go-name: Format\n x-dcl-go-type: CertificateCertificateDescriptionPublicKeyFormatEnum\n description: 'Required. The format of the public key. Possible values:\n KEY_FORMAT_UNSPECIFIED, PEM'\n x-kubernetes-immutable: true\n enum:\n - KEY_FORMAT_UNSPECIFIED\n - PEM\n key:\n type: string\n x-dcl-go-name: Key\n description: Required. A public key. The padding and encoding must\n match with the `KeyFormat` value specified for the `format` field.\n x-kubernetes-immutable: true\n subjectDescription:\n type: object\n x-dcl-go-name: SubjectDescription\n x-dcl-go-type: CertificateCertificateDescriptionSubjectDescription\n description: Describes some of the values in a certificate that are\n related to the subject and lifetime.\n x-kubernetes-immutable: true\n properties:\n hexSerialNumber:\n type: string\n x-dcl-go-name: HexSerialNumber\n description: The serial number encoded in lowercase hexadecimal.\n x-kubernetes-immutable: true\n lifetime:\n type: string\n x-dcl-go-name: Lifetime\n description: For convenience, the actual lifetime of an issued certificate.\n x-kubernetes-immutable: true\n notAfterTime:\n type: string\n format: date-time\n x-dcl-go-name: NotAfterTime\n description: The time after which the certificate is expired. Per\n RFC 5280, the validity period for a certificate is the period\n of time from not_before_time through not_after_time, inclusive.\n Corresponds to 'not_before_time' + 'lifetime' - 1 second.\n x-kubernetes-immutable: true\n notBeforeTime:\n type: string\n format: date-time\n x-dcl-go-name: NotBeforeTime\n description: The time at which the certificate becomes valid.\n x-kubernetes-immutable: true\n subject:\n type: object\n x-dcl-go-name: Subject\n x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubject\n description: Contains distinguished name fields such as the common\n name, location and / organization.\n x-kubernetes-immutable: true\n properties:\n commonName:\n type: string\n x-dcl-go-name: CommonName\n description: The \"common name\" of the subject.\n x-kubernetes-immutable: true\n countryCode:\n type: string\n x-dcl-go-name: CountryCode\n description: The country code of the subject.\n x-kubernetes-immutable: true\n locality:\n type: string\n x-dcl-go-name: Locality\n description: The locality or city of the subject.\n x-kubernetes-immutable: true\n organization:\n type: string\n x-dcl-go-name: Organization\n description: The organization of the subject.\n x-kubernetes-immutable: true\n organizationalUnit:\n type: string\n x-dcl-go-name: OrganizationalUnit\n description: The organizational_unit of the subject.\n x-kubernetes-immutable: true\n postalCode:\n type: string\n x-dcl-go-name: PostalCode\n description: The postal code of the subject.\n x-kubernetes-immutable: true\n province:\n type: string\n x-dcl-go-name: Province\n description: The province, territory, or regional state of the\n subject.\n x-kubernetes-immutable: true\n streetAddress:\n type: string\n x-dcl-go-name: StreetAddress\n description: The street address of the subject.\n x-kubernetes-immutable: true\n subjectAltName:\n type: object\n x-dcl-go-name: SubjectAltName\n x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubjectAltName\n description: The subject alternative name fields.\n x-kubernetes-immutable: true\n properties:\n customSans:\n type: array\n x-dcl-go-name: CustomSans\n description: Contains additional subject alternative name values.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSans\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to\n handle this extension, the client should consider this\n to be an error).\n x-kubernetes-immutable: true\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateCertificateDescriptionSubjectDescriptionSubjectAltNameCustomSansObjectId\n description: Required. The OID for this X.509 extension.\n x-kubernetes-immutable: true\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The\n most significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n x-kubernetes-immutable: true\n dnsNames:\n type: array\n x-dcl-go-name: DnsNames\n description: Contains only valid, fully-qualified host names.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n emailAddresses:\n type: array\n x-dcl-go-name: EmailAddresses\n description: Contains only valid RFC 2822 E-mail addresses.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n ipAddresses:\n type: array\n x-dcl-go-name: IPAddresses\n description: Contains only valid 32-bit IPv4 addresses or RFC\n 4291 IPv6 addresses.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n uris:\n type: array\n x-dcl-go-name: Uris\n description: Contains only valid RFC 3986 URIs.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n subjectKeyId:\n type: object\n x-dcl-go-name: SubjectKeyId\n x-dcl-go-type: CertificateCertificateDescriptionSubjectKeyId\n description: Provides a means of identifiying certificates that contain\n a particular public key, per https://tools.ietf.org/html/rfc5280#section-4.2.1.2.\n x-kubernetes-immutable: true\n properties:\n keyId:\n type: string\n x-dcl-go-name: KeyId\n description: Optional. The value of this KeyId encoded in lowercase\n hexadecimal. This is most likely the 160 bit SHA-1 hash of the\n public key.\n x-kubernetes-immutable: true\n x509Description:\n type: object\n x-dcl-go-name: X509Description\n x-dcl-go-type: CertificateCertificateDescriptionX509Description\n description: Describes some of the technical X.509 fields in a certificate.\n x-kubernetes-immutable: true\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. Describes custom X.509 extensions.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionAdditionalExtensions\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to handle\n this extension, the client should consider this to be an\n error).\n x-kubernetes-immutable: true\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionAdditionalExtensionsObjectId\n description: Required. The OID for this X.509 extension.\n x-kubernetes-immutable: true\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n x-kubernetes-immutable: true\n aiaOcspServers:\n type: array\n x-dcl-go-name: AiaOcspServers\n description: Optional. Describes Online Certificate Status Protocol\n (OCSP) endpoint addresses that appear in the \"Authority Information\n Access\" extension in the certificate.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caOptions:\n type: object\n x-dcl-go-name: CaOptions\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionCaOptions\n description: Optional. Describes options in this X509Parameters\n that are relevant in a CA certificate.\n x-kubernetes-immutable: true\n properties:\n isCa:\n type: boolean\n x-dcl-go-name: IsCa\n description: Optional. Refers to the \"CA\" X.509 extension, which\n is a boolean value. When this value is missing, the extension\n will be omitted from the CA certificate.\n x-kubernetes-immutable: true\n maxIssuerPathLength:\n type: integer\n format: int64\n x-dcl-go-name: MaxIssuerPathLength\n description: Optional. Refers to the path length restriction\n X.509 extension. For a CA certificate, this value describes\n the depth of subordinate CA certificates that are allowed.\n If this value is less than 0, the request will fail. If this\n value is missing, the max path length will be omitted from\n the CA certificate.\n x-kubernetes-immutable: true\n keyUsage:\n type: object\n x-dcl-go-name: KeyUsage\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsage\n description: Optional. Indicates the intended use for keys that\n correspond to a certificate.\n x-kubernetes-immutable: true\n properties:\n baseKeyUsage:\n type: object\n x-dcl-go-name: BaseKeyUsage\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsageBaseKeyUsage\n description: Describes high-level ways in which a key may be\n used.\n x-kubernetes-immutable: true\n properties:\n certSign:\n type: boolean\n x-dcl-go-name: CertSign\n description: The key may be used to sign certificates.\n x-kubernetes-immutable: true\n contentCommitment:\n type: boolean\n x-dcl-go-name: ContentCommitment\n description: The key may be used for cryptographic commitments.\n Note that this may also be referred to as \"non-repudiation\".\n x-kubernetes-immutable: true\n crlSign:\n type: boolean\n x-dcl-go-name: CrlSign\n description: The key may be used sign certificate revocation\n lists.\n x-kubernetes-immutable: true\n dataEncipherment:\n type: boolean\n x-dcl-go-name: DataEncipherment\n description: The key may be used to encipher data.\n x-kubernetes-immutable: true\n decipherOnly:\n type: boolean\n x-dcl-go-name: DecipherOnly\n description: The key may be used to decipher only.\n x-kubernetes-immutable: true\n digitalSignature:\n type: boolean\n x-dcl-go-name: DigitalSignature\n description: The key may be used for digital signatures.\n x-kubernetes-immutable: true\n encipherOnly:\n type: boolean\n x-dcl-go-name: EncipherOnly\n description: The key may be used to encipher only.\n x-kubernetes-immutable: true\n keyAgreement:\n type: boolean\n x-dcl-go-name: KeyAgreement\n description: The key may be used in a key agreement protocol.\n x-kubernetes-immutable: true\n keyEncipherment:\n type: boolean\n x-dcl-go-name: KeyEncipherment\n description: The key may be used to encipher other keys.\n x-kubernetes-immutable: true\n extendedKeyUsage:\n type: object\n x-dcl-go-name: ExtendedKeyUsage\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsageExtendedKeyUsage\n description: Detailed scenarios in which a key may be used.\n x-kubernetes-immutable: true\n properties:\n clientAuth:\n type: boolean\n x-dcl-go-name: ClientAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially\n described as \"TLS WWW client authentication\", though regularly\n used for non-WWW TLS.\n x-kubernetes-immutable: true\n codeSigning:\n type: boolean\n x-dcl-go-name: CodeSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially\n described as \"Signing of downloadable executable code\n client authentication\".\n x-kubernetes-immutable: true\n emailProtection:\n type: boolean\n x-dcl-go-name: EmailProtection\n description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially\n described as \"Email protection\".\n x-kubernetes-immutable: true\n ocspSigning:\n type: boolean\n x-dcl-go-name: OcspSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially\n described as \"Signing OCSP responses\".\n x-kubernetes-immutable: true\n serverAuth:\n type: boolean\n x-dcl-go-name: ServerAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially\n described as \"TLS WWW server authentication\", though regularly\n used for non-WWW TLS.\n x-kubernetes-immutable: true\n timeStamping:\n type: boolean\n x-dcl-go-name: TimeStamping\n description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially\n described as \"Binding the hash of an object to a time\".\n x-kubernetes-immutable: true\n unknownExtendedKeyUsages:\n type: array\n x-dcl-go-name: UnknownExtendedKeyUsages\n description: Used to describe extended key usages that are not\n listed in the KeyUsage.ExtendedKeyUsageOptions message.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionKeyUsageUnknownExtendedKeyUsages\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n policyIds:\n type: array\n x-dcl-go-name: PolicyIds\n description: Optional. Describes the X.509 certificate policy object\n identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateCertificateDescriptionX509DescriptionPolicyIds\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n certificateTemplate:\n type: string\n x-dcl-go-name: CertificateTemplate\n description: Immutable. The resource name for a CertificateTemplate used\n to issue this certificate, in the format `projects/*/locations/*/certificateTemplates/*`.\n If this is specified, the caller must have the necessary permission to\n use this template. If this is omitted, no template will be used. This\n template must be in the same location as the Certificate.\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Privateca/CertificateTemplate\n field: selfLink\n x-dcl-has-long-form: true\n config:\n type: object\n x-dcl-go-name: Config\n x-dcl-go-type: CertificateConfig\n description: Immutable. A description of the certificate and key that does\n not require X.509 or ASN.1.\n x-kubernetes-immutable: true\n x-dcl-conflicts:\n - pemCsr\n required:\n - subjectConfig\n - x509Config\n properties:\n publicKey:\n type: object\n x-dcl-go-name: PublicKey\n x-dcl-go-type: CertificateConfigPublicKey\n description: Optional. The public key that corresponds to this config.\n This is, for example, used when issuing Certificates, but not when\n creating a self-signed CertificateAuthority or CertificateAuthority\n CSR.\n x-kubernetes-immutable: true\n required:\n - key\n - format\n properties:\n format:\n type: string\n x-dcl-go-name: Format\n x-dcl-go-type: CertificateConfigPublicKeyFormatEnum\n description: 'Required. The format of the public key. Possible values:\n KEY_FORMAT_UNSPECIFIED, PEM'\n x-kubernetes-immutable: true\n enum:\n - KEY_FORMAT_UNSPECIFIED\n - PEM\n key:\n type: string\n x-dcl-go-name: Key\n description: Required. A public key. The padding and encoding must\n match with the `KeyFormat` value specified for the `format` field.\n x-kubernetes-immutable: true\n subjectConfig:\n type: object\n x-dcl-go-name: SubjectConfig\n x-dcl-go-type: CertificateConfigSubjectConfig\n description: Required. Specifies some of the values in a certificate\n that are related to the subject.\n x-kubernetes-immutable: true\n required:\n - subject\n properties:\n subject:\n type: object\n x-dcl-go-name: Subject\n x-dcl-go-type: CertificateConfigSubjectConfigSubject\n description: Required. Contains distinguished name fields such as\n the common name, location and organization.\n x-kubernetes-immutable: true\n properties:\n commonName:\n type: string\n x-dcl-go-name: CommonName\n description: The \"common name\" of the subject.\n x-kubernetes-immutable: true\n countryCode:\n type: string\n x-dcl-go-name: CountryCode\n description: The country code of the subject.\n x-kubernetes-immutable: true\n locality:\n type: string\n x-dcl-go-name: Locality\n description: The locality or city of the subject.\n x-kubernetes-immutable: true\n organization:\n type: string\n x-dcl-go-name: Organization\n description: The organization of the subject.\n x-kubernetes-immutable: true\n organizationalUnit:\n type: string\n x-dcl-go-name: OrganizationalUnit\n description: The organizational_unit of the subject.\n x-kubernetes-immutable: true\n postalCode:\n type: string\n x-dcl-go-name: PostalCode\n description: The postal code of the subject.\n x-kubernetes-immutable: true\n province:\n type: string\n x-dcl-go-name: Province\n description: The province, territory, or regional state of the\n subject.\n x-kubernetes-immutable: true\n streetAddress:\n type: string\n x-dcl-go-name: StreetAddress\n description: The street address of the subject.\n x-kubernetes-immutable: true\n subjectAltName:\n type: object\n x-dcl-go-name: SubjectAltName\n x-dcl-go-type: CertificateConfigSubjectConfigSubjectAltName\n description: Optional. The subject alternative name fields.\n x-kubernetes-immutable: true\n properties:\n dnsNames:\n type: array\n x-dcl-go-name: DnsNames\n description: Contains only valid, fully-qualified host names.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n emailAddresses:\n type: array\n x-dcl-go-name: EmailAddresses\n description: Contains only valid RFC 2822 E-mail addresses.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n ipAddresses:\n type: array\n x-dcl-go-name: IPAddresses\n description: Contains only valid 32-bit IPv4 addresses or RFC\n 4291 IPv6 addresses.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n uris:\n type: array\n x-dcl-go-name: Uris\n description: Contains only valid RFC 3986 URIs.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x509Config:\n type: object\n x-dcl-go-name: X509Config\n x-dcl-go-type: CertificateConfigX509Config\n description: Required. Describes how some of the technical X.509 fields\n in a certificate should be populated.\n x-kubernetes-immutable: true\n properties:\n additionalExtensions:\n type: array\n x-dcl-go-name: AdditionalExtensions\n description: Optional. Describes custom X.509 extensions.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateConfigX509ConfigAdditionalExtensions\n required:\n - objectId\n - value\n properties:\n critical:\n type: boolean\n x-dcl-go-name: Critical\n description: Optional. Indicates whether or not this extension\n is critical (i.e., if the client does not know how to handle\n this extension, the client should consider this to be an\n error).\n x-kubernetes-immutable: true\n objectId:\n type: object\n x-dcl-go-name: ObjectId\n x-dcl-go-type: CertificateConfigX509ConfigAdditionalExtensionsObjectId\n description: Required. The OID for this X.509 extension.\n x-kubernetes-immutable: true\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n value:\n type: string\n x-dcl-go-name: Value\n description: Required. The value of this X.509 extension.\n x-kubernetes-immutable: true\n aiaOcspServers:\n type: array\n x-dcl-go-name: AiaOcspServers\n description: Optional. Describes Online Certificate Status Protocol\n (OCSP) endpoint addresses that appear in the \"Authority Information\n Access\" extension in the certificate.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n caOptions:\n type: object\n x-dcl-go-name: CaOptions\n x-dcl-go-type: CertificateConfigX509ConfigCaOptions\n description: Optional. Describes options in this X509Parameters\n that are relevant in a CA certificate.\n x-kubernetes-immutable: true\n properties:\n isCa:\n type: boolean\n x-dcl-go-name: IsCa\n description: Optional. When true, the \"CA\" in Basic Constraints\n extension will be set to true.\n x-kubernetes-immutable: true\n maxIssuerPathLength:\n type: integer\n format: int64\n x-dcl-go-name: MaxIssuerPathLength\n description: Optional. Refers to the \"path length constraint\"\n in Basic Constraints extension. For a CA certificate, this\n value describes the depth of subordinate CA certificates that\n are allowed. If this value is less than 0, the request will\n fail.\n x-kubernetes-immutable: true\n nonCa:\n type: boolean\n x-dcl-go-name: NonCa\n description: Optional. When true, the \"CA\" in Basic Constraints\n extension will be set to false. If both `is_ca` and `non_ca`\n are unset, the extension will be omitted from the CA certificate.\n x-kubernetes-immutable: true\n zeroMaxIssuerPathLength:\n type: boolean\n x-dcl-go-name: ZeroMaxIssuerPathLength\n description: Optional. When true, the \"path length constraint\"\n in Basic Constraints extension will be set to 0. if both max_issuer_path_length\n and zero_max_issuer_path_length are unset, the max path length\n will be omitted from the CA certificate.\n x-kubernetes-immutable: true\n keyUsage:\n type: object\n x-dcl-go-name: KeyUsage\n x-dcl-go-type: CertificateConfigX509ConfigKeyUsage\n description: Optional. Indicates the intended use for keys that\n correspond to a certificate.\n x-kubernetes-immutable: true\n properties:\n baseKeyUsage:\n type: object\n x-dcl-go-name: BaseKeyUsage\n x-dcl-go-type: CertificateConfigX509ConfigKeyUsageBaseKeyUsage\n description: Describes high-level ways in which a key may be\n used.\n x-kubernetes-immutable: true\n properties:\n certSign:\n type: boolean\n x-dcl-go-name: CertSign\n description: The key may be used to sign certificates.\n x-kubernetes-immutable: true\n contentCommitment:\n type: boolean\n x-dcl-go-name: ContentCommitment\n description: The key may be used for cryptographic commitments.\n Note that this may also be referred to as \"non-repudiation\".\n x-kubernetes-immutable: true\n crlSign:\n type: boolean\n x-dcl-go-name: CrlSign\n description: The key may be used sign certificate revocation\n lists.\n x-kubernetes-immutable: true\n dataEncipherment:\n type: boolean\n x-dcl-go-name: DataEncipherment\n description: The key may be used to encipher data.\n x-kubernetes-immutable: true\n decipherOnly:\n type: boolean\n x-dcl-go-name: DecipherOnly\n description: The key may be used to decipher only.\n x-kubernetes-immutable: true\n digitalSignature:\n type: boolean\n x-dcl-go-name: DigitalSignature\n description: The key may be used for digital signatures.\n x-kubernetes-immutable: true\n encipherOnly:\n type: boolean\n x-dcl-go-name: EncipherOnly\n description: The key may be used to encipher only.\n x-kubernetes-immutable: true\n keyAgreement:\n type: boolean\n x-dcl-go-name: KeyAgreement\n description: The key may be used in a key agreement protocol.\n x-kubernetes-immutable: true\n keyEncipherment:\n type: boolean\n x-dcl-go-name: KeyEncipherment\n description: The key may be used to encipher other keys.\n x-kubernetes-immutable: true\n extendedKeyUsage:\n type: object\n x-dcl-go-name: ExtendedKeyUsage\n x-dcl-go-type: CertificateConfigX509ConfigKeyUsageExtendedKeyUsage\n description: Detailed scenarios in which a key may be used.\n x-kubernetes-immutable: true\n properties:\n clientAuth:\n type: boolean\n x-dcl-go-name: ClientAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially\n described as \"TLS WWW client authentication\", though regularly\n used for non-WWW TLS.\n x-kubernetes-immutable: true\n codeSigning:\n type: boolean\n x-dcl-go-name: CodeSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially\n described as \"Signing of downloadable executable code\n client authentication\".\n x-kubernetes-immutable: true\n emailProtection:\n type: boolean\n x-dcl-go-name: EmailProtection\n description: Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially\n described as \"Email protection\".\n x-kubernetes-immutable: true\n ocspSigning:\n type: boolean\n x-dcl-go-name: OcspSigning\n description: Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially\n described as \"Signing OCSP responses\".\n x-kubernetes-immutable: true\n serverAuth:\n type: boolean\n x-dcl-go-name: ServerAuth\n description: Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially\n described as \"TLS WWW server authentication\", though regularly\n used for non-WWW TLS.\n x-kubernetes-immutable: true\n timeStamping:\n type: boolean\n x-dcl-go-name: TimeStamping\n description: Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially\n described as \"Binding the hash of an object to a time\".\n x-kubernetes-immutable: true\n unknownExtendedKeyUsages:\n type: array\n x-dcl-go-name: UnknownExtendedKeyUsages\n description: Used to describe extended key usages that are not\n listed in the KeyUsage.ExtendedKeyUsageOptions message.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateConfigX509ConfigKeyUsageUnknownExtendedKeyUsages\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n policyIds:\n type: array\n x-dcl-go-name: PolicyIds\n description: Optional. Describes the X.509 certificate policy object\n identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: CertificateConfigX509ConfigPolicyIds\n required:\n - objectIdPath\n properties:\n objectIdPath:\n type: array\n x-dcl-go-name: ObjectIdPath\n description: Required. The parts of an OID path. The most\n significant parts of the path come first.\n x-kubernetes-immutable: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. The time at which this Certificate was created.\n x-kubernetes-immutable: true\n issuerCertificateAuthority:\n type: string\n x-dcl-go-name: IssuerCertificateAuthority\n readOnly: true\n description: Output only. The resource name of the issuing CertificateAuthority\n in the format `projects/*/locations/*/caPools/*/certificateAuthorities/*`.\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Privateca/CertificateAuthority\n field: selfLink\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: Optional. Labels with user-defined metadata.\n lifetime:\n type: string\n x-dcl-go-name: Lifetime\n description: Required. Immutable. The desired lifetime of a certificate.\n Used to create the \"not_before_time\" and \"not_after_time\" fields inside\n an X.509 certificate. Note that the lifetime may be truncated if it would\n extend past the life of any certificate authority in the issuing chain.\n x-kubernetes-immutable: true\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: The resource name for this Certificate in the format `projects/*/locations/*/caPools/*/certificates/*`.\n x-kubernetes-immutable: true\n x-dcl-has-long-form: true\n pemCertificate:\n type: string\n x-dcl-go-name: PemCertificate\n readOnly: true\n description: Output only. The pem-encoded, signed X.509 certificate.\n x-kubernetes-immutable: true\n pemCertificateChain:\n type: array\n x-dcl-go-name: PemCertificateChain\n readOnly: true\n description: Output only. The chain that may be used to verify the X.509\n certificate. Expected to be in issuer-to-root order according to RFC 5246.\n x-kubernetes-immutable: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n pemCsr:\n type: string\n x-dcl-go-name: PemCsr\n description: Immutable. A pem-encoded X.509 certificate signing request\n (CSR).\n x-kubernetes-immutable: true\n x-dcl-conflicts:\n - config\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n revocationDetails:\n type: object\n x-dcl-go-name: RevocationDetails\n x-dcl-go-type: CertificateRevocationDetails\n readOnly: true\n description: Output only. Details regarding the revocation of this Certificate.\n This Certificate is considered revoked if and only if this field is present.\n x-kubernetes-immutable: true\n properties:\n revocationState:\n type: string\n x-dcl-go-name: RevocationState\n x-dcl-go-type: CertificateRevocationDetailsRevocationStateEnum\n description: 'Indicates why a Certificate was revoked. Possible values:\n REVOCATION_REASON_UNSPECIFIED, KEY_COMPROMISE, CERTIFICATE_AUTHORITY_COMPROMISE,\n AFFILIATION_CHANGED, SUPERSEDED, CESSATION_OF_OPERATION, CERTIFICATE_HOLD,\n PRIVILEGE_WITHDRAWN, ATTRIBUTE_AUTHORITY_COMPROMISE'\n x-kubernetes-immutable: true\n enum:\n - REVOCATION_REASON_UNSPECIFIED\n - KEY_COMPROMISE\n - CERTIFICATE_AUTHORITY_COMPROMISE\n - AFFILIATION_CHANGED\n - SUPERSEDED\n - CESSATION_OF_OPERATION\n - CERTIFICATE_HOLD\n - PRIVILEGE_WITHDRAWN\n - ATTRIBUTE_AUTHORITY_COMPROMISE\n revocationTime:\n type: string\n format: date-time\n x-dcl-go-name: RevocationTime\n description: The time at which this Certificate was revoked.\n x-kubernetes-immutable: true\n subjectMode:\n type: string\n x-dcl-go-name: SubjectMode\n x-dcl-go-type: CertificateSubjectModeEnum\n description: 'Immutable. Specifies how the Certificate''s identity fields\n are to be decided. If this is omitted, the `DEFAULT` subject mode will\n be used. Possible values: SUBJECT_REQUEST_MODE_UNSPECIFIED, DEFAULT, REFLECTED_SPIFFE'\n x-kubernetes-immutable: true\n enum:\n - SUBJECT_REQUEST_MODE_UNSPECIFIED\n - DEFAULT\n - REFLECTED_SPIFFE\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. The time at which this Certificate was updated.\n x-kubernetes-immutable: true\n") + +// 55751 bytes +// MD5: e8e18f36484865ea130bf0b064ec8517 diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/client.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/client.go new file mode 100644 index 00000000000..a1e5bebc211 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/client.go @@ -0,0 +1,32 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// Package privateca defines operations in the declarative SDK. +package privateca + +import ( + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" +) + +// The Client is the base struct of all operations. This will receive the +// Get, Delete, List, and Apply operations on all resources. +type Client struct { + Config *dcl.Config +} + +// NewClient creates a client that retries all operations a few times each. +func NewClient(c *dcl.Config) *Client { + return &Client{ + Config: c, + } +} diff --git a/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/privateca_utils.go b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/privateca_utils.go new file mode 100644 index 00000000000..3001870f6c6 --- /dev/null +++ b/terraform/providers/google/vendor/github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/privateca_utils.go @@ -0,0 +1,343 @@ +// Copyright 2024 Google LLC. All Rights Reserved. +// +// 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. +// Package privateca contains methods and objects for handling privateca GCP resources. +package privateca + +import ( + "bytes" + "context" + "fmt" + + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations" +) + +// Waits for the state of the certificate authority to be "ENABLED". +func (r *CertificateAuthority) waitForCertificateAuthorityEnabled(ctx context.Context, c *Client) error { + return dcl.Do(ctx, func(ctx context.Context) (*dcl.RetryDetails, error) { + nr, err := c.GetCertificateAuthority(ctx, r) + if err != nil { + return nil, err + } + if *nr.State == *CertificateAuthorityStateEnumRef("ENABLED") || *nr.State == *CertificateAuthorityStateEnumRef("STAGED") { + return nil, nil + } + return &dcl.RetryDetails{}, dcl.OperationNotDone{} + }, c.Config.RetryProvider) +} + +// Disables the certificate authority so that it can be deleted. +func (r *CertificateAuthority) disableCertificateAuthority(ctx context.Context, c *Client) error { + if *r.State != *CertificateAuthorityStateEnumRef("ENABLED") { + // Only enabled certificate authorities need to be disabled before deletion. + return nil + } + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "ca_pool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + } + u := dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{ca_pool}}/certificateAuthorities/{{name}}:disable", "https://privateca.googleapis.com/v1/", c.Config.BasePath, params) + resp, err := dcl.SendRequest(ctx, c.Config, "POST", u, &bytes.Buffer{}, c.Config.RetryProvider) + if err != nil { + return err + } + + // wait for certificate authority to be disabled. + var o operations.StandardGCPOperation + if err := dcl.ParseResponse(resp.Response, &o); err != nil { + return err + } + if err := o.Wait(ctx, c.Config, "https://privateca.googleapis.com/v1beta1/", "GET"); err != nil { + return err + } + return nil +} + +func (r *Certificate) createURL(userBasePath string) (string, error) { + nr := r.urlNormalized() + params := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "caPool": dcl.ValueOrEmptyString(nr.CaPool), + "name": dcl.ValueOrEmptyString(nr.Name), + "certificateAuthority": dcl.ValueOrEmptyString(nr.CertificateAuthority), + } + basePath := dcl.URL("projects/{{project}}/locations/{{location}}/caPools/{{caPool}}/certificates", nr.basePath(), userBasePath, params) + + var err error + if dcl.ValueOrEmptyString(nr.CertificateAuthority) != "" { + basePath, err = dcl.AddQueryParams(basePath, map[string]string{"issuingCertificateAuthorityId": dcl.ValueOrEmptyString(nr.CertificateAuthority)}) + if err != nil { + return "", err + } + } + if dcl.ValueOrEmptyString(nr.Name) != "" { + // Need to set name to nil or else it'll trigger error messages. + basePath, err = dcl.AddQueryParams(basePath, map[string]string{"certificateId": dcl.ValueOrEmptyString(nr.Name)}) + if err != nil { + return "", err + } + } + return basePath, nil +} + +func flattenCertificateConfigX509ConfigCAOptions(_ *Client, i interface{}, _ *Certificate) *CertificateConfigX509ConfigCaOptions { + if i == nil { + return nil + } + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + result := &CertificateConfigX509ConfigCaOptions{} + + isCA, ok := m["isCa"].(bool) + if ok { + result.IsCa = dcl.Bool(isCA) + if !isCA { + result.NonCa = dcl.Bool(true) + } + } + + if _, ok := m["maxIssuerPathLength"]; ok { + pathLen := dcl.FlattenInteger(m["maxIssuerPathLength"]) + result.MaxIssuerPathLength = pathLen + if dcl.ValueOrEmptyInt64(pathLen) == 0 { + result.ZeroMaxIssuerPathLength = dcl.Bool(true) + } + } + + return result +} + +func expandCertificateConfigX509ConfigCAOptions(_ *Client, caOptions *CertificateConfigX509ConfigCaOptions, _ *Certificate) (map[string]interface{}, error) { + if caOptions == nil { + return nil, nil + } + + m := make(map[string]interface{}) + isCA := dcl.ValueOrEmptyBool(caOptions.IsCa) + nonCA := dcl.ValueOrEmptyBool(caOptions.NonCa) + zeroPathLength := dcl.ValueOrEmptyBool(caOptions.ZeroMaxIssuerPathLength) + maxIssuerPathLength := dcl.ValueOrEmptyInt64(caOptions.MaxIssuerPathLength) + + if !isCA && !nonCA { + return nil, nil + } else if isCA && nonCA { + return nil, fmt.Errorf("is_ca and non_ca are mutually exclusive") + } else if isCA || nonCA { + m["isCa"] = isCA + } + + if zeroPathLength && maxIssuerPathLength > 0 { + return nil, fmt.Errorf("max_issuer_path_length and zero_max_issuer_path_length are mutually exclusive") + } + if maxIssuerPathLength > 0 || zeroPathLength { + m["maxIssuerPathLength"] = maxIssuerPathLength + } + + return m, nil +} + +// base_key_usage has a custom flattener because the API does not return the object when all subfields are set to false. +func flattenCertificateTemplateBaseKeyUsage(_ *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + if res != nil && res.PredefinedValues != nil && res.PredefinedValues.KeyUsage != nil && res.PredefinedValues.KeyUsage.BaseKeyUsage != nil { + baseKeyUsage := res.PredefinedValues.KeyUsage.BaseKeyUsage + allFalse := true + for _, booleanField := range []*bool{ + baseKeyUsage.DigitalSignature, + baseKeyUsage.ContentCommitment, + baseKeyUsage.KeyEncipherment, + baseKeyUsage.DataEncipherment, + baseKeyUsage.KeyAgreement, + baseKeyUsage.CertSign, + baseKeyUsage.CrlSign, + baseKeyUsage.EncipherOnly, + baseKeyUsage.DecipherOnly, + } { + if dcl.ValueOrEmptyBool(booleanField) { + allFalse = false + } + } + if allFalse { + return dcl.Copy(baseKeyUsage).(*CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) + } + } + return nil + } + + r := &CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + } + r.DigitalSignature = dcl.FlattenBool(m["digitalSignature"]) + r.ContentCommitment = dcl.FlattenBool(m["contentCommitment"]) + r.KeyEncipherment = dcl.FlattenBool(m["keyEncipherment"]) + r.DataEncipherment = dcl.FlattenBool(m["dataEncipherment"]) + r.KeyAgreement = dcl.FlattenBool(m["keyAgreement"]) + r.CertSign = dcl.FlattenBool(m["certSign"]) + r.CrlSign = dcl.FlattenBool(m["crlSign"]) + r.EncipherOnly = dcl.FlattenBool(m["encipherOnly"]) + r.DecipherOnly = dcl.FlattenBool(m["decipherOnly"]) + + return r +} + +// extended_key_usage has a custom flattener because the API does not return the object when all subfields are set to false. +func flattenCertificateTemplateExtendedKeyUsage(_ *Client, i interface{}, res *CertificateTemplate) *CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + m, ok := i.(map[string]interface{}) + if !ok { + if res != nil && res.PredefinedValues != nil && res.PredefinedValues.KeyUsage != nil && res.PredefinedValues.KeyUsage.ExtendedKeyUsage != nil { + extendedKeyUsage := res.PredefinedValues.KeyUsage.ExtendedKeyUsage + allFalse := true + for _, booleanField := range []*bool{ + extendedKeyUsage.ServerAuth, + extendedKeyUsage.ClientAuth, + extendedKeyUsage.CodeSigning, + extendedKeyUsage.EmailProtection, + extendedKeyUsage.TimeStamping, + extendedKeyUsage.OcspSigning, + } { + if dcl.ValueOrEmptyBool(booleanField) { + allFalse = false + } + } + if allFalse { + return dcl.Copy(extendedKeyUsage).(*CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) + } + } + return nil + } + + r := &CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + } + r.ServerAuth = dcl.FlattenBool(m["serverAuth"]) + r.ClientAuth = dcl.FlattenBool(m["clientAuth"]) + r.CodeSigning = dcl.FlattenBool(m["codeSigning"]) + r.EmailProtection = dcl.FlattenBool(m["emailProtection"]) + r.TimeStamping = dcl.FlattenBool(m["timeStamping"]) + r.OcspSigning = dcl.FlattenBool(m["ocspSigning"]) + + return r +} + +func expandCaPoolIssuancePolicyBaselineValuesCAOptions(_ *Client, f *CaPoolIssuancePolicyBaselineValuesCaOptions, res *CaPool) (map[string]any, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]any) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + + maxIssuerPathLength := dcl.ValueOrEmptyInt64(f.MaxIssuerPathLength) + zeroPathLength := dcl.ValueOrEmptyBool(f.ZeroMaxIssuerPathLength) + if zeroPathLength && maxIssuerPathLength > 0 { + return nil, fmt.Errorf("max_issuer_path_length and zero_max_issuer_path_length are mutually exclusive") + } + if maxIssuerPathLength > 0 || zeroPathLength { + m["maxIssuerPathLength"] = maxIssuerPathLength + } + + return m, nil +} + +func flattenCaPoolIssuancePolicyBaselineValuesCAOptions(_ *Client, i any, res *CaPool) *CaPoolIssuancePolicyBaselineValuesCaOptions { + m, ok := i.(map[string]any) + if !ok { + return nil + } + + r := &CaPoolIssuancePolicyBaselineValuesCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCaPoolIssuancePolicyBaselineValuesCaOptions + } + + isCA, ok := m["isCa"].(bool) + if ok { + r.IsCa = dcl.Bool(isCA) + } + + if _, ok := m["maxIssuerPathLength"]; ok { + pathLen := dcl.FlattenInteger(m["maxIssuerPathLength"]) + r.MaxIssuerPathLength = pathLen + if dcl.ValueOrEmptyInt64(pathLen) == 0 { + r.ZeroMaxIssuerPathLength = dcl.Bool(true) + } + } + + return r +} + +func flattenCertificateAuthorityConfigX509ConfigCAOptions(_ *Client, i any, res *CertificateAuthority) *CertificateAuthorityConfigX509ConfigCaOptions { + m, ok := i.(map[string]any) + if !ok { + return nil + } + + r := &CertificateAuthorityConfigX509ConfigCaOptions{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyCertificateAuthorityConfigX509ConfigCaOptions + } + + isCA, ok := m["isCa"].(bool) + if ok { + r.IsCa = dcl.Bool(isCA) + } + + if _, ok := m["maxIssuerPathLength"]; ok { + pathLen := dcl.FlattenInteger(m["maxIssuerPathLength"]) + r.MaxIssuerPathLength = pathLen + if dcl.ValueOrEmptyInt64(pathLen) == 0 { + r.ZeroMaxIssuerPathLength = dcl.Bool(true) + } + } + + return r +} + +func expandCertificateAuthorityConfigX509ConfigCAOptions(_ *Client, f *CertificateAuthorityConfigX509ConfigCaOptions, res *CertificateAuthority) (map[string]any, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]any) + if v := f.IsCa; !dcl.IsEmptyValueIndirect(v) { + m["isCa"] = v + } + + maxIssuerPathLength := dcl.ValueOrEmptyInt64(f.MaxIssuerPathLength) + zeroPathLength := dcl.ValueOrEmptyBool(f.ZeroMaxIssuerPathLength) + if zeroPathLength && maxIssuerPathLength > 0 { + return nil, fmt.Errorf("max_issuer_path_length and zero_max_issuer_path_length are mutually exclusive") + } + if maxIssuerPathLength > 0 || zeroPathLength { + m["maxIssuerPathLength"] = maxIssuerPathLength + } + + return m, nil +} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.go-version b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.go-version index d2ab029d32c..5fb5a6b4f54 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.go-version +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.go-version @@ -1 +1 @@ -1.21 +1.20 diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.goreleaser.yml b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.goreleaser.yml index 2c3fc7bb20e..ce9cf6b1102 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.goreleaser.yml +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/.goreleaser.yml @@ -1,8 +1,7 @@ archives: - files: - # Include built binary and license files in archive - - src: 'LICENSE' - dst: 'LICENSE.txt' + # Only include built binary in archive + - 'none*' format: zip name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' builds: diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/CHANGELOG.md b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/CHANGELOG.md index 8fac9566621..ca84e170ba1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/CHANGELOG.md +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/CHANGELOG.md @@ -1,440 +1,8 @@ -## 5.37.0 (Unreleased) - -NOTES: -* orgpolicy: converted `google_org_policy_policy` now to use MMv1 engine instead of DCL ([#18635](https://github.com/hashicorp/terraform-provider-google/pull/18635)) - -FEATURES: -* **New Data Source:** `google_kms_crypto_keys` ([#18605](https://github.com/hashicorp/terraform-provider-google/pull/18605)) -* **New Data Source:** `google_kms_key_rings` ([#18611](https://github.com/hashicorp/terraform-provider-google/pull/18611)) -* **New Resource:** `google_scc_v2_organization_notification_config` ([#18594](https://github.com/hashicorp/terraform-provider-google/pull/18594)) -* **New Resource:** `google_secure_source_manager_repository` ([#18576](https://github.com/hashicorp/terraform-provider-google/pull/18576)) -* **New Resource:** `google_storage_managed_folder_iam` ([#18555](https://github.com/hashicorp/terraform-provider-google/pull/18555)) -* **New Resource:** `google_storage_managed_folder` ([#18555](https://github.com/hashicorp/terraform-provider-google/pull/18555)) - -IMPROVEMENTS: -* certificatemanager: added `allowlisted_certificates` field to `google_certificate_manager_trust_config` resource ([#18587](https://github.com/hashicorp/terraform-provider-google/pull/18587)) -* compute: added `max_run_duration` and `on_instance_stop_action` fields to `google_compute_instance`, `google_compute_instance_template`, and `google_compute_instance_from_machine_image` resources ([#18623](https://github.com/hashicorp/terraform-provider-google/pull/18623)) -* dataplex: added `sql_assertion` field to `google_dataplex_datascan` resource ([#18559](https://github.com/hashicorp/terraform-provider-google/pull/18559)) -* gkehub: added `fleet_default_member_config.configmanagement.config_sync.enabled` field to `google_gke_hub_feature` resource ([#18582](https://github.com/hashicorp/terraform-provider-google/pull/18582)) -* netapp: added `zone` and `replica_zone` field to `google_netapp_storage_pool` resource ([#18609](https://github.com/hashicorp/terraform-provider-google/pull/18609)) -* vertexai: added `project_number` field to `google_vertex_ai_feature_online_store_featureview` resource ([#18637](https://github.com/hashicorp/terraform-provider-google/pull/18637)) -* workstations: added `host.gce_instance.vm_tags` field to `google_workstations_workstation_config` resource ([#18588](https://github.com/hashicorp/terraform-provider-google/pull/18588)) - -BUG FIXES: -* compute: fixed a bug preventing the creation of `google_compute_autoscaler` and `google_compute_region_autoscaler` resources if both `autoscaling_policy.max_replicas` and `autoscaling_policy.min_replicas` were configured as zero. ([#18607](https://github.com/hashicorp/terraform-provider-google/pull/18607)) -* resourcemanager: mitigated eventual consistency issues by adding a 10s wait after `google_service_account_key` resource creation ([#18566](https://github.com/hashicorp/terraform-provider-google/pull/18566)) -* vertexai: fixed issue where updating "metadata" field could fail in `google_vertex_ai_index` resource ([#18632](https://github.com/hashicorp/terraform-provider-google/pull/18632)) - -## 5.36.0 (July 1, 2024) - -FEATURES: -* **New Resource:** `google_storage_managed_folder_iam` ([#18555](https://github.com/hashicorp/terraform-provider-google/pull/18555)) -* **New Resource:** `google_storage_managed_folder` ([#18555](https://github.com/hashicorp/terraform-provider-google/pull/18555)) - -IMPROVEMENTS: -* bigtable: added `ignore_warnings` field to `google_bigtable_gc_policy` resource ([#18492](https://github.com/hashicorp/terraform-provider-google/pull/18492)) -* cloudfunctions2: added `build_config.automatic_update_policy` and `build_config.on_deploy_update_policy` fields to `google_cloudfunctions2_function` resource ([#18540](https://github.com/hashicorp/terraform-provider-google/pull/18540)) -* compute: added `confidential_instance_config.confidential_instance_type` field to `google_compute_instance`, `google_compute_instance_template`, and `google_compute_region_instance_template` resources ([#18554](https://github.com/hashicorp/terraform-provider-google/pull/18554)) -* compute: added `custom_error_response_policy` and `default_custom_error_response_policy` fields to `google_compute_url_map` resource ([#18511](https://github.com/hashicorp/terraform-provider-google/pull/18511)) -* compute: added `tls_early_data` field to `google_compute_target_https_proxy` resource ([#18512](https://github.com/hashicorp/terraform-provider-google/pull/18512)) -* compute: promoted `google_compute_network_attachment` resource from beta to GA ([#18494](https://github.com/hashicorp/terraform-provider-google/pull/18494)) -* datafusion: added `connection_type` and `private_service_connect_config` fields to `google_data_fusion_instance` resource ([#18525](https://github.com/hashicorp/terraform-provider-google/pull/18525)) -* healthcare: added `encryption_spec` field to `google_healthcare_dataset` resource ([#18528](https://github.com/hashicorp/terraform-provider-google/pull/18528)) -* monitoring: added `links` field to `google_monitoring_alert_policy` resource ([#18549](https://github.com/hashicorp/terraform-provider-google/pull/18549)) -* vertexai: added update support for `big_query.entity_id_columns` field on `google_vertex_ai_feature_group` resource ([#18493](https://github.com/hashicorp/terraform-provider-google/pull/18493)) -* vertexai: promoted `dedicated_serving_endpoint` field on `google_vertex_ai_feature_online_store` resource from beta to GA ([#18513](https://github.com/hashicorp/terraform-provider-google/pull/18513)) - -BUG FIXES: -* accesscontextmanager: fixed perma-diff caused by ordering of `service_perimeters` in `google_access_context_manager_service_perimeters` resource ([#18520](https://github.com/hashicorp/terraform-provider-google/pull/18520)) -* compute: fixed a crash in `google_compute_reservation` resource when `share_settings` field has changes ([#18498](https://github.com/hashicorp/terraform-provider-google/pull/18498)) -* compute: fixed issue in `google_compute_instance` resource where `service_account` is not set when specifying `service_account.email` and no `service_account.scopes` ([#18521](https://github.com/hashicorp/terraform-provider-google/pull/18521)) -* gkehub2: fixed `google_gke_hub_feature` resource to allow `fleet_default_member_config` field to be unset ([#18487](https://github.com/hashicorp/terraform-provider-google/pull/18487)) -* identityplatform: fixed perma-diff on `google_identity_platform_config` resource when `sms_region_config` is not set ([#18537](https://github.com/hashicorp/terraform-provider-google/pull/18537)) -* logging: fixed perma-diff on `index_configs` in `google_logging_organization_bucket_config` resource ([#18501](https://github.com/hashicorp/terraform-provider-google/pull/18501)) - -## 5.35.0 (June 24, 2024) - -FEATURES: -* **New Data Source:** `google_artifact_registry_docker_image` ([#18446](https://github.com/hashicorp/terraform-provider-google/pull/18446)) -* **New Resource:** `google_service_networking_vpc_service_controls` ([#18448](https://github.com/hashicorp/terraform-provider-google/pull/18448)) - -IMPROVEMENTS: -* billingbudget: added `enable_project_level_recipients` field to `google_billing_budget` resource ([#18437](https://github.com/hashicorp/terraform-provider-google/pull/18437)) -* compute: added `action_token_site_keys` and `session_token_site_keys` fields to `google_compute_security_policy` and `google_compute_security_policy_rule` resources ([#18414](https://github.com/hashicorp/terraform-provider-google/pull/18414)) -* gkehub2: added `ENTERPRISE` option to `security_posture_config` field on `google_gke_hub_fleet` resource ([#18440](https://github.com/hashicorp/terraform-provider-google/pull/18440)) -* pubsub: added `bigquery_config.service_account_email` field to `google_pubsub_subscription` resource ([#18444](https://github.com/hashicorp/terraform-provider-google/pull/18444)) -* redis: added `maintenance_version` field to `google_redis_instance` resource ([#18424](https://github.com/hashicorp/terraform-provider-google/pull/18424)) -* storage: changed update behavior in `google_storage_bucket_object` to no longer delete to avoid object deletion on content update ([#18479](https://github.com/hashicorp/terraform-provider-google/pull/18479)) -* sql: added support for more MySQL values in `type` field of `google_sql_user` resource ([#18452](https://github.com/hashicorp/terraform-provider-google/pull/18452)) -* sql: increased timeouts on `google_sql_database_instance` to 90m to account for longer-running actions such as creation through cloning ([#18458](https://github.com/hashicorp/terraform-provider-google/pull/18458)) -* workbench: added update support to `gce_setup.boot_disk` and `gce_setup.data_disks` fields in `google_workbench_instance` resource ([#18482](https://github.com/hashicorp/terraform-provider-google/pull/18482)) - -BUG FIXES: -* compute: updated `google_compute_instance` to force reboot if `min_node_cpus` is updated ([#18420](https://github.com/hashicorp/terraform-provider-google/pull/18420)) -* compute: fixed `description` field in `google_compute_firewall` to support empty/null values on update ([#18478](https://github.com/hashicorp/terraform-provider-google/pull/18478)) -* compute: fixed perma-diff on `google_compute_disk` for Ubuntu amd64 canonical LTS images ([#18418](https://github.com/hashicorp/terraform-provider-google/pull/18418)) -* storage: fixed lowercased `custom_placement_config` values in `google_storage_bucket` causing perma-destroy ([#18456](https://github.com/hashicorp/terraform-provider-google/pull/18456)) -* workbench: fixed issue where instance was not starting after an update in `google_workbench_instance` resource ([#18464](https://github.com/hashicorp/terraform-provider-google/pull/18464)) -* workbench: fixed perma-diff caused by empty `accelerator_configs` in `google_workbench_instance` resource ([#18464](https://github.com/hashicorp/terraform-provider-google/pull/18464)) - -## 5.34.0 (June 17, 2024) - -NOTES: -* compute: Updated field description of `connection_draining_timeout_sec`, `balancing_mode` and `outlier_detection` in `google_compute_region_backend_service` and `google_compute_backend_service` to inform that default values will be changed in 6.0.0 ([#18399](https://github.com/hashicorp/terraform-provider-google/pull/18399)) - -FEATURES: -* **New Resource:** `google_netapp_backup` ([#18357](https://github.com/hashicorp/terraform-provider-google/pull/18357)) -* **New Resource:** `google_network_services_service_lb_policies` ([#18326](https://github.com/hashicorp/terraform-provider-google/pull/18326)) -* **New Resource:** `google_scc_management_folder_security_health_analytics_custom_module` ([#18360](https://github.com/hashicorp/terraform-provider-google/pull/18360)) -* **New Resource:** `google_scc_management_organization_project_security_health_analytics_custom_module` ([#18369](https://github.com/hashicorp/terraform-provider-google/pull/18369)) -* **New Resource:** `google_scc_management_organization_security_health_analytics_custom_module` ([#18374](https://github.com/hashicorp/terraform-provider-google/pull/18374)) - -IMPROVEMENTS: -* alloydb: changed the resource `google_alloydb_instance` to be created directly with public IP enabled instead of creating the resource with public IP disabled and then enabling it ([#18344](https://github.com/hashicorp/terraform-provider-google/pull/18344)) -* bigtable: added `automated_backup_configuration` field to `google_bigtable_table` resource ([#18335](https://github.com/hashicorp/terraform-provider-google/pull/18335)) -* cloudbuildv2: added support for connecting to Bitbucket Data Center and Bitbucket Cloud with the `bitbucket_data_center_config` and `bitbucket_cloud_config` fields in `google_cloudbuildv2_connection` ([#18375](https://github.com/hashicorp/terraform-provider-google/pull/18375)) -* compute: added update support to `ssl_policy` field in `google_compute_region_target_https_proxy` resource ([#18361](https://github.com/hashicorp/terraform-provider-google/pull/18361)) -* compute: removed enum validation on `guest_os_features.type` in `google_compute_disk` to allow for new features to be used without provider update ([#18331](https://github.com/hashicorp/terraform-provider-google/pull/18331)) -* compute: updated documentation of google_compute_target_https_proxy and google_compute_region_target_https_proxy ([#18358](https://github.com/hashicorp/terraform-provider-google/pull/18358)) -* container: added support for `security_posture_config.mode` value "ENTERPRISE" in `resource_container_cluster` ([#18334](https://github.com/hashicorp/terraform-provider-google/pull/18334)) -* discoveryengine: added `document_processing_config` field to `google_discovery_engine_data_store` resource ([#18350](https://github.com/hashicorp/terraform-provider-google/pull/18350)) -* edgecontainer: added 'maintenance_exclusions' field to 'google_edgecontainer_cluster' resource ([#18370](https://github.com/hashicorp/terraform-provider-google/pull/18370)) -* gkehub: added `prevent_drift` field to ConfigManagement `fleet_default_member_config` ([#18330](https://github.com/hashicorp/terraform-provider-google/pull/18330)) -* netapp: added `administrators` field to `google_netapp_active_directory` resource ([#18333](https://github.com/hashicorp/terraform-provider-google/pull/18333)) -* vertexai: promoted `optimized` field to GA for `google_vertex_ai_feature_online_store` resource ([#18348](https://github.com/hashicorp/terraform-provider-google/pull/18348)) -* workbench: updated the metadata keys managed by the backend. ([#18367](https://github.com/hashicorp/terraform-provider-google/pull/18367)) - -BUG FIXES: -* compute: fixed an issue where `google_compute_instance_group_manager` with a pending operation was incorrectly removed due to the operation no longer being present in the backend ([#18380](https://github.com/hashicorp/terraform-provider-google/pull/18380)) -* compute: fixed issue where users could not create `google_compute_security_policy` resources with `layer_7_ddos_defense_config` explicitly disabled ([#18345](https://github.com/hashicorp/terraform-provider-google/pull/18345)) -* workbench: fixed a bug in the `google_workbench_instance` resource where specifying a network in some scenarios would cause instance creation to fail ([#18404](https://github.com/hashicorp/terraform-provider-google/pull/18404) - -## 5.33.0 (June 10, 2024) - -DEPRECATIONS: -* healthcare: deprecated `notification_config` in `google_healthcare_fhir_store` resource. Use `notification_configs` instead. ([#18306](https://github.com/hashicorp/terraform-provider-google/pull/18306)) - -FEATURES: -* **New Data Source:** `google_compute_security_policy` ([#18316](https://github.com/hashicorp/terraform-provider-google/pull/18316)) -* **New Resource:** `google_compute_project_cloud_armor_tier` ([#18319](https://github.com/hashicorp/terraform-provider-google/pull/18319)) -* **New Resource:** `google_network_services_service_lb_policies` ([#18326](https://github.com/hashicorp/terraform-provider-google/pull/18326)) -* **New Resource:** `google_scc_management_organization_event_threat_detection_custom_module` ([#18317](https://github.com/hashicorp/terraform-provider-google/pull/18317)) -* **New Resource:** `google_spanner_instance_config` ([#18322](https://github.com/hashicorp/terraform-provider-google/pull/18322)) - -IMPROVEMENTS: -* appengine: added `flexible_runtime_settings` field to `google_app_engine_flexible_app_version` resource ([#18325](https://github.com/hashicorp/terraform-provider-google/pull/18325)) -* bigtable: added `force_destroy` field to `google_bigtable_instance` resource. This will force delete any backups present in the instance and allow the instance to be deleted. ([#18291](https://github.com/hashicorp/terraform-provider-google/pull/18291)) -* clouddeploy: added `execution_configs.verbose` field to `google_clouddeploy_target` resource ([#18292](https://github.com/hashicorp/terraform-provider-google/pull/18292)) -* compute: added `storage_pool` field to `google_compute_disk` resource ([#18273](https://github.com/hashicorp/terraform-provider-google/pull/18273)) -* dlp: added `secrets_discovery_target`, `cloud_sql_target.filter.database_resource_reference`, and `big_query_target.filter.table_reference` fields to `google_data_loss_prevention_discovery_config` resource ([#18324](https://github.com/hashicorp/terraform-provider-google/pull/18324)) -* gkebackup: added `backup_schedule.backup_config.permissive_mode` field to `google_gke_backup_backup_plan` resource ([#18266](https://github.com/hashicorp/terraform-provider-google/pull/18266)) -* gkebackup: added `restore_config.restore_order` field to `google_gke_backup_restore_plan` resource ([#18266](https://github.com/hashicorp/terraform-provider-google/pull/18266)) -* gkebackup: added `restore_config.volume_data_restore_policy_bindings` field to `google_gke_backup_restore_plan` resource ([#18266](https://github.com/hashicorp/terraform-provider-google/pull/18266)) -* gkebackup: added new enum values `MERGE_SKIP_ON_CONFLICT`, `MERGE_REPLACE_VOLUME_ON_CONFLICT` and `MERGE_REPLACE_ON_CONFLICT` to field `restore_config.namespaced_resource_restore_mode` in `google_gke_backup_restore_plan` resource ([#18266](https://github.com/hashicorp/terraform-provider-google/pull/18266)) -* healthcare: added `notification_config.send_for_bulk_import` field to `google_healthcare_dicom_store` resource ([#18320](https://github.com/hashicorp/terraform-provider-google/pull/18320)) -* healthcare: added `notification_configs` field to `google_healthcare_fhir_store` resource ([#18306](https://github.com/hashicorp/terraform-provider-google/pull/18306)) -* integrationconnectors: added `endpoint_global_access` field to `google_integration_connectors_endpoint_attachment` resource ([#18293](https://github.com/hashicorp/terraform-provider-google/pull/18293)) -* netapp: added `backup_config` field to `google_netapp_volume` resource ([#18286](https://github.com/hashicorp/terraform-provider-google/pull/18286)) -* redis: added `zone_distribution_config` field to `google_redis_cluster` resource ([#18307](https://github.com/hashicorp/terraform-provider-google/pull/18307)) -* resourcemanager: added support for `range_type = "default-domains-netblocks"` in `google_netblock_ip_ranges` data source ([#18290](https://github.com/hashicorp/terraform-provider-google/pull/18290)) -* secretmanager: added support for IAM conditions in `google_secret_manager_secret_iam_*` resources ([#18294](https://github.com/hashicorp/terraform-provider-google/pull/18294)) -* workstations: added `boot_disk_size_gb`, `enable_nested_virtualization`, and `pool_size` to `host.gce_instance.boost_configs` in `google_workstations_workstation_config` resource ([#18310](https://github.com/hashicorp/terraform-provider-google/pull/18310)) - -BUG FIXES: -* container: fixed `google_container_node_pool` crash if `node_config.secondary_boot_disks.mode` is not set ([#18323](https://github.com/hashicorp/terraform-provider-google/pull/18323)) -* dlp: removed `required` on `inspect_config.limits.max_findings_per_info_type.info_type` field to allow the use of default limit by not setting this field in `google_data_loss_prevention_inspect_template` resource ([#18285](https://github.com/hashicorp/terraform-provider-google/pull/18285)) -* provider: fixed application default credential and access token authorization when `universe_domain` is set ([#18272](https://github.com/hashicorp/terraform-provider-google/pull/18272)) - - -## 5.32.0 (June 3, 2024) - -NOTES: -* privateca: converted `google_privateca_certificate_template` to now use the MMv1 engine instead of DCL ([#18224](https://github.com/hashicorp/terraform-provider-google/pull/18224)) - -FEATURES: -* **New Resource:** `google_dataplex_entry_type` ([#18229](https://github.com/hashicorp/terraform-provider-google/pull/18229)) -* **New Resource:** `google_logging_log_view_iam_binding` ([#18243](https://github.com/hashicorp/terraform-provider-google/pull/18243)) -* **New Resource:** `google_logging_log_view_iam_member` ([#18243](https://github.com/hashicorp/terraform-provider-google/pull/18243)) -* **New Resource:** `google_logging_log_view_iam_policy` ([#18243](https://github.com/hashicorp/terraform-provider-google/pull/18243)) - -IMPROVEMENTS: -* alloydb: added `psc_config` field to `google_alloydb_cluster` resource ([#18263](https://github.com/hashicorp/terraform-provider-google/pull/18263)) -* alloydb: added `psc_instance_config` field to `google_alloydb_instance` resource ([#18263](https://github.com/hashicorp/terraform-provider-google/pull/18263)) -* cloudrunv2: added `default_uri_disabled` field to resource `google_cloud_run_v2_service` resource ([#18246](https://github.com/hashicorp/terraform-provider-google/pull/18246)) -* compute: added `NONE` to acceptable options for `update_policy.minimal_action` field in `google_compute_instance_group_manager` resource ([#18236](https://github.com/hashicorp/terraform-provider-google/pull/18236)) -* looker: increased validation length of `name` to `google_looker_instance` resource ([#18244](https://github.com/hashicorp/terraform-provider-google/pull/18244)) -* sql: updated support for a new value `week5` in field `setting.maintenance_window.update_track` in `google_sql_database_instance` resource ([#18223](https://github.com/hashicorp/terraform-provider-google/pull/18223)) - -BUG FIXES: -* cloudrunv2: added validation for `timeout` field to `google_cloud_run_v2_job` and `google_cloud_run_v2_service` resources ([#18260](https://github.com/hashicorp/terraform-provider-google/pull/18260)) -* compute: fixed permadiff in ordering of `advertised_ip_ranges.range` field on `google_compute_router` resource ([#18228](https://github.com/hashicorp/terraform-provider-google/pull/18228)) -* iam: added a 10 second sleep when creating a 'google_service_account' resource to reduce eventual consistency errors([#18261](https://github.com/hashicorp/terraform-provider-google/pull/18261)) -* storage: fixed `google_storage_bucket.lifecycle_rule.condition` block fields `days_since_noncurrent_time` and `days_since_custom_time` and `num_newer_versions` were not working for 0 value ([#18231](https://github.com/hashicorp/terraform-provider-google/pull/18231)) - -## 5.31.0 (May 28, 2024) - -FEATURES: -* **New Data Source:** `google_compute_subnetworks` ([#18159](https://github.com/hashicorp/terraform-provider-google/pull/18159)) -* **New Resource:** `google_dataplex_aspect_type` ([#18201](https://github.com/hashicorp/terraform-provider-google/pull/18201)) -* **New Resource:** `google_dataplex_entry_group` ([#18188](https://github.com/hashicorp/terraform-provider-google/pull/18188)) -* **New Resource:** `google_kms_autokey_config` ([#18179](https://github.com/hashicorp/terraform-provider-google/pull/18179)) -* **New Resource:** `google_kms_key_handle` ([#18179](https://github.com/hashicorp/terraform-provider-google/pull/18179)) -* **New Resource:** `google_network_services_lb_route_extension` ([#18195](https://github.com/hashicorp/terraform-provider-google/pull/18195)) - -IMPROVEMENTS: -* appengine: added field `instance_ip_mode` to resource `google_app_engine_flexible_app_version` resource (beta) ([#18168](https://github.com/hashicorp/terraform-provider-google/pull/18168)) -* bigquery: added `external_data_configuration.bigtable_options` to `google_bigquery_table` ([#18181](https://github.com/hashicorp/terraform-provider-google/pull/18181)) -* composer: added support for importing `google_composer_user_workloads_secret` via the "{{environment}}/{{name}}" format. ([#7390](https://github.com/hashicorp/terraform-provider-google-beta/pull/7390)) -* composer: improved timeouts for `google_composer_user_workloads_secret`. ([#7390](https://github.com/hashicorp/terraform-provider-google-beta/pull/7390)) -* compute: added `TLS_JA3_FINGERPRINT` and `USER_IP` options in field `rate_limit_options.enforce_on_key` to `google_compute_security_policy` resource ([#18167](https://github.com/hashicorp/terraform-provider-google/pull/18167)) -* compute: added 'rateLimitOptions' field to 'google_compute_security_policy_rule' resource ([#18167](https://github.com/hashicorp/terraform-provider-google/pull/18167)) -* compute: changed `google_compute_region_ssl_policy`'s `region` field to optional and allow to be inferred from environment ([#18178](https://github.com/hashicorp/terraform-provider-google/pull/18178)) -* compute: added `subnet_length` field to `google_compute_interconnect_attachment` resource ([#18187](https://github.com/hashicorp/terraform-provider-google/pull/18187)) -* container: added `containerd_config` field and subfields to `google_container_cluster` and `google_container_node_pool` resources, to allow those resources to access private image registries. ([#18160](https://github.com/hashicorp/terraform-provider-google/pull/18160)) -* container: allowed both `enable_autopilot` and `workload_identity_config` to be set in `google_container_cluster` resource. ([#18166](https://github.com/hashicorp/terraform-provider-google/pull/18166)) -* datastream: added `create_without_validation` field to `google_datastream_connection_profile`, `google_datastream_private_connection` and `google_datastream_stream` resources ([#18176](https://github.com/hashicorp/terraform-provider-google/pull/18176)) -* network-security: added `trust_config`, `min_tls_version`, `tls_feature_profile` and `custom_tls_features` fields to `google_network_security_tls_inspection_policy` resource ([#18139](https://github.com/hashicorp/terraform-provider-google/pull/18139)) -* networkservices: made field `load_balancing_scheme` immutable in resource `google_network_services_lb_traffic_extension`, as in-place updating is always failing ([#18195](https://github.com/hashicorp/terraform-provider-google/pull/18195)) -* networkservices: made required fields `extension_chains.extensions.authority ` and `extension_chains.extensions.timeout` optional in resource `google_network_services_lb_traffic_extension` ([#18195](https://github.com/hashicorp/terraform-provider-google/pull/18195)) -* networkservices: removed unsupported load balancing scheme `LOAD_BALANCING_SCHEME_UNSPECIFIED` from the field `load_balancing_scheme` in resource `google_network_services_lb_traffic_extension` ([#18195](https://github.com/hashicorp/terraform-provider-google/pull/18195)) -* pubsub: added `cloud_storage_config.filename_datetime_format` field to `google_pubsub_subscription` resource ([#18180](https://github.com/hashicorp/terraform-provider-google/pull/18180)) -* tpu: added `type` of `accelerator_config` to `google_tpu_v2_vm` resource ([#18148](https://github.com/hashicorp/terraform-provider-google/pull/18148)) - -BUG FIXES: -* monitoring: fixed a permadiff with `monitored_resource.labels` property in the `google_monitoring_uptime_check_config` resource ([#18174](https://github.com/hashicorp/terraform-provider-google/pull/18174)) -* storage: fixed a bug where field `autoclass` block is generating permadiff whenever the block is removed from the config in `google_storage_bucket` resource ([#18197](https://github.com/hashicorp/terraform-provider-google/pull/18197)) -* storagetransfer: fixed a permadiff with `transfer_spec.0.aws_s3_data_source.0.aws_access_key` `resource_storage_transfer_job` ([#18190](https://github.com/hashicorp/terraform-provider-google/pull/18190)) - -## 5.30.0 (May 20, 2024) - -FEATURES: -* **New Data Source:** `google_cloud_asset_resources_search_all` ([#18129](https://github.com/hashicorp/terraform-provider-google/pull/18129)) -* **New Resource:** `google_compute_interconnect` ([#18064](https://github.com/hashicorp/terraform-provider-google/pull/18064)) -* **New Resource:** `google_network_services_lb_traffic_extension` ([#18138](https://github.com/hashicorp/terraform-provider-google/pull/18138)) - -IMPROVEMENTS: -* compute: added `kms_key_name` field to `google_bigquery_connection` resource ([#18057](https://github.com/hashicorp/terraform-provider-google/pull/18057)) -* compute: added `auto_network_tier` field to `google_compute_router_nat` resource ([#18055](https://github.com/hashicorp/terraform-provider-google/pull/18055)) -* compute: promoted `enable_ipv4`, `ipv4_nexthop_address` and `peer_ipv4_nexthop_address` fields in `google_compute_router_peer` resource to GA ([#18056](https://github.com/hashicorp/terraform-provider-google/pull/18056)) -* compute: promoted `identifier_range` field in `google_compute_router` resource to GA ([#18056](https://github.com/hashicorp/terraform-provider-google/pull/18056)) -* compute: promoted `ip_version` field in `google_compute_router_interface` resource to GA ([#18056](https://github.com/hashicorp/terraform-provider-google/pull/18056)) -* container: added `KUBELET` and `CADVISOR` options to `monitoring_config.enable_components` in `google_container_cluster` resource ([#18090](https://github.com/hashicorp/terraform-provider-google/pull/18090)) -* dataproc: added `local_ssd_interface` to `google_dataproc_cluster` resource ([#18137](https://github.com/hashicorp/terraform-provider-google/pull/18137)) -* dataprocmetastore: promoted `google_dataproc_metastore_federation` to GA ([#18084](https://github.com/hashicorp/terraform-provider-google/pull/18084)) -* dlp: added `cloud_sql_target` field to `google_data_loss_prevention_discovery_config` resource ([#18063](https://github.com/hashicorp/terraform-provider-google/pull/18063)) -* netapp: added `FLEX` value to field `service_level` in `google_netapp_storage_pool` resource ([#18088](https://github.com/hashicorp/terraform-provider-google/pull/18088)) -* networksecurity: added `trust_config`, `min_tls_version`, `tls_feature_profile` and `custom_tls_features` fields to `google_network_security_tls_inspection_policy` resource ([#18139](https://github.com/hashicorp/terraform-provider-google/pull/18139)) -* networkservices: supported in-place update for `gateway_security_policy` and `certificate_urls` fields in `google_network_services_gateway` resource ([#18082](https://github.com/hashicorp/terraform-provider-google/pull/18082)) - -BUG FIXES: -* compute: fixed a perma-diff on `machine_type` field in `google_compute_instance` resource ([#18071](https://github.com/hashicorp/terraform-provider-google/pull/18071)) -* compute: fixed a perma-diff on `type` field in `google_compute_disk` resource ([#18071](https://github.com/hashicorp/terraform-provider-google/pull/18071)) -* storage: fixed update issue for `lifecycle_rule.condition.custom_time_before` and `lifecycle_rule.condition.noncurrent_time_before` in `google_storage_bucket` resource ([#18127](https://github.com/hashicorp/terraform-provider-google/pull/18127)) - -## 5.29.1 (May 14, 2024) - -BREAKING CHANGES: -* compute: removed `secondary_ip_range.reserved_internal_range` field from `google_compute_subnetwork` ([18133](https://github.com/hashicorp/terraform-provider-google/pull/18133)) - -## 5.29.0 (May 13, 2024) - -NOTES: -* compute: added documentation for `md5_authentication_key` field in `google_compute_router_peer` resource. The field was introduced in [v5.12.0](https://github.com/hashicorp/terraform-provider-google/releases/tag/v5.12.0), but documentation was unintentionally omitted at that time. ([#17991](https://github.com/hashicorp/terraform-provider-google/pull/17991)) - -FEATURES: -* **New Resource:** `google_bigtable_authorized_view` ([#18006](https://github.com/hashicorp/terraform-provider-google/pull/18006)) -* **New Resource:** `google_integration_connectors_managed_zone` ([#18029](https://github.com/hashicorp/terraform-provider-google/pull/18029)) -* **New Resource:** `google_network_connectivity_regional_endpoint` ([#18014](https://github.com/hashicorp/terraform-provider-google/pull/18014)) -* **New Resource:** `google_network_security_security_profile` ([#18025](https://github.com/hashicorp/terraform-provider-google/pull/18025)) -* **New Resource:** `google_network_security_security_profile_group` ([#18025](https://github.com/hashicorp/terraform-provider-google/pull/18025)) -* **New Resource:** `google_network_security_firewall_endpoint` ([#18025](https://github.com/hashicorp/terraform-provider-google/pull/18025)) -* **New Resource:** `google_network_security_firewall_endpoint_association` ([#18025](https://github.com/hashicorp/terraform-provider-google/pull/18025)) - -IMPROVEMENTS: -* clouddeploy: added `custom_target` field to `google_clouddeploy_target` resource ([#18000](https://github.com/hashicorp/terraform-provider-google/pull/18000)) -* clouddeploy: added `google_cloud_build_repo` to `custom_target_type` resource ([#18040](https://github.com/hashicorp/terraform-provider-google/pull/18040)) -* compute: added `preconfigured_waf_config` field to `google_compute_region_security_policy_rule` resource; ([#18039](https://github.com/hashicorp/terraform-provider-google/pull/18039)) -* compute: added `rate_limit_options` field to `google_compute_region_security_policy_rule` resource; ([#18039](https://github.com/hashicorp/terraform-provider-google/pull/18039)) -* compute: added `security_profile_group`, `tls_inspect` to `google_compute_firewall_policy_rule` ([#18000](https://github.com/hashicorp/terraform-provider-google/pull/18000)) -* compute: added `security_profile_group`, `tls_inspect` to `google_compute_network_firewall_policy_rule` ([#18000](https://github.com/hashicorp/terraform-provider-google/pull/18000)) -* compute: added fields `reserved_internal_range` and `secondary_ip_ranges.reserved_internal_range` to `google_compute_subnetwork` resource ([#18026](https://github.com/hashicorp/terraform-provider-google/pull/18026)) -* container: added `dns_config.additive_vpc_scope_dns_domain` field to `google_container_cluster` resource ([#18031](https://github.com/hashicorp/terraform-provider-google/pull/18031)) -* container: added `enable_nested_virtualization` field to `google_container_node_pool` and `google_container_cluster` resource. ([#18015](https://github.com/hashicorp/terraform-provider-google/pull/18015)) -* iam: added `extra_attributes_oauth2_client` field to `google_iam_workforce_pool_provider` resource ([#18027](https://github.com/hashicorp/terraform-provider-google/pull/18027)) -* privateca: added `maximum_lifetime` field to `google_privateca_certificate_template` resource ([#18000](https://github.com/hashicorp/terraform-provider-google/pull/18000)) - -## 5.28.0 (May 6, 2024) - -DEPRECATIONS: -* integrations: deprecated `create_sample_workflows` and `provision_gmek` fields in `google_integrations_client`. ([#17945](https://github.com/hashicorp/terraform-provider-google/pull/17945)) - -FEATURES: -* **New Data Source:** `google_storage_buckets` ([#17960](https://github.com/hashicorp/terraform-provider-google/pull/17960)) -* **New Resource:** `google_compute_security_policy_rule` ([#17937](https://github.com/hashicorp/terraform-provider-google/pull/17937)) - -IMPROVEMENTS: -* alloydb: added `maintenance_update_policy` field to `google_alloydb_cluster` resource ([#17954](https://github.com/hashicorp/terraform-provider-google/pull/17954)) -* bigquery: promoted `external_dataset_reference` in `google_bigquery_dataset` to GA ([#17944](https://github.com/hashicorp/terraform-provider-google/pull/17944)) -* composer: promoted `config.software_config.image_version` in-place update to GA in resource `google_composer_environment` ([#17986](https://github.com/hashicorp/terraform-provider-google/pull/17986)) -* container: added `node_config.secondary_boot_disks` field to `google_container_node_pool` ([#17962](https://github.com/hashicorp/terraform-provider-google/pull/17962)) -* integrations: added `create_sample_integrations` field to `google_integrations_client`, replacing deprecated field `create_sample_workflows`. ([#17945](https://github.com/hashicorp/terraform-provider-google/pull/17945)) -* redis: added `redis_configs` field to `google_redis_cluster` resource ([#17956](https://github.com/hashicorp/terraform-provider-google/pull/17956)) - -BUG FIXES: -* dns: fixed bug where the deletion of `google_dns_managed_zone` resources was blocked by any associated SOA-type `google_dns_record_set` resources ([#17989](https://github.com/hashicorp/terraform-provider-google/pull/17989)) -* storage: fixed an issue where `google_storage_bucket_object` and `google_storage_bucket_objects` data sources would ignore custom endpoints ([#17952](https://github.com/hashicorp/terraform-provider-google/pull/17952)) - -## 5.27.0 (Apr 30, 2024) - -FEATURES: -* **New Data Source:** `google_storage_bucket_objects` ([#17920](https://github.com/hashicorp/terraform-provider-google/pull/17920)) -* **New Resource:** `google_compute_security_policy_rule` ([#17937](https://github.com/hashicorp/terraform-provider-google/pull/17937)) -* **New Resource:** `google_data_loss_prevention_discovery_config` ([#17887](https://github.com/hashicorp/terraform-provider-google/pull/17887)) -* **New Resource:** `google_integrations_auth_config` ([#17917](https://github.com/hashicorp/terraform-provider-google/pull/17917)) -* **New Resource:** `google_network_connectivity_internal_range` ([#17909](https://github.com/hashicorp/terraform-provider-google/pull/17909)) - -IMPROVEMENTS: -* alloydb: added `network_config` field to `google_alloydb_instance` resource ([#17921](https://github.com/hashicorp/terraform-provider-google/pull/17921)) -* alloydb: added `public_ip_address` field to `google_alloydb_instance` resource ([#17921](https://github.com/hashicorp/terraform-provider-google/pull/17921)) -* apigee: added `forward_proxy_uri` field to `google_apigee_environment` resource ([#17902](https://github.com/hashicorp/terraform-provider-google/pull/17902)) -* bigquerydatapolicy: added `data_masking_policy.routine` field to `google_bigquery_data_policy` resource ([#17885](https://github.com/hashicorp/terraform-provider-google/pull/17885)) -* compute: added `server_tls_policy` field to `google_compute_region_target_https_proxy` resource ([#17934](https://github.com/hashicorp/terraform-provider-google/pull/17934)) -* logging: added `intercept_children` field to `google_logging_organization_sink` and `google_logging_folder_sink` resources ([#17932](https://github.com/hashicorp/terraform-provider-google/pull/17932)) -* monitoring: added `service_agent_authentication` field to `google_monitoring_uptime_check_config` resource ([#17929](https://github.com/hashicorp/terraform-provider-google/pull/17929)) -* privateca: added `subject_key_id` field to `google_privateca_certificate` and `google_privateca_certificate_authority` resources ([#17923](https://github.com/hashicorp/terraform-provider-google/pull/17923)) -* secretmanager: added `version_destroy_ttl` field to `google_secret_manager_secret` resource ([#17888](https://github.com/hashicorp/terraform-provider-google/pull/17888)) - -BUG FIXES: -* appengine: added suppression for a diff in `google_app_engine_standard_app_version.automatic_scaling` when the block is unset in configuration ([#17905](https://github.com/hashicorp/terraform-provider-google/pull/17905)) -* sql: fixed issues with updating the `enable_google_ml_integration` field in `google_sql_database_instance` resource ([#17878](https://github.com/hashicorp/terraform-provider-google/pull/17878)) - -## 5.26.0 (Apr 22, 2024) - -FEATURES: -* **New Resource:** `google_project_iam_member_remove` ([#17871](https://github.com/hashicorp/terraform-provider-google/pull/17871)) - -IMPROVEMENTS: -* apigee: added support for `api_consumer_data_location`, `api_consumer_data_encryption_key_name`, and `control_plane_encryption_key_name` in `google_apigee_organization` ([#17874](https://github.com/hashicorp/terraform-provider-google/pull/17874)) -* artifactregistry: added `remote_repository_config._repository.custom_repository.uri` field to `google_artifact_registry_repository` resource. ([#17840](https://github.com/hashicorp/terraform-provider-google/pull/17840)) -* bigquery: added `resource_tags` field to `google_bigquery_table` resource ([#17876](https://github.com/hashicorp/terraform-provider-google/pull/17876)) -* billing: added `ownership_scope` field to `google_billing_budget` resource ([#17868](https://github.com/hashicorp/terraform-provider-google/pull/17868)) -* cloudfunctions2: added `build_config.service_account` field to `google_cloudfunctions2_function` resource ([#17841](https://github.com/hashicorp/terraform-provider-google/pull/17841)) -* resourcemanager: added the field `api_method` to datasource `google_active_folder` so you can use either `SEARCH` or `LIST` to find your folder ([#17877](https://github.com/hashicorp/terraform-provider-google/pull/17877)) -* storage: added labels validation to `google_storage_bucket` resource ([#17806](https://github.com/hashicorp/terraform-provider-google/pull/17806)) - -BUG FIXES: -* apigee: fixed permadiff in ordering of `google_apigee_organization.properties.property`. ([#17850](https://github.com/hashicorp/terraform-provider-google/pull/17850)) -* cloudrun: fixed the bug that computed `metadata.0.labels` and `metadata.0.annotations` fields don't appear in terraform plan when creating resource `google_cloud_run_service` and `google_cloud_run_domain_mapping` ([#17815](https://github.com/hashicorp/terraform-provider-google/pull/17815)) -* dns: fixed bug where some methods of authentication didn't work when using `dns` data sources ([#17847](https://github.com/hashicorp/terraform-provider-google/pull/17847)) -* iam: fixed a bug that prevented setting `create_ignore_already_exists` on existing resources in `google_service_account`. ([#17856](https://github.com/hashicorp/terraform-provider-google/pull/17856)) -* sql: fixed issues with updating the `enable_google_ml_integration` field in `google_sql_database_instance` resource ([#17878](https://github.com/hashicorp/terraform-provider-google/pull/17878)) -* storage: added validation to `name` field in `google_storage_bucket` resource ([#17858](https://github.com/hashicorp/terraform-provider-google/pull/17858)) -* vmwareengine: fixed stretched cluster creation in `google_vmwareengine_private_cloud` ([#17875](https://github.com/hashicorp/terraform-provider-google/pull/17875)) - -## 5.25.0 (Apr 15, 2024) - -FEATURES: -* **New Data Source:** `google_tags_tag_keys` ([#17782](https://github.com/hashicorp/terraform-provider-google/pull/17782)) -* **New Data Source:** `google_tags_tag_values` ([#17782](https://github.com/hashicorp/terraform-provider-google/pull/17782)) - -IMPROVEMENTS: -* bigquery: added in-place schema column drop support for `google_bigquery_table` resource ([#17777](https://github.com/hashicorp/terraform-provider-google/pull/17777)) -* compute: added `endpoint_types` field to `google_compute_router_nat` resource ([#17771](https://github.com/hashicorp/terraform-provider-google/pull/17771)) -* compute: increased timeouts from 8 minutes to 20 minutes for `google_compute_security_policy` resource ([#17793](https://github.com/hashicorp/terraform-provider-google/pull/17793)) -* compute: promoted `google_compute_instance_settings` to GA ([#17781](https://github.com/hashicorp/terraform-provider-google/pull/17781)) -* container: added `stateful_ha_config` field to `google_container_cluster` resource ([#17796](https://github.com/hashicorp/terraform-provider-google/pull/17796)) -* firestore: added `vector_config` field to `google_firestore_index` resource ([#17758](https://github.com/hashicorp/terraform-provider-google/pull/17758)) -* gkebackup: added `backup_schedule.rpo_config` field to `google_gke_backup_backup_plan` resource ([#17805](https://github.com/hashicorp/terraform-provider-google/pull/17805)) -* networksecurity: added `disabled` field to `google_network_security_firewall_endpoint_association` resource; ([#17762](https://github.com/hashicorp/terraform-provider-google/pull/17762)) -* sql: added `enable_google_ml_integration` field to `google_sql_database_instance` resource ([#17798](https://github.com/hashicorp/terraform-provider-google/pull/17798)) -* storage: added labels validation to `google_storage_bucket` resource ([#17806](https://github.com/hashicorp/terraform-provider-google/pull/17806)) -* vmwareengine: added `preferred_zone` and `secondary_zone` fields to `google_vmwareengine_private_cloud` resource ([#17803](https://github.com/hashicorp/terraform-provider-google/pull/17803)) - -BUG FIXES: -* networksecurity: fixed an issue where `google_network_security_firewall_endpoint_association` resources could not be created due to a bad parameter ([#17762](https://github.com/hashicorp/terraform-provider-google/pull/17762)) -* privateca: fixed permission issue by specifying signer certs chain when activating a sub-CA across regions for `google_privateca_certificate_authority` resource ([#17783](https://github.com/hashicorp/terraform-provider-google/pull/17783)) - -## 5.24.0 (Apr 8, 2024) - -IMPROVEMENTS: -* container: added `enable_cilium_clusterwide_network_policy` field to `google_container_cluster` resource ([#17738](https://github.com/hashicorp/terraform-provider-google/pull/17738)) -* container: added `node_pool_auto_config.resource_manager_tags` field to `google_container_cluster` resource ([#17715](https://github.com/hashicorp/terraform-provider-google/pull/17715)) -* gkeonprem: added `disable_bundled_ingress` field to `google_gkeonprem_vmware_cluster` resource ([#17718](https://github.com/hashicorp/terraform-provider-google/pull/17718)) -* redis: added `node_type` and `precise_size_gb` fields to `google_redis_cluster` ([#17742](https://github.com/hashicorp/terraform-provider-google/pull/17742)) -* storage: added `project_number` attribute to `google_storage_bucket` resource and data source ([#17719](https://github.com/hashicorp/terraform-provider-google/pull/17719)) -* storage: added ability to provide `project` argument to `google_storage_bucket` data source. This will not impact reading the resource's data, instead this helps users avoid calls to the Compute API within the data source. ([#17719](https://github.com/hashicorp/terraform-provider-google/pull/17719)) - -BUG FIXES: -* appengine: fixed a crash in `google_app_engine_flexible_app_version` due to the `deployment` field not being returned by the API ([#17744](https://github.com/hashicorp/terraform-provider-google/pull/17744)) -* bigquery: fixed a crash when `google_bigquery_table` had a `primary_key.columns` entry set to `""` ([#17721](https://github.com/hashicorp/terraform-provider-google/pull/17721)) -* compute: fixed update scenarios on`google_compute_region_target_https_proxy` and `google_compute_target_https_proxy` resources. ([#17733](https://github.com/hashicorp/terraform-provider-google/pull/17733)) - -## 5.23.0 (Apr 1, 2024) - -NOTES: -* provider: introduced support for [provider-defined functions](https://developer.hashicorp.com/terraform/plugin/framework/functions). This feature is in Terraform v1.8.0+. ([#17694](https://github.com/hashicorp/terraform-provider-google/pull/17694)) - -DEPRECATIONS: -* kms: deprecated `attestation.external_protection_level_options` in favor of `external_protection_level_options` in `google_kms_crypto_key_version` ([#17704](https://github.com/hashicorp/terraform-provider-google/pull/17704)) - -FEATURES: -* **New Data Source:** `google_apphub_application` ([#17679](https://github.com/hashicorp/terraform-provider-google/pull/17679)) -* **New Resource:** `google_cloud_quotas_quota_preference` ([#17637](https://github.com/hashicorp/terraform-provider-google/pull/17637)) -* **New Resource:** `google_vertex_ai_deployment_resource_pool` ([#17707](https://github.com/hashicorp/terraform-provider-google/pull/17707)) -* **New Resource:** `google_integrations_client` ([#17640](https://github.com/hashicorp/terraform-provider-google/pull/17640)) - -IMPROVEMENTS: -* bigquery: added `dataGovernanceType` to `google_bigquery_routine` resource ([#17689](https://github.com/hashicorp/terraform-provider-google/pull/17689)) -* bigquery: added support for `external_data_configuration.json_extension` to `google_bigquery_table` ([#17663](https://github.com/hashicorp/terraform-provider-google/pull/17663)) -* compute: added `cloud_router_ipv6_address`, `customer_router_ipv6_address` fields to `google_compute_interconnect_attachment` resource ([#17692](https://github.com/hashicorp/terraform-provider-google/pull/17692)) -* compute: added `generated_id` field to `google_compute_region_backend_service` resource ([#17639](https://github.com/hashicorp/terraform-provider-google/pull/17639)) -* integrations: added deletion support for `google_integrations_client` resource ([#17678](https://github.com/hashicorp/terraform-provider-google/pull/17678)) -* kms: added `crypto_key_backend` field to `google_kms_crypto_key` resource ([#17704](https://github.com/hashicorp/terraform-provider-google/pull/17704)) -* metastore: added `scheduled_backup` field to `google_dataproc_metastore_service` resource ([#17673](https://github.com/hashicorp/terraform-provider-google/pull/17673)) -* provider: added provider-defined function `name_from_id` for retrieving the short-form name of a resource from its self link or id ([#17694](https://github.com/hashicorp/terraform-provider-google/pull/17694)) -* provider: added provider-defined function `project_from_id` for retrieving the project id from a resource's self link or id ([#17694](https://github.com/hashicorp/terraform-provider-google/pull/17694)) -* provider: added provider-defined function `region_from_zone` for deriving a region from a zone's name ([#17694](https://github.com/hashicorp/terraform-provider-google/pull/17694)) -* provider: added provider-defined functions `location_from_id`, `region_from_id`, and `zone_from_id` for retrieving the location/region/zone names from a resource's self link or id ([#17694](https://github.com/hashicorp/terraform-provider-google/pull/17694)) - -BUG FIXES: -* cloudrunv2: fixed Terraform state inconsistency when resource `google_cloud_run_v2_job` creation fails ([#17711](https://github.com/hashicorp/terraform-provider-google/pull/17711)) -* cloudrunv2: fixed Terraform state inconsistency when resource `google_cloud_run_v2_service` creation fails ([#17711](https://github.com/hashicorp/terraform-provider-google/pull/17711)) -* container: fixed `google_container_cluster` permadiff when `master_ipv4_cidr_block` is set for a private flexible cluster ([#17687](https://github.com/hashicorp/terraform-provider-google/pull/17687)) -* dataflow: fixed an issue where the provider would crash when `enableStreamingEngine` is set as a `parameter` value in `google_dataflow_flex_template_job` ([#17712](https://github.com/hashicorp/terraform-provider-google/pull/17712)) -* kms: added top-level `external_protection_level_options` field in `google_kms_crypto_key_version` resource ([#17704](https://github.com/hashicorp/terraform-provider-google/pull/17704)) - -## 5.22.0 (Mar 26, 2024) - -BREAKING CHANGES: -* networksecurity: added required field `billing_project_id` to `google_network_security_firewall_endpoint` resource. Any configuration without `billing_project_id` specified will cause resource creation fail (beta) ([#17630](https://github.com/hashicorp/terraform-provider-google/pull/17630)) - -FEATURES: -* **New Data Source:** `google_cloud_quotas_quota_info` ([#17564](https://github.com/hashicorp/terraform-provider-google/pull/17564)) -* **New Data Source:** `google_cloud_quotas_quota_infos` ([#17617](https://github.com/hashicorp/terraform-provider-google/pull/17617)) -* **New Resource:** `google_access_context_manager_service_perimeter_dry_run_resource` ([#17614](https://github.com/hashicorp/terraform-provider-google/pull/17614)) - -IMPROVEMENTS: -* accesscontextmanager: supported managing service perimeter dry run resources outside the perimeter via new resource `google_access_context_manager_service_perimeter_dry_run_resource` ([#17614](https://github.com/hashicorp/terraform-provider-google/pull/17614)) -* cloudrunv2: added plan-time validation to restrict number of ports to 1 in `google_cloud_run_v2_service` ([#17594](https://github.com/hashicorp/terraform-provider-google/pull/17594)) -* composer: added field `count` to validate number of DAG processors in `google_composer_environment` ([#17625](https://github.com/hashicorp/terraform-provider-google/pull/17625)) -* compute: added enumeration value `SEV_LIVE_MIGRATABLE_V2` for the `guest_os_features` of `google_compute_disk` ([#17629](https://github.com/hashicorp/terraform-provider-google/pull/17629)) -* compute: added `status.all_instances_config.revision` field to `google_compute_instance_group_manager` and `google_compute_region_instance_group_manager` ([#17595](https://github.com/hashicorp/terraform-provider-google/pull/17595)) -* compute: added field `path_template_match` to resource `google_compute_region_url_map` ([#17571](https://github.com/hashicorp/terraform-provider-google/pull/17571)) -* compute: added field `path_template_rewrite` to resource `google_compute_region_url_map` ([#17571](https://github.com/hashicorp/terraform-provider-google/pull/17571)) -* pubsub: added `ingestion_data_source_settings` field to `google_pubsub_topic` resource ([#17604](https://github.com/hashicorp/terraform-provider-google/pull/17604)) -* storage: added 'soft_delete_policy' to 'google_storage_bucket' resource ([#17624](https://github.com/hashicorp/terraform-provider-google/pull/17624)) - -BUG FIXES: -* accesscontextmanager: fixed an issue with `access_context_manager_service_perimeter_ingress_policy` and `access_context_manager_service_perimeter_egress_policy` where updates could not be applied after initial creation. Any updates applied to these resources will now involve their recreation. To ensure that new policies are added before old ones are removed, add a `lifecycle` block with `create_before_destroy = true` to your resource configuration alongside other updates. ([#17596](https://github.com/hashicorp/terraform-provider-google/pull/17596)) -* firebase: made the `google_firebase_android_app` resource's `package_name` field required and immutable. This prevents API errors encountered by users who attempted to update or leave that field unset in their configurations. ([#17585](https://github.com/hashicorp/terraform-provider-google/pull/17585)) -* spanner: removed validation function for the field `version_retention_period` in the resource `google_spanner_database` and directly returned error from backend ([#17621](https://github.com/hashicorp/terraform-provider-google/pull/17621)) - -## 5.21.0 (Mar 18, 2024) +## 5.21.0 (Unreleased) FEATURES: * **New Data Source:** `google_apphub_discovered_service` ([#17548](https://github.com/hashicorp/terraform-provider-google/pull/17548)) * **New Data Source:** `google_apphub_discovered_workload` ([#17553](https://github.com/hashicorp/terraform-provider-google/pull/17553)) -* **New Data Source:** `google_cloud_quotas_quota_info` ([#17564](https://github.com/hashicorp/terraform-provider-google/pull/17564)) * **New Resource:** `google_apphub_workload` ([#17561](https://github.com/hashicorp/terraform-provider-google/pull/17561)) * **New Resource:** `google_firebase_app_check_device_check_config` ([#17517](https://github.com/hashicorp/terraform-provider-google/pull/17517)) * **New Resource:** `google_iap_tunnel_dest_group` ([#17533](https://github.com/hashicorp/terraform-provider-google/pull/17533)) @@ -442,6 +10,7 @@ FEATURES: * **New Resource:** `google_apphub_application` ([#17499](https://github.com/hashicorp/terraform-provider-google/pull/17499)) * **New Resource:** `google_apphub_service` ([#17562](https://github.com/hashicorp/terraform-provider-google/pull/17562)) * **New Resource:** `google_apphub_service_project_attachment` ([#17536](https://github.com/hashicorp/terraform-provider-google/pull/17536)) +* **New Resource:** `google_cloud_quotas_quota_info` ([#17564](https://github.com/hashicorp/terraform-provider-google/pull/17564)) * **New Resource:** `google_network_security_firewall_endpoint_association` ([#17540](https://github.com/hashicorp/terraform-provider-google/pull/17540)) IMPROVEMENTS: @@ -1097,14 +666,6 @@ BUG FIXES: * tags: fixed import failure on `google_tags_tag_binding` ([#16005](https://github.com/hashicorp/terraform-provider-google/pull/16005)) * vertexai: made `contents_delta_uri` a required field in `google_vertex_ai_index` as omitting it would result in an error ([#15992](https://github.com/hashicorp/terraform-provider-google/pull/15992)) -## 4.85.0 (June 12, 2024) - -NOTES: -* The `4.85.0` release backports configuration for the retention period for Cloud Storage soft delete (https://cloud.google.com/resources/storage/soft-delete-announce) so that customers who have not yet upgraded to `5.22.0`+ are able to configure the retention period of objects in their buckets. By upgrading to this version and configuring or otherwise interacting with the `google_storage_bucket.soft_delete_policy` values, you will need to upgrade directly to `5.22.0`+ from `4.85.0` when upgrading to `5.X` in the future. - -IMPROVEMENTS: -* storage: added `soft_delete_policy` to `google_storage_bucket` resource ([#17624](https://github.com/hashicorp/terraform-provider-google/pull/17624)) - ## 4.84.0 (September 26, 2023) DEPRECATIONS: diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/GNUmakefile b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/GNUmakefile index 3f9923fa4ed..fd0cb88ea47 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/GNUmakefile +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/GNUmakefile @@ -1,4 +1,4 @@ -TEST?=$$(go list -e ./... | grep -v github.com/hashicorp/terraform-provider-google/scripts) +TEST?=$$(go list ./... | grep -v github.com/hashicorp/terraform-provider-google/scripts) WEBSITE_REPO=github.com/hashicorp/terraform-website PKG_NAME=google DIR_NAME=google diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/envvar/envvar_utils.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/envvar/envvar_utils.go index 75f310984d4..7c2857cc2d4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/envvar/envvar_utils.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/envvar/envvar_utils.go @@ -21,18 +21,6 @@ var CredsEnvVars = []string{ "GOOGLE_USE_DEFAULT_CREDENTIALS", } -// CredsEnvVarsExcludingAdcs returns the contents of CredsEnvVars excluding GOOGLE_APPLICATION_CREDENTIALS -func CredsEnvVarsExcludingAdcs() []string { - envs := CredsEnvVars - var filtered []string - for _, e := range envs { - if e != "GOOGLE_APPLICATION_CREDENTIALS" { - filtered = append(filtered, e) - } - } - return filtered -} - var ProjectNumberEnvVars = []string{ "GOOGLE_PROJECT_NUMBER", } @@ -43,6 +31,10 @@ var ProjectEnvVars = []string{ "CLOUDSDK_CORE_PROJECT", } +var FirestoreProjectEnvVars = []string{ + "GOOGLE_FIRESTORE_PROJECT", +} + var RegionEnvVars = []string{ "GOOGLE_REGION", "GCLOUD_REGION", @@ -150,6 +142,13 @@ func GetTestIdentityUserFromEnv(t *testing.T) string { return transport_tpg.MultiEnvSearch(IdentityUserEnvVars) } +// Firestore can't be enabled at the same time as Datastore, so we need a new +// project to manage it until we can enable Firestore programmatically. +func GetTestFirestoreProjectFromEnv(t *testing.T) string { + SkipIfEnvNotSet(t, FirestoreProjectEnvVars...) + return transport_tpg.MultiEnvSearch(FirestoreProjectEnvVars) +} + // Returns the raw organization id like 1234567890, skipping the test if one is // not found. func GetTestOrgFromEnv(t *testing.T) string { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/element_from_id.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/element_from_id.go deleted file mode 100644 index 68eb0b0b42c..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/element_from_id.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "fmt" - "log" - "regexp" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -// ValidateElementFromIdArguments is reusable validation logic used in provider-defined functions that use the GetElementFromId function -func ValidateElementFromIdArguments(ctx context.Context, input string, regex *regexp.Regexp, pattern string, functionName string) *function.FuncError { - submatches := regex.FindAllStringSubmatchIndex(input, -1) - - // Zero matches means unusable input; error returned - if len(submatches) == 0 { - return function.NewArgumentFuncError(0, fmt.Sprintf("The input string \"%s\" doesn't contain the expected pattern \"%s\".", input, pattern)) - } - - // >1 matches means input usable but not ideal; debug log - if len(submatches) > 1 { - log.Printf("[DEBUG] Provider-defined function %s was called with input string: %s. This contains more than one match for the pattern %s. Terraform will use the first found match.", functionName, input, pattern) - } - - return nil -} - -// GetElementFromId is reusable logic that is used in multiple provider-defined functions for pulling elements out of self links and ids of resources and data sources -func GetElementFromId(input string, regex *regexp.Regexp, template string) string { - submatches := regex.FindAllStringSubmatchIndex(input, -1) - submatch := submatches[0] // Take the only / left-most submatch - dst := []byte{} - return string(regex.ExpandString(dst, template, input, submatch)) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/location_from_id.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/location_from_id.go deleted file mode 100644 index 5d8a92972fa..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/location_from_id.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "regexp" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = LocationFromIdFunction{} - -func NewLocationFromIdFunction() function.Function { - return &LocationFromIdFunction{ - name: "location_from_id", - } -} - -type LocationFromIdFunction struct { - name string // Makes function name available in Run logic for logging purposes -} - -func (f LocationFromIdFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = f.name -} - -func (f LocationFromIdFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Summary: "Returns the location name within a provided resource id, self link, or OP style resource name.", - Description: "Takes a single string argument, which should be a resource id, self link, or OP style resource name. This function will either return the location name from the input string or raise an error due to no location being present in the string. The function uses the presence of \"locations/{{location}}/\" in the input string to identify the location name, e.g. when the function is passed the id \"projects/my-project/locations/us-central1/services/my-service\" as an argument it will return \"us-central1\".", - Parameters: []function.Parameter{ - function.StringParameter{ - Name: "id", - Description: "A string of a resource's id, a resource's self link, or an OP style resource name. For example, \"projects/my-project/locations/us-central1/services/my-service\" and \"https://run.googleapis.com/v2/projects/my-project/locations/us-central1/services/my-service\" are valid values containing locations", - }, - }, - Return: function.StringReturn{}, - } -} - -func (f LocationFromIdFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - // Load arguments from function call - var arg0 string - resp.Error = function.ConcatFuncErrors(req.Arguments.GetArgument(ctx, 0, &arg0)) - if resp.Error != nil { - return - } - - // Prepare how we'll identify location name from input string - regex := regexp.MustCompile("locations/(?P[^/]+)/") // Should match the pattern below - template := "$LocationName" // Should match the submatch identifier in the regex - pattern := "locations/{location}/" // Human-readable pseudo-regex pattern used in errors and warnings - - // Validate input - resp.Error = function.ConcatFuncErrors(ValidateElementFromIdArguments(ctx, arg0, regex, pattern, f.name)) - if resp.Error != nil { - return - } - - // Get and return element from input string - location := GetElementFromId(arg0, regex, template) - resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, location)) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/name_from_id.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/name_from_id.go deleted file mode 100644 index 061fdf13614..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/name_from_id.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "regexp" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = NameFromIdFunction{} - -func NewNameFromIdFunction() function.Function { - return &NameFromIdFunction{ - name: "name_from_id", - } -} - -type NameFromIdFunction struct { - name string -} - -func (f NameFromIdFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = f.name -} - -func (f NameFromIdFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Summary: "Returns the short-form name of a resource within a provided resource's id, resource URI, self link, or full resource name.", - Description: "Takes a single string argument, which should be a resource's id, resource URI, self link, or full resource name. This function will return the short-form name of a resource from the input string, or raise an error due to a problem with the input string. The function returns the final element in the input string as the resource's name, e.g. when the function is passed the id \"projects/my-project/zones/us-central1-c/instances/my-instance\" as an argument it will return \"my-instance\".", - Parameters: []function.Parameter{ - function.StringParameter{ - Name: "id", - Description: "A string of a resource's id, resource URI, self link, or full resource name. For example, \"projects/my-project/zones/us-central1-c/instances/my-instance\", \"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instances/my-instance\" and \"//gkehub.googleapis.com/projects/my-project/locations/us-central1/memberships/my-membership\" are valid values", - }, - }, - Return: function.StringReturn{}, - } -} - -func (f NameFromIdFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - // Load arguments from function call - var arg0 string - resp.Error = function.ConcatFuncErrors(req.Arguments.GetArgument(ctx, 0, &arg0)) - if resp.Error != nil { - return - } - - // Prepare how we'll identify resource name from input string - regex := regexp.MustCompile("/(?P[^/]+)$") // Should match the pattern below - template := "$ResourceName" // Should match the submatch identifier in the regex - pattern := "resourceType/{name}$" // Human-readable pseudo-regex pattern used in errors and warnings - - // Validate input - resp.Error = function.ConcatFuncErrors(ValidateElementFromIdArguments(ctx, arg0, regex, pattern, f.name)) - if resp.Error != nil { - return - } - - // Get and return element from input string - name := GetElementFromId(arg0, regex, template) - resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, name)) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/project_from_id.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/project_from_id.go deleted file mode 100644 index 7c76515ea03..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/project_from_id.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "regexp" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = ProjectFromIdFunction{} - -func NewProjectFromIdFunction() function.Function { - return &ProjectFromIdFunction{ - name: "project_from_id", - } -} - -type ProjectFromIdFunction struct { - name string // Makes function name available in Run logic for logging purposes -} - -func (f ProjectFromIdFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = f.name -} - -func (f ProjectFromIdFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Summary: "Returns the project within a provided resource's id, resource URI, self link, or full resource name.", - Description: "Takes a single string argument, which should be a resource's id, resource URI, self link, or full resource name. This function will either return the project name from the input string or raise an error due to no project being present in the string. The function uses the presence of \"projects/{{project}}/\" in the input string to identify the project name, e.g. when the function is passed the id \"projects/my-project/zones/us-central1-c/instances/my-instance\" as an argument it will return \"my-project\".", - Parameters: []function.Parameter{ - function.StringParameter{ - Name: "id", - Description: "A string of a resource's id, resource URI, self link, or full resource name. For example, \"projects/my-project/zones/us-central1-c/instances/my-instance\", \"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instances/my-instance\" and \"//gkehub.googleapis.com/projects/my-project/locations/us-central1/memberships/my-membership\" are valid values", - }, - }, - Return: function.StringReturn{}, - } -} - -func (f ProjectFromIdFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - // Load arguments from function call - var arg0 string - resp.Error = function.ConcatFuncErrors(req.Arguments.GetArgument(ctx, 0, &arg0)) - if resp.Error != nil { - return - } - - // Prepare how we'll identify project id from input string - regex := regexp.MustCompile("projects/(?P[^/]+)/") // Should match the pattern below - template := "$ProjectId" // Should match the submatch identifier in the regex - pattern := "projects/{project}/" // Human-readable pseudo-regex pattern used in errors and warnings - - // Validate input - resp.Error = function.ConcatFuncErrors(ValidateElementFromIdArguments(ctx, arg0, regex, pattern, f.name)) - if resp.Error != nil { - return - } - - // Get and return element from input string - projectId := GetElementFromId(arg0, regex, template) - resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, projectId)) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/region_from_id.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/region_from_id.go deleted file mode 100644 index cc5374582c7..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/region_from_id.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "regexp" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = RegionFromIdFunction{} - -func NewRegionFromIdFunction() function.Function { - return &RegionFromIdFunction{ - name: "region_from_id", - } -} - -type RegionFromIdFunction struct { - name string // Makes function name available in Run logic for logging purposes -} - -func (f RegionFromIdFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = f.name -} - -func (f RegionFromIdFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Summary: "Returns the region name within a provided resource id, self link, or OP style resource name.", - Description: "Takes a single string argument, which should be a resource id, self link, or OP style resource name. This function will either return the region name from the input string or raise an error due to no region being present in the string. The function uses the presence of \"regions/{{region}}/\" in the input string to identify the region name, e.g. when the function is passed the id \"projects/my-project/regions/us-central1/subnetworks/my-subnetwork\" as an argument it will return \"us-central1\".", - Parameters: []function.Parameter{ - function.StringParameter{ - Name: "id", - Description: "A string of a resource's id, a resource's self link, or an OP style resource name. For example, \"projects/my-project/regions/us-central1/subnetworks/my-subnetwork\" and \"https://www.googleapis.com/compute/v1/projects/my-project/regions/us-central1/subnetworks/my-subnetwork\" are valid values containing regions", - }, - }, - Return: function.StringReturn{}, - } -} - -func (f RegionFromIdFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - // Load arguments from function call - var arg0 string - resp.Error = function.ConcatFuncErrors(req.Arguments.GetArgument(ctx, 0, &arg0)) - if resp.Error != nil { - return - } - - // Prepare how we'll identify region name from input string - regex := regexp.MustCompile("regions/(?P[^/]+)/") // Should match the pattern below - template := "$RegionName" // Should match the submatch identifier in the regex - pattern := "regions/{region}/" // Human-readable pseudo-regex pattern used in errors and warnings - - // Validate input - resp.Error = function.ConcatFuncErrors(ValidateElementFromIdArguments(ctx, arg0, regex, pattern, f.name)) - if resp.Error != nil { - return - } - - // Get and return element from input string - region := GetElementFromId(arg0, regex, template) - resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, region)) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/region_from_zone.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/region_from_zone.go deleted file mode 100644 index bab7f9dbbb2..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/region_from_zone.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "fmt" - "strings" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = RegionFromZoneFunction{} - -func NewRegionFromZoneFunction() function.Function { - return &RegionFromZoneFunction{} -} - -type RegionFromZoneFunction struct{} - -func (f RegionFromZoneFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = "region_from_zone" -} - -func (f RegionFromZoneFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Summary: "Returns the region within a provided resource's zone", - Description: "Takes a single string argument, which should be a resource's zone.", - Parameters: []function.Parameter{ - function.StringParameter{ - Name: "zone", - Description: "A string of a resource's zone.", - }, - }, - Return: function.StringReturn{}, - } -} - -func (f RegionFromZoneFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - // Load arguments from function call - var zone string - resp.Error = function.ConcatFuncErrors(req.Arguments.GetArgument(ctx, 0, &zone)) - if resp.Error != nil { - return - } - - if zone == "" { - err := function.NewArgumentFuncError(0, "The input string cannot be empty.") - resp.Error = function.ConcatFuncErrors(err) - return - } - - zoneParts := strings.Split(zone, "-") - - if len(zoneParts) < 3 { - err := function.NewArgumentFuncError(0, fmt.Sprintf("The input string \"%s\" is not a valid zone name.", zone)) - resp.Error = function.ConcatFuncErrors(err) - } else { - resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, strings.Join(zoneParts[:len(zoneParts)-1], "-"))) - } -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/zone_from_id.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/zone_from_id.go deleted file mode 100644 index 6823f1f094a..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/functions/zone_from_id.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package functions - -import ( - "context" - "regexp" - - "github.com/hashicorp/terraform-plugin-framework/function" -) - -var _ function.Function = ZoneFromIdFunction{} - -func NewZoneFromIdFunction() function.Function { - return &ZoneFromIdFunction{ - name: "zone_from_id", - } -} - -type ZoneFromIdFunction struct { - name string // Makes function name available in Run logic for logging purposes -} - -func (f ZoneFromIdFunction) Metadata(ctx context.Context, req function.MetadataRequest, resp *function.MetadataResponse) { - resp.Name = f.name -} - -func (f ZoneFromIdFunction) Definition(ctx context.Context, req function.DefinitionRequest, resp *function.DefinitionResponse) { - resp.Definition = function.Definition{ - Summary: "Returns the zone name within the resource id or self link provided as an argument.", - Description: "Takes a single string argument, which should be an id or self link of a resource. This function will either return the zone name from the input string or raise an error due to no zone being present in the string. The function uses the presence of \"zones/{{zone}}/\" in the input string to identify the zone name, e.g. when the function is passed the id \"projects/my-project/zones/us-central1-c/instances/my-instance\" as an argument it will return \"us-central1-c\".", - Parameters: []function.Parameter{ - function.StringParameter{ - Name: "id", - Description: "An id of a resouce, or a self link. For example, both \"projects/my-project/zones/us-central1-c/instances/my-instance\" and \"https://www.googleapis.com/compute/v1/projects/my-project/zones/us-central1-c/instances/my-instance\" are valid inputs", - }, - }, - Return: function.StringReturn{}, - } -} - -func (f ZoneFromIdFunction) Run(ctx context.Context, req function.RunRequest, resp *function.RunResponse) { - // Load arguments from function call - var arg0 string - resp.Error = function.ConcatFuncErrors(req.Arguments.GetArgument(ctx, 0, &arg0)) - if resp.Error != nil { - return - } - - // Prepare how we'll identify zone name from input string - regex := regexp.MustCompile("zones/(?P[^/]+)/") // Should match the pattern below - template := "$ZoneName" // Should match the submatch identifier in the regex - pattern := "zones/{zone}/" // Human-readable pseudo-regex pattern used in errors and warnings - - // Validate input - resp.Error = function.ConcatFuncErrors(ValidateElementFromIdArguments(ctx, arg0, regex, pattern, f.name)) - if resp.Error != nil { - return - } - - // Get and return element from input string - zone := GetElementFromId(arg0, regex, template) - resp.Error = function.ConcatFuncErrors(resp.Result.Set(ctx, zone)) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwmodels/provider_model.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwmodels/provider_model.go index 4118b94315d..dfd6a92424b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwmodels/provider_model.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwmodels/provider_model.go @@ -63,7 +63,6 @@ type ProviderModel struct { CloudRunV2CustomEndpoint types.String `tfsdk:"cloud_run_v2_custom_endpoint"` CloudSchedulerCustomEndpoint types.String `tfsdk:"cloud_scheduler_custom_endpoint"` CloudTasksCustomEndpoint types.String `tfsdk:"cloud_tasks_custom_endpoint"` - ComposerCustomEndpoint types.String `tfsdk:"composer_custom_endpoint"` ComputeCustomEndpoint types.String `tfsdk:"compute_custom_endpoint"` ContainerAnalysisCustomEndpoint types.String `tfsdk:"container_analysis_custom_endpoint"` ContainerAttachedCustomEndpoint types.String `tfsdk:"container_attached_custom_endpoint"` @@ -102,7 +101,6 @@ type ProviderModel struct { IapCustomEndpoint types.String `tfsdk:"iap_custom_endpoint"` IdentityPlatformCustomEndpoint types.String `tfsdk:"identity_platform_custom_endpoint"` IntegrationConnectorsCustomEndpoint types.String `tfsdk:"integration_connectors_custom_endpoint"` - IntegrationsCustomEndpoint types.String `tfsdk:"integrations_custom_endpoint"` KMSCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"` LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"` LookerCustomEndpoint types.String `tfsdk:"looker_custom_endpoint"` @@ -128,11 +126,8 @@ type ProviderModel struct { SecretManagerCustomEndpoint types.String `tfsdk:"secret_manager_custom_endpoint"` SecureSourceManagerCustomEndpoint types.String `tfsdk:"secure_source_manager_custom_endpoint"` SecurityCenterCustomEndpoint types.String `tfsdk:"security_center_custom_endpoint"` - SecurityCenterManagementCustomEndpoint types.String `tfsdk:"security_center_management_custom_endpoint"` - SecurityCenterV2CustomEndpoint types.String `tfsdk:"security_center_v2_custom_endpoint"` SecuritypostureCustomEndpoint types.String `tfsdk:"securityposture_custom_endpoint"` ServiceManagementCustomEndpoint types.String `tfsdk:"service_management_custom_endpoint"` - ServiceNetworkingCustomEndpoint types.String `tfsdk:"service_networking_custom_endpoint"` ServiceUsageCustomEndpoint types.String `tfsdk:"service_usage_custom_endpoint"` SourceRepoCustomEndpoint types.String `tfsdk:"source_repo_custom_endpoint"` SpannerCustomEndpoint types.String `tfsdk:"spanner_custom_endpoint"` @@ -150,11 +145,13 @@ type ProviderModel struct { // Handwritten Products / Versioned / Atypical Entries CloudBillingCustomEndpoint types.String `tfsdk:"cloud_billing_custom_endpoint"` + ComposerCustomEndpoint types.String `tfsdk:"composer_custom_endpoint"` ContainerCustomEndpoint types.String `tfsdk:"container_custom_endpoint"` DataflowCustomEndpoint types.String `tfsdk:"dataflow_custom_endpoint"` IamCredentialsCustomEndpoint types.String `tfsdk:"iam_credentials_custom_endpoint"` ResourceManagerV3CustomEndpoint types.String `tfsdk:"resource_manager_v3_custom_endpoint"` IAMCustomEndpoint types.String `tfsdk:"iam_custom_endpoint"` + ServiceNetworkingCustomEndpoint types.String `tfsdk:"service_networking_custom_endpoint"` TagsLocationCustomEndpoint types.String `tfsdk:"tags_location_custom_endpoint"` // dcl diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwprovider/framework_provider.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwprovider/framework_provider.go index d54ae812900..3f59f738e12 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwprovider/framework_provider.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwprovider/framework_provider.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" - "github.com/hashicorp/terraform-plugin-framework/function" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/metaschema" @@ -16,9 +15,9 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" - "github.com/hashicorp/terraform-provider-google/google/functions" "github.com/hashicorp/terraform-provider-google/google/fwmodels" "github.com/hashicorp/terraform-provider-google/google/fwtransport" + "github.com/hashicorp/terraform-provider-google/google/services/dns" "github.com/hashicorp/terraform-provider-google/google/services/resourcemanager" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" @@ -27,7 +26,6 @@ import ( // Ensure the implementation satisfies the expected interfaces var ( _ provider.ProviderWithMetaSchema = &FrameworkProvider{} - _ provider.ProviderWithFunctions = &FrameworkProvider{} ) // New is a helper function to simplify provider server and testing implementation. @@ -354,12 +352,6 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, - "composer_custom_endpoint": &schema.StringAttribute{ - Optional: true, - Validators: []validator.String{ - transport_tpg.CustomEndpointValidator(), - }, - }, "compute_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -588,12 +580,6 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, - "integrations_custom_endpoint": &schema.StringAttribute{ - Optional: true, - Validators: []validator.String{ - transport_tpg.CustomEndpointValidator(), - }, - }, "kms_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -744,18 +730,6 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, - "security_center_management_custom_endpoint": &schema.StringAttribute{ - Optional: true, - Validators: []validator.String{ - transport_tpg.CustomEndpointValidator(), - }, - }, - "security_center_v2_custom_endpoint": &schema.StringAttribute{ - Optional: true, - Validators: []validator.String{ - transport_tpg.CustomEndpointValidator(), - }, - }, "securityposture_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -768,12 +742,6 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, - "service_networking_custom_endpoint": &schema.StringAttribute{ - Optional: true, - Validators: []validator.String{ - transport_tpg.CustomEndpointValidator(), - }, - }, "service_usage_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -866,6 +834,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, + "composer_custom_endpoint": &schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + transport_tpg.CustomEndpointValidator(), + }, + }, "container_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -896,6 +870,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest, transport_tpg.CustomEndpointValidator(), }, }, + "service_networking_custom_endpoint": &schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + transport_tpg.CustomEndpointValidator(), + }, + }, "tags_location_custom_endpoint": &schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -965,6 +945,10 @@ func (p *FrameworkProvider) DataSources(_ context.Context) []func() datasource.D return []func() datasource.DataSource{ resourcemanager.NewGoogleClientConfigDataSource, resourcemanager.NewGoogleClientOpenIDUserinfoDataSource, + dns.NewGoogleDnsManagedZoneDataSource, + dns.NewGoogleDnsManagedZonesDataSource, + dns.NewGoogleDnsRecordSetDataSource, + dns.NewGoogleDnsKeysDataSource, } } @@ -972,15 +956,3 @@ func (p *FrameworkProvider) DataSources(_ context.Context) []func() datasource.D func (p *FrameworkProvider) Resources(_ context.Context) []func() resource.Resource { return nil } - -// Functions defines the provider functions implemented in the provider. -func (p *FrameworkProvider) Functions(_ context.Context) []func() function.Function { - return []func() function.Function{ - functions.NewLocationFromIdFunction, - functions.NewNameFromIdFunction, - functions.NewProjectFromIdFunction, - functions.NewRegionFromIdFunction, - functions.NewRegionFromZoneFunction, - functions.NewZoneFromIdFunction, - } -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwtransport/framework_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwtransport/framework_config.go index 24bbcdfb6d4..4ba7c643a9e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwtransport/framework_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/fwtransport/framework_config.go @@ -86,7 +86,6 @@ type FrameworkProviderConfig struct { CloudRunV2BasePath string CloudSchedulerBasePath string CloudTasksBasePath string - ComposerBasePath string ComputeBasePath string ContainerAnalysisBasePath string ContainerAttachedBasePath string @@ -125,7 +124,6 @@ type FrameworkProviderConfig struct { IapBasePath string IdentityPlatformBasePath string IntegrationConnectorsBasePath string - IntegrationsBasePath string KMSBasePath string LoggingBasePath string LookerBasePath string @@ -151,11 +149,8 @@ type FrameworkProviderConfig struct { SecretManagerBasePath string SecureSourceManagerBasePath string SecurityCenterBasePath string - SecurityCenterManagementBasePath string - SecurityCenterV2BasePath string SecuritypostureBasePath string ServiceManagementBasePath string - ServiceNetworkingBasePath string ServiceUsageBasePath string SourceRepoBasePath string SpannerBasePath string @@ -244,7 +239,6 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, p.CloudRunV2BasePath = data.CloudRunV2CustomEndpoint.ValueString() p.CloudSchedulerBasePath = data.CloudSchedulerCustomEndpoint.ValueString() p.CloudTasksBasePath = data.CloudTasksCustomEndpoint.ValueString() - p.ComposerBasePath = data.ComposerCustomEndpoint.ValueString() p.ComputeBasePath = data.ComputeCustomEndpoint.ValueString() p.ContainerAnalysisBasePath = data.ContainerAnalysisCustomEndpoint.ValueString() p.ContainerAttachedBasePath = data.ContainerAttachedCustomEndpoint.ValueString() @@ -283,7 +277,6 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, p.IapBasePath = data.IapCustomEndpoint.ValueString() p.IdentityPlatformBasePath = data.IdentityPlatformCustomEndpoint.ValueString() p.IntegrationConnectorsBasePath = data.IntegrationConnectorsCustomEndpoint.ValueString() - p.IntegrationsBasePath = data.IntegrationsCustomEndpoint.ValueString() p.KMSBasePath = data.KMSCustomEndpoint.ValueString() p.LoggingBasePath = data.LoggingCustomEndpoint.ValueString() p.LookerBasePath = data.LookerCustomEndpoint.ValueString() @@ -309,11 +302,8 @@ func (p *FrameworkProviderConfig) LoadAndValidateFramework(ctx context.Context, p.SecretManagerBasePath = data.SecretManagerCustomEndpoint.ValueString() p.SecureSourceManagerBasePath = data.SecureSourceManagerCustomEndpoint.ValueString() p.SecurityCenterBasePath = data.SecurityCenterCustomEndpoint.ValueString() - p.SecurityCenterManagementBasePath = data.SecurityCenterManagementCustomEndpoint.ValueString() - p.SecurityCenterV2BasePath = data.SecurityCenterV2CustomEndpoint.ValueString() p.SecuritypostureBasePath = data.SecuritypostureCustomEndpoint.ValueString() p.ServiceManagementBasePath = data.ServiceManagementCustomEndpoint.ValueString() - p.ServiceNetworkingBasePath = data.ServiceNetworkingCustomEndpoint.ValueString() p.ServiceUsageBasePath = data.ServiceUsageCustomEndpoint.ValueString() p.SourceRepoBasePath = data.SourceRepoCustomEndpoint.ValueString() p.SpannerBasePath = data.SpannerCustomEndpoint.ValueString() @@ -735,14 +725,6 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo data.CloudTasksCustomEndpoint = types.StringValue(customEndpoint.(string)) } } - if data.ComposerCustomEndpoint.IsNull() { - customEndpoint := transport_tpg.MultiEnvDefault([]string{ - "GOOGLE_COMPOSER_CUSTOM_ENDPOINT", - }, transport_tpg.DefaultBasePaths[transport_tpg.ComposerBasePathKey]) - if customEndpoint != nil { - data.ComposerCustomEndpoint = types.StringValue(customEndpoint.(string)) - } - } if data.ComputeCustomEndpoint.IsNull() { customEndpoint := transport_tpg.MultiEnvDefault([]string{ "GOOGLE_COMPUTE_CUSTOM_ENDPOINT", @@ -1047,14 +1029,6 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo data.IntegrationConnectorsCustomEndpoint = types.StringValue(customEndpoint.(string)) } } - if data.IntegrationsCustomEndpoint.IsNull() { - customEndpoint := transport_tpg.MultiEnvDefault([]string{ - "GOOGLE_INTEGRATIONS_CUSTOM_ENDPOINT", - }, transport_tpg.DefaultBasePaths[transport_tpg.IntegrationsBasePathKey]) - if customEndpoint != nil { - data.IntegrationsCustomEndpoint = types.StringValue(customEndpoint.(string)) - } - } if data.KMSCustomEndpoint.IsNull() { customEndpoint := transport_tpg.MultiEnvDefault([]string{ "GOOGLE_KMS_CUSTOM_ENDPOINT", @@ -1255,22 +1229,6 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo data.SecurityCenterCustomEndpoint = types.StringValue(customEndpoint.(string)) } } - if data.SecurityCenterManagementCustomEndpoint.IsNull() { - customEndpoint := transport_tpg.MultiEnvDefault([]string{ - "GOOGLE_SECURITY_CENTER_MANAGEMENT_CUSTOM_ENDPOINT", - }, transport_tpg.DefaultBasePaths[transport_tpg.SecurityCenterManagementBasePathKey]) - if customEndpoint != nil { - data.SecurityCenterManagementCustomEndpoint = types.StringValue(customEndpoint.(string)) - } - } - if data.SecurityCenterV2CustomEndpoint.IsNull() { - customEndpoint := transport_tpg.MultiEnvDefault([]string{ - "GOOGLE_SECURITY_CENTER_V2_CUSTOM_ENDPOINT", - }, transport_tpg.DefaultBasePaths[transport_tpg.SecurityCenterV2BasePathKey]) - if customEndpoint != nil { - data.SecurityCenterV2CustomEndpoint = types.StringValue(customEndpoint.(string)) - } - } if data.SecuritypostureCustomEndpoint.IsNull() { customEndpoint := transport_tpg.MultiEnvDefault([]string{ "GOOGLE_SECURITYPOSTURE_CUSTOM_ENDPOINT", @@ -1287,14 +1245,6 @@ func (p *FrameworkProviderConfig) HandleDefaults(ctx context.Context, data *fwmo data.ServiceManagementCustomEndpoint = types.StringValue(customEndpoint.(string)) } } - if data.ServiceNetworkingCustomEndpoint.IsNull() { - customEndpoint := transport_tpg.MultiEnvDefault([]string{ - "GOOGLE_SERVICE_NETWORKING_CUSTOM_ENDPOINT", - }, transport_tpg.DefaultBasePaths[transport_tpg.ServiceNetworkingBasePathKey]) - if customEndpoint != nil { - data.ServiceNetworkingCustomEndpoint = types.StringValue(customEndpoint.(string)) - } - } if data.ServiceUsageCustomEndpoint.IsNull() { customEndpoint := transport_tpg.MultiEnvDefault([]string{ "GOOGLE_SERVICE_USAGE_CUSTOM_ENDPOINT", diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider.go index 5e3f70fea31..7f3d0687396 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider.go @@ -4,6 +4,7 @@ package provider import ( "context" + "encoding/json" "fmt" "os" "strings" @@ -319,11 +320,6 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: transport_tpg.ValidateCustomEndpoint, }, - "composer_custom_endpoint": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: transport_tpg.ValidateCustomEndpoint, - }, "compute_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -514,11 +510,6 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: transport_tpg.ValidateCustomEndpoint, }, - "integrations_custom_endpoint": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: transport_tpg.ValidateCustomEndpoint, - }, "kms_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -644,16 +635,6 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: transport_tpg.ValidateCustomEndpoint, }, - "security_center_management_custom_endpoint": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: transport_tpg.ValidateCustomEndpoint, - }, - "security_center_v2_custom_endpoint": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: transport_tpg.ValidateCustomEndpoint, - }, "securityposture_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -664,11 +645,6 @@ func Provider() *schema.Provider { Optional: true, ValidateFunc: transport_tpg.ValidateCustomEndpoint, }, - "service_networking_custom_endpoint": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: transport_tpg.ValidateCustomEndpoint, - }, "service_usage_custom_endpoint": { Type: schema.TypeString, Optional: true, @@ -860,13 +836,35 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr }) } - // Set the universe domain to the configured value, if any - if v, ok := d.GetOk("universe_domain"); ok { - config.UniverseDomain = v.(string) + // set universe_domain based on the service account key file. + if config.Credentials != "" { + contents, _, err := verify.PathOrContents(config.Credentials) + if err != nil { + return nil, diag.FromErr(fmt.Errorf("error loading service account credentials: %s", err)) + } + var content map[string]any + + if err := json.Unmarshal([]byte(contents), &content); err != nil { + return nil, diag.FromErr(err) + } + + if content["universe_domain"] != nil { + config.UniverseDomain = content["universe_domain"].(string) + } } - // Configure DCL basePath - transport_tpg.ProviderDCLConfigure(d, &config) + // Check if the user provided a value from the universe_domain field other than the default + if v, ok := d.GetOk("universe_domain"); ok && v.(string) != "googleapis.com" { + if config.UniverseDomain == "" { + return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' supplied directly to Terraform with no matching universe domain in credentials. Credentials with no 'universe_domain' set are assumed to be in the default universe.", v)) + } else if v.(string) != config.UniverseDomain { + if _, err := os.Stat(config.Credentials); err == nil { + return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' does not match the universe domain '%s' already set in the credential file '%s'. The 'universe_domain' provider configuration can not be used to override the universe domain that is defined in the active credential. Set the 'universe_domain' provider configuration when universe domain information is not already available in the credential, e.g. when authenticating with a JWT token.", v, config.UniverseDomain, config.Credentials)) + } else { + return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' does not match the universe domain '%s' supplied directly to Terraform. The 'universe_domain' provider configuration can not be used to override the universe domain that is defined in the active credential. Set the 'universe_domain' provider configuration when universe domain information is not already available in the credential, e.g. when authenticating with a JWT token.", v, config.UniverseDomain)) + } + } + } // Replace hostname by the universe_domain field. if config.UniverseDomain != "" && config.UniverseDomain != "googleapis.com" { @@ -966,7 +964,6 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.CloudRunV2BasePath = d.Get("cloud_run_v2_custom_endpoint").(string) config.CloudSchedulerBasePath = d.Get("cloud_scheduler_custom_endpoint").(string) config.CloudTasksBasePath = d.Get("cloud_tasks_custom_endpoint").(string) - config.ComposerBasePath = d.Get("composer_custom_endpoint").(string) config.ComputeBasePath = d.Get("compute_custom_endpoint").(string) config.ContainerAnalysisBasePath = d.Get("container_analysis_custom_endpoint").(string) config.ContainerAttachedBasePath = d.Get("container_attached_custom_endpoint").(string) @@ -1005,7 +1002,6 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.IapBasePath = d.Get("iap_custom_endpoint").(string) config.IdentityPlatformBasePath = d.Get("identity_platform_custom_endpoint").(string) config.IntegrationConnectorsBasePath = d.Get("integration_connectors_custom_endpoint").(string) - config.IntegrationsBasePath = d.Get("integrations_custom_endpoint").(string) config.KMSBasePath = d.Get("kms_custom_endpoint").(string) config.LoggingBasePath = d.Get("logging_custom_endpoint").(string) config.LookerBasePath = d.Get("looker_custom_endpoint").(string) @@ -1031,11 +1027,8 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.SecretManagerBasePath = d.Get("secret_manager_custom_endpoint").(string) config.SecureSourceManagerBasePath = d.Get("secure_source_manager_custom_endpoint").(string) config.SecurityCenterBasePath = d.Get("security_center_custom_endpoint").(string) - config.SecurityCenterManagementBasePath = d.Get("security_center_management_custom_endpoint").(string) - config.SecurityCenterV2BasePath = d.Get("security_center_v2_custom_endpoint").(string) config.SecuritypostureBasePath = d.Get("securityposture_custom_endpoint").(string) config.ServiceManagementBasePath = d.Get("service_management_custom_endpoint").(string) - config.ServiceNetworkingBasePath = d.Get("service_networking_custom_endpoint").(string) config.ServiceUsageBasePath = d.Get("service_usage_custom_endpoint").(string) config.SourceRepoBasePath = d.Get("source_repo_custom_endpoint").(string) config.SpannerBasePath = d.Get("spanner_custom_endpoint").(string) @@ -1059,6 +1052,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr config.IamCredentialsBasePath = d.Get(transport_tpg.IamCredentialsCustomEndpointEntryKey).(string) config.ResourceManagerV3BasePath = d.Get(transport_tpg.ResourceManagerV3CustomEndpointEntryKey).(string) config.IAMBasePath = d.Get(transport_tpg.IAMCustomEndpointEntryKey).(string) + config.ServiceNetworkingBasePath = d.Get(transport_tpg.ServiceNetworkingCustomEndpointEntryKey).(string) config.ServiceUsageBasePath = d.Get(transport_tpg.ServiceUsageCustomEndpointEntryKey).(string) config.BigtableAdminBasePath = d.Get(transport_tpg.BigtableAdminCustomEndpointEntryKey).(string) config.TagsLocationBasePath = d.Get(transport_tpg.TagsLocationCustomEndpointEntryKey).(string) @@ -1075,18 +1069,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr return nil, diag.FromErr(err) } - // Verify that universe domains match between credentials and configuration - if v, ok := d.GetOk("universe_domain"); ok { - if config.UniverseDomain == "" && v.(string) != "googleapis.com" { // v can't be "", as it wouldn't pass `ok` above - return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' supplied directly to Terraform with no matching universe domain in credentials. Credentials with no 'universe_domain' set are assumed to be in the default universe.", v)) - } else if v.(string) != config.UniverseDomain && !(config.UniverseDomain == "" && v.(string) == "googleapis.com") { - return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: '%s' does not match the universe domain '%s' supplied directly to Terraform. The 'universe_domain' provider configuration must match the universe domain supplied by credentials.", config.UniverseDomain, v)) - } - } else if config.UniverseDomain != "" && config.UniverseDomain != "googleapis.com" { - return nil, diag.FromErr(fmt.Errorf("Universe domain mismatch: Universe domain '%s' was found in credentials without a corresponding 'universe_domain' provider configuration set. Please set 'universe_domain' to '%s' or use different credentials.", config.UniverseDomain, config.UniverseDomain)) - } - - return &config, nil + return transport_tpg.ProviderDCLConfigure(d, &config), nil } func mergeResourceMaps(ms ...map[string]*schema.Resource) (map[string]*schema.Resource, error) { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_dcl_resources.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_dcl_resources.go index b680f80e3f8..a64fd0a3825 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_dcl_resources.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_dcl_resources.go @@ -22,6 +22,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/services/apikeys" "github.com/hashicorp/terraform-provider-google/google/services/assuredworkloads" + "github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation" "github.com/hashicorp/terraform-provider-google/google/services/cloudbuild" "github.com/hashicorp/terraform-provider-google/google/services/clouddeploy" "github.com/hashicorp/terraform-provider-google/google/services/compute" @@ -33,12 +34,15 @@ import ( "github.com/hashicorp/terraform-provider-google/google/services/firebaserules" "github.com/hashicorp/terraform-provider-google/google/services/gkehub" "github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity" + "github.com/hashicorp/terraform-provider-google/google/services/orgpolicy" + "github.com/hashicorp/terraform-provider-google/google/services/privateca" "github.com/hashicorp/terraform-provider-google/google/services/recaptchaenterprise" ) var dclResources = map[string]*schema.Resource{ "google_apikeys_key": apikeys.ResourceApikeysKey(), "google_assured_workloads_workload": assuredworkloads.ResourceAssuredWorkloadsWorkload(), + "google_bigquery_reservation_assignment": bigqueryreservation.ResourceBigqueryReservationAssignment(), "google_cloudbuild_worker_pool": cloudbuild.ResourceCloudbuildWorkerPool(), "google_clouddeploy_delivery_pipeline": clouddeploy.ResourceClouddeployDeliveryPipeline(), "google_clouddeploy_target": clouddeploy.ResourceClouddeployTarget(), @@ -66,5 +70,7 @@ var dclResources = map[string]*schema.Resource{ "google_gke_hub_feature_membership": gkehub.ResourceGkeHubFeatureMembership(), "google_network_connectivity_hub": networkconnectivity.ResourceNetworkConnectivityHub(), "google_network_connectivity_spoke": networkconnectivity.ResourceNetworkConnectivitySpoke(), + "google_org_policy_policy": orgpolicy.ResourceOrgPolicyPolicy(), + "google_privateca_certificate_template": privateca.ResourcePrivatecaCertificateTemplate(), "google_recaptcha_enterprise_key": recaptchaenterprise.ResourceRecaptchaEnterpriseKey(), } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_mmv1_resources.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_mmv1_resources.go index 9f83f9eae92..f89054014cf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_mmv1_resources.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/provider/provider_mmv1_resources.go @@ -35,7 +35,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/services/cloudfunctions2" "github.com/hashicorp/terraform-provider-google/google/services/cloudidentity" "github.com/hashicorp/terraform-provider-google/google/services/cloudids" - "github.com/hashicorp/terraform-provider-google/google/services/cloudquotas" "github.com/hashicorp/terraform-provider-google/google/services/cloudrun" "github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2" "github.com/hashicorp/terraform-provider-google/google/services/cloudscheduler" @@ -78,7 +77,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/services/iap" "github.com/hashicorp/terraform-provider-google/google/services/identityplatform" "github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors" - "github.com/hashicorp/terraform-provider-google/google/services/integrations" "github.com/hashicorp/terraform-provider-google/google/services/kms" "github.com/hashicorp/terraform-provider-google/google/services/logging" "github.com/hashicorp/terraform-provider-google/google/services/looker" @@ -104,11 +102,8 @@ import ( "github.com/hashicorp/terraform-provider-google/google/services/secretmanager" "github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager" "github.com/hashicorp/terraform-provider-google/google/services/securitycenter" - "github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement" - "github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2" "github.com/hashicorp/terraform-provider-google/google/services/securityposture" "github.com/hashicorp/terraform-provider-google/google/services/servicemanagement" - "github.com/hashicorp/terraform-provider-google/google/services/servicenetworking" "github.com/hashicorp/terraform-provider-google/google/services/sourcerepo" "github.com/hashicorp/terraform-provider-google/google/services/spanner" "github.com/hashicorp/terraform-provider-google/google/services/sql" @@ -128,7 +123,10 @@ import ( "github.com/hashicorp/terraform-provider-google/google/services/containeraws" "github.com/hashicorp/terraform-provider-google/google/services/containerazure" "github.com/hashicorp/terraform-provider-google/google/services/dataflow" + "github.com/hashicorp/terraform-provider-google/google/services/servicenetworking" "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" + // https://github.com/hashicorp/terraform-provider-google/issues/15633 for details + "github.com/hashicorp/terraform-provider-google/google/services/cloudquotas" ) // Datasources @@ -140,11 +138,9 @@ var handwrittenDatasources = map[string]*schema.Resource{ "google_active_folder": resourcemanager.DataSourceGoogleActiveFolder(), "google_alloydb_locations": alloydb.DataSourceAlloydbLocations(), "google_alloydb_supported_database_flags": alloydb.DataSourceAlloydbSupportedDatabaseFlags(), - "google_artifact_registry_docker_image": artifactregistry.DataSourceArtifactRegistryDockerImage(), "google_artifact_registry_repository": artifactregistry.DataSourceArtifactRegistryRepository(), "google_apphub_discovered_workload": apphub.DataSourceApphubDiscoveredWorkload(), "google_app_engine_default_service_account": appengine.DataSourceGoogleAppEngineDefaultServiceAccount(), - "google_apphub_application": apphub.DataSourceGoogleApphubApplication(), "google_apphub_discovered_service": apphub.DataSourceApphubDiscoveredService(), "google_beyondcorp_app_connection": beyondcorp.DataSourceGoogleBeyondcorpAppConnection(), "google_beyondcorp_app_connector": beyondcorp.DataSourceGoogleBeyondcorpAppConnector(), @@ -156,12 +152,10 @@ var handwrittenDatasources = map[string]*schema.Resource{ "google_cloudbuild_trigger": cloudbuild.DataSourceGoogleCloudBuildTrigger(), "google_cloudfunctions_function": cloudfunctions.DataSourceGoogleCloudFunctionsFunction(), "google_cloudfunctions2_function": cloudfunctions2.DataSourceGoogleCloudFunctions2Function(), - "google_cloud_asset_search_all_resources": cloudasset.DataSourceGoogleCloudAssetSearchAllResources(), "google_cloud_identity_groups": cloudidentity.DataSourceGoogleCloudIdentityGroups(), "google_cloud_identity_group_memberships": cloudidentity.DataSourceGoogleCloudIdentityGroupMemberships(), "google_cloud_identity_group_lookup": cloudidentity.DataSourceGoogleCloudIdentityGroupLookup(), "google_cloud_quotas_quota_info": cloudquotas.DataSourceGoogleCloudQuotasQuotaInfo(), - "google_cloud_quotas_quota_infos": cloudquotas.DataSourceGoogleCloudQuotasQuotaInfos(), "google_cloud_run_locations": cloudrun.DataSourceGoogleCloudRunLocations(), "google_cloud_run_service": cloudrun.DataSourceGoogleCloudRunService(), "google_cloud_run_v2_job": cloudrunv2.DataSourceGoogleCloudRunV2Job(), @@ -204,12 +198,10 @@ var handwrittenDatasources = map[string]*schema.Resource{ "google_compute_router": compute.DataSourceGoogleComputeRouter(), "google_compute_router_nat": compute.DataSourceGoogleComputeRouterNat(), "google_compute_router_status": compute.DataSourceGoogleComputeRouterStatus(), - "google_compute_security_policy": compute.DataSourceGoogleComputeSecurityPolicy(), "google_compute_snapshot": compute.DataSourceGoogleComputeSnapshot(), "google_compute_ssl_certificate": compute.DataSourceGoogleComputeSslCertificate(), "google_compute_ssl_policy": compute.DataSourceGoogleComputeSslPolicy(), "google_compute_subnetwork": compute.DataSourceGoogleComputeSubnetwork(), - "google_compute_subnetworks": compute.DataSourceGoogleComputeSubnetworks(), "google_compute_vpn_gateway": compute.DataSourceGoogleComputeVpnGateway(), "google_compute_zones": compute.DataSourceGoogleComputeZones(), "google_container_azure_versions": containerazure.DataSourceGoogleContainerAzureVersions(), @@ -222,20 +214,14 @@ var handwrittenDatasources = map[string]*schema.Resource{ "google_container_registry_repository": containeranalysis.DataSourceGoogleContainerRepo(), "google_dataproc_metastore_service": dataprocmetastore.DataSourceDataprocMetastoreService(), "google_datastream_static_ips": datastream.DataSourceGoogleDatastreamStaticIps(), - "google_dns_keys": dns.DataSourceDNSKeys(), - "google_dns_managed_zone": dns.DataSourceDnsManagedZone(), - "google_dns_managed_zones": dns.DataSourceDnsManagedZones(), - "google_dns_record_set": dns.DataSourceDnsRecordSet(), "google_filestore_instance": filestore.DataSourceGoogleFilestoreInstance(), "google_iam_policy": resourcemanager.DataSourceGoogleIamPolicy(), "google_iam_role": resourcemanager.DataSourceGoogleIamRole(), "google_iam_testable_permissions": resourcemanager.DataSourceGoogleIamTestablePermissions(), "google_iap_client": iap.DataSourceGoogleIapClient(), "google_kms_crypto_key": kms.DataSourceGoogleKmsCryptoKey(), - "google_kms_crypto_keys": kms.DataSourceGoogleKmsCryptoKeys(), "google_kms_crypto_key_version": kms.DataSourceGoogleKmsCryptoKeyVersion(), "google_kms_key_ring": kms.DataSourceGoogleKmsKeyRing(), - "google_kms_key_rings": kms.DataSourceGoogleKmsKeyRings(), "google_kms_secret": kms.DataSourceGoogleKmsSecret(), "google_kms_secret_ciphertext": kms.DataSourceGoogleKmsSecretCiphertext(), "google_folder": resourcemanager.DataSourceGoogleFolder(), @@ -282,17 +268,13 @@ var handwrittenDatasources = map[string]*schema.Resource{ "google_sql_database_instances": sql.DataSourceSqlDatabaseInstances(), "google_service_networking_peered_dns_domain": servicenetworking.DataSourceGoogleServiceNetworkingPeeredDNSDomain(), "google_storage_bucket": storage.DataSourceGoogleStorageBucket(), - "google_storage_buckets": storage.DataSourceGoogleStorageBuckets(), "google_storage_bucket_object": storage.DataSourceGoogleStorageBucketObject(), - "google_storage_bucket_objects": storage.DataSourceGoogleStorageBucketObjects(), "google_storage_bucket_object_content": storage.DataSourceGoogleStorageBucketObjectContent(), "google_storage_object_signed_url": storage.DataSourceGoogleSignedUrl(), "google_storage_project_service_account": storage.DataSourceGoogleStorageProjectServiceAccount(), "google_storage_transfer_project_service_account": storagetransfer.DataSourceGoogleStorageTransferProjectServiceAccount(), "google_tags_tag_key": tags.DataSourceGoogleTagsTagKey(), - "google_tags_tag_keys": tags.DataSourceGoogleTagsTagKeys(), "google_tags_tag_value": tags.DataSourceGoogleTagsTagValue(), - "google_tags_tag_values": tags.DataSourceGoogleTagsTagValues(), "google_tpu_tensorflow_versions": tpu.DataSourceTpuTensorflowVersions(), "google_vpc_access_connector": vpcaccess.DataSourceVPCAccessConnector(), "google_redis_instance": redis.DataSourceGoogleRedisInstance(), @@ -344,16 +326,12 @@ var generatedIAMDatasources = map[string]*schema.Resource{ "google_data_catalog_tag_template_iam_policy": tpgiamresource.DataSourceIamPolicy(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer), "google_data_catalog_taxonomy_iam_policy": tpgiamresource.DataSourceIamPolicy(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer), "google_data_fusion_instance_iam_policy": tpgiamresource.DataSourceIamPolicy(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer), - "google_dataplex_aspect_type_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexAspectTypeIamSchema, dataplex.DataplexAspectTypeIamUpdaterProducer), "google_dataplex_asset_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer), "google_dataplex_datascan_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer), - "google_dataplex_entry_group_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexEntryGroupIamSchema, dataplex.DataplexEntryGroupIamUpdaterProducer), - "google_dataplex_entry_type_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexEntryTypeIamSchema, dataplex.DataplexEntryTypeIamUpdaterProducer), "google_dataplex_lake_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer), "google_dataplex_task_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer), "google_dataplex_zone_iam_policy": tpgiamresource.DataSourceIamPolicy(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer), "google_dataproc_autoscaling_policy_iam_policy": tpgiamresource.DataSourceIamPolicy(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer), - "google_dataproc_metastore_federation_iam_policy": tpgiamresource.DataSourceIamPolicy(dataprocmetastore.DataprocMetastoreFederationIamSchema, dataprocmetastore.DataprocMetastoreFederationIamUpdaterProducer), "google_dataproc_metastore_service_iam_policy": tpgiamresource.DataSourceIamPolicy(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer), "google_dns_managed_zone_iam_policy": tpgiamresource.DataSourceIamPolicy(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer), "google_gke_backup_backup_plan_iam_policy": tpgiamresource.DataSourceIamPolicy(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer), @@ -381,7 +359,6 @@ var generatedIAMDatasources = map[string]*schema.Resource{ "google_pubsub_topic_iam_policy": tpgiamresource.DataSourceIamPolicy(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer), "google_secret_manager_secret_iam_policy": tpgiamresource.DataSourceIamPolicy(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer), "google_secure_source_manager_instance_iam_policy": tpgiamresource.DataSourceIamPolicy(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer), - "google_secure_source_manager_repository_iam_policy": tpgiamresource.DataSourceIamPolicy(securesourcemanager.SecureSourceManagerRepositoryIamSchema, securesourcemanager.SecureSourceManagerRepositoryIamUpdaterProducer), "google_scc_source_iam_policy": tpgiamresource.DataSourceIamPolicy(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer), "google_endpoints_service_iam_policy": tpgiamresource.DataSourceIamPolicy(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer), "google_endpoints_service_consumers_iam_policy": tpgiamresource.DataSourceIamPolicy(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer), @@ -410,7 +387,6 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ "google_kms_crypto_key_iam_policy": tpgiamresource.DataSourceIamPolicy(kms.IamKmsCryptoKeySchema, kms.NewKmsCryptoKeyIamUpdater), "google_spanner_instance_iam_policy": tpgiamresource.DataSourceIamPolicy(spanner.IamSpannerInstanceSchema, spanner.NewSpannerInstanceIamUpdater), "google_spanner_database_iam_policy": tpgiamresource.DataSourceIamPolicy(spanner.IamSpannerDatabaseSchema, spanner.NewSpannerDatabaseIamUpdater), - "google_storage_managed_folder_iam_policy": tpgiamresource.DataSourceIamPolicy(storage.StorageManagedFolderIamSchema, storage.StorageManagedFolderIamUpdaterProducer), "google_organization_iam_policy": tpgiamresource.DataSourceIamPolicy(resourcemanager.IamOrganizationSchema, resourcemanager.NewOrganizationIamUpdater), "google_project_iam_policy": tpgiamresource.DataSourceIamPolicy(resourcemanager.IamProjectSchema, resourcemanager.NewProjectIamUpdater), "google_pubsub_subscription_iam_policy": tpgiamresource.DataSourceIamPolicy(pubsub.IamPubsubSubscriptionSchema, pubsub.NewPubsubSubscriptionIamUpdater), @@ -419,673 +395,620 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{ } // Resources -// Generated resources: 432 -// Generated IAM resources: 252 -// Total generated resources: 684 +// Generated resources: 394 +// Generated IAM resources: 234 +// Total generated resources: 628 var generatedResources = map[string]*schema.Resource{ - "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), - "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), - "google_project_access_approval_settings": accessapproval.ResourceAccessApprovalProjectSettings(), - "google_access_context_manager_access_level": accesscontextmanager.ResourceAccessContextManagerAccessLevel(), - "google_access_context_manager_access_level_condition": accesscontextmanager.ResourceAccessContextManagerAccessLevelCondition(), - "google_access_context_manager_access_levels": accesscontextmanager.ResourceAccessContextManagerAccessLevels(), - "google_access_context_manager_access_policy": accesscontextmanager.ResourceAccessContextManagerAccessPolicy(), - "google_access_context_manager_access_policy_iam_binding": tpgiamresource.ResourceIamBinding(accesscontextmanager.AccessContextManagerAccessPolicyIamSchema, accesscontextmanager.AccessContextManagerAccessPolicyIamUpdaterProducer, accesscontextmanager.AccessContextManagerAccessPolicyIdParseFunc), - "google_access_context_manager_access_policy_iam_member": tpgiamresource.ResourceIamMember(accesscontextmanager.AccessContextManagerAccessPolicyIamSchema, accesscontextmanager.AccessContextManagerAccessPolicyIamUpdaterProducer, accesscontextmanager.AccessContextManagerAccessPolicyIdParseFunc), - "google_access_context_manager_access_policy_iam_policy": tpgiamresource.ResourceIamPolicy(accesscontextmanager.AccessContextManagerAccessPolicyIamSchema, accesscontextmanager.AccessContextManagerAccessPolicyIamUpdaterProducer, accesscontextmanager.AccessContextManagerAccessPolicyIdParseFunc), - "google_access_context_manager_authorized_orgs_desc": accesscontextmanager.ResourceAccessContextManagerAuthorizedOrgsDesc(), - "google_access_context_manager_egress_policy": accesscontextmanager.ResourceAccessContextManagerEgressPolicy(), - "google_access_context_manager_gcp_user_access_binding": accesscontextmanager.ResourceAccessContextManagerGcpUserAccessBinding(), - "google_access_context_manager_ingress_policy": accesscontextmanager.ResourceAccessContextManagerIngressPolicy(), - "google_access_context_manager_service_perimeter": accesscontextmanager.ResourceAccessContextManagerServicePerimeter(), - "google_access_context_manager_service_perimeter_dry_run_resource": accesscontextmanager.ResourceAccessContextManagerServicePerimeterDryRunResource(), - "google_access_context_manager_service_perimeter_egress_policy": accesscontextmanager.ResourceAccessContextManagerServicePerimeterEgressPolicy(), - "google_access_context_manager_service_perimeter_ingress_policy": accesscontextmanager.ResourceAccessContextManagerServicePerimeterIngressPolicy(), - "google_access_context_manager_service_perimeter_resource": accesscontextmanager.ResourceAccessContextManagerServicePerimeterResource(), - "google_access_context_manager_service_perimeters": accesscontextmanager.ResourceAccessContextManagerServicePerimeters(), - "google_active_directory_domain": activedirectory.ResourceActiveDirectoryDomain(), - "google_active_directory_domain_trust": activedirectory.ResourceActiveDirectoryDomainTrust(), - "google_alloydb_backup": alloydb.ResourceAlloydbBackup(), - "google_alloydb_cluster": alloydb.ResourceAlloydbCluster(), - "google_alloydb_instance": alloydb.ResourceAlloydbInstance(), - "google_alloydb_user": alloydb.ResourceAlloydbUser(), - "google_apigee_addons_config": apigee.ResourceApigeeAddonsConfig(), - "google_apigee_endpoint_attachment": apigee.ResourceApigeeEndpointAttachment(), - "google_apigee_env_keystore": apigee.ResourceApigeeEnvKeystore(), - "google_apigee_env_references": apigee.ResourceApigeeEnvReferences(), - "google_apigee_envgroup": apigee.ResourceApigeeEnvgroup(), - "google_apigee_envgroup_attachment": apigee.ResourceApigeeEnvgroupAttachment(), - "google_apigee_environment": apigee.ResourceApigeeEnvironment(), - "google_apigee_environment_iam_binding": tpgiamresource.ResourceIamBinding(apigee.ApigeeEnvironmentIamSchema, apigee.ApigeeEnvironmentIamUpdaterProducer, apigee.ApigeeEnvironmentIdParseFunc), - "google_apigee_environment_iam_member": tpgiamresource.ResourceIamMember(apigee.ApigeeEnvironmentIamSchema, apigee.ApigeeEnvironmentIamUpdaterProducer, apigee.ApigeeEnvironmentIdParseFunc), - "google_apigee_environment_iam_policy": tpgiamresource.ResourceIamPolicy(apigee.ApigeeEnvironmentIamSchema, apigee.ApigeeEnvironmentIamUpdaterProducer, apigee.ApigeeEnvironmentIdParseFunc), - "google_apigee_instance": apigee.ResourceApigeeInstance(), - "google_apigee_instance_attachment": apigee.ResourceApigeeInstanceAttachment(), - "google_apigee_keystores_aliases_self_signed_cert": apigee.ResourceApigeeKeystoresAliasesSelfSignedCert(), - "google_apigee_nat_address": apigee.ResourceApigeeNatAddress(), - "google_apigee_organization": apigee.ResourceApigeeOrganization(), - "google_apigee_sync_authorization": apigee.ResourceApigeeSyncAuthorization(), - "google_apigee_target_server": apigee.ResourceApigeeTargetServer(), - "google_app_engine_application_url_dispatch_rules": appengine.ResourceAppEngineApplicationUrlDispatchRules(), - "google_app_engine_domain_mapping": appengine.ResourceAppEngineDomainMapping(), - "google_app_engine_firewall_rule": appengine.ResourceAppEngineFirewallRule(), - "google_app_engine_flexible_app_version": appengine.ResourceAppEngineFlexibleAppVersion(), - "google_app_engine_service_network_settings": appengine.ResourceAppEngineServiceNetworkSettings(), - "google_app_engine_service_split_traffic": appengine.ResourceAppEngineServiceSplitTraffic(), - "google_app_engine_standard_app_version": appengine.ResourceAppEngineStandardAppVersion(), - "google_apphub_application": apphub.ResourceApphubApplication(), - "google_apphub_service": apphub.ResourceApphubService(), - "google_apphub_service_project_attachment": apphub.ResourceApphubServiceProjectAttachment(), - "google_apphub_workload": apphub.ResourceApphubWorkload(), - "google_artifact_registry_repository": artifactregistry.ResourceArtifactRegistryRepository(), - "google_artifact_registry_repository_iam_binding": tpgiamresource.ResourceIamBinding(artifactregistry.ArtifactRegistryRepositoryIamSchema, artifactregistry.ArtifactRegistryRepositoryIamUpdaterProducer, artifactregistry.ArtifactRegistryRepositoryIdParseFunc), - "google_artifact_registry_repository_iam_member": tpgiamresource.ResourceIamMember(artifactregistry.ArtifactRegistryRepositoryIamSchema, artifactregistry.ArtifactRegistryRepositoryIamUpdaterProducer, artifactregistry.ArtifactRegistryRepositoryIdParseFunc), - "google_artifact_registry_repository_iam_policy": tpgiamresource.ResourceIamPolicy(artifactregistry.ArtifactRegistryRepositoryIamSchema, artifactregistry.ArtifactRegistryRepositoryIamUpdaterProducer, artifactregistry.ArtifactRegistryRepositoryIdParseFunc), - "google_beyondcorp_app_connection": beyondcorp.ResourceBeyondcorpAppConnection(), - "google_beyondcorp_app_connector": beyondcorp.ResourceBeyondcorpAppConnector(), - "google_beyondcorp_app_gateway": beyondcorp.ResourceBeyondcorpAppGateway(), - "google_biglake_catalog": biglake.ResourceBiglakeCatalog(), - "google_biglake_database": biglake.ResourceBiglakeDatabase(), - "google_biglake_table": biglake.ResourceBiglakeTable(), - "google_bigquery_dataset": bigquery.ResourceBigQueryDataset(), - "google_bigquery_dataset_access": bigquery.ResourceBigQueryDatasetAccess(), - "google_bigquery_job": bigquery.ResourceBigQueryJob(), - "google_bigquery_routine": bigquery.ResourceBigQueryRoutine(), - "google_bigquery_table_iam_binding": tpgiamresource.ResourceIamBinding(bigquery.BigQueryTableIamSchema, bigquery.BigQueryTableIamUpdaterProducer, bigquery.BigQueryTableIdParseFunc), - "google_bigquery_table_iam_member": tpgiamresource.ResourceIamMember(bigquery.BigQueryTableIamSchema, bigquery.BigQueryTableIamUpdaterProducer, bigquery.BigQueryTableIdParseFunc), - "google_bigquery_table_iam_policy": tpgiamresource.ResourceIamPolicy(bigquery.BigQueryTableIamSchema, bigquery.BigQueryTableIamUpdaterProducer, bigquery.BigQueryTableIdParseFunc), - "google_bigquery_analytics_hub_data_exchange": bigqueryanalyticshub.ResourceBigqueryAnalyticsHubDataExchange(), - "google_bigquery_analytics_hub_data_exchange_iam_binding": tpgiamresource.ResourceIamBinding(bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIdParseFunc), - "google_bigquery_analytics_hub_data_exchange_iam_member": tpgiamresource.ResourceIamMember(bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIdParseFunc), - "google_bigquery_analytics_hub_data_exchange_iam_policy": tpgiamresource.ResourceIamPolicy(bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIdParseFunc), - "google_bigquery_analytics_hub_listing": bigqueryanalyticshub.ResourceBigqueryAnalyticsHubListing(), - "google_bigquery_analytics_hub_listing_iam_binding": tpgiamresource.ResourceIamBinding(bigqueryanalyticshub.BigqueryAnalyticsHubListingIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubListingIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubListingIdParseFunc), - "google_bigquery_analytics_hub_listing_iam_member": tpgiamresource.ResourceIamMember(bigqueryanalyticshub.BigqueryAnalyticsHubListingIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubListingIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubListingIdParseFunc), - "google_bigquery_analytics_hub_listing_iam_policy": tpgiamresource.ResourceIamPolicy(bigqueryanalyticshub.BigqueryAnalyticsHubListingIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubListingIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubListingIdParseFunc), - "google_bigquery_connection": bigqueryconnection.ResourceBigqueryConnectionConnection(), - "google_bigquery_connection_iam_binding": tpgiamresource.ResourceIamBinding(bigqueryconnection.BigqueryConnectionConnectionIamSchema, bigqueryconnection.BigqueryConnectionConnectionIamUpdaterProducer, bigqueryconnection.BigqueryConnectionConnectionIdParseFunc), - "google_bigquery_connection_iam_member": tpgiamresource.ResourceIamMember(bigqueryconnection.BigqueryConnectionConnectionIamSchema, bigqueryconnection.BigqueryConnectionConnectionIamUpdaterProducer, bigqueryconnection.BigqueryConnectionConnectionIdParseFunc), - "google_bigquery_connection_iam_policy": tpgiamresource.ResourceIamPolicy(bigqueryconnection.BigqueryConnectionConnectionIamSchema, bigqueryconnection.BigqueryConnectionConnectionIamUpdaterProducer, bigqueryconnection.BigqueryConnectionConnectionIdParseFunc), - "google_bigquery_datapolicy_data_policy": bigquerydatapolicy.ResourceBigqueryDatapolicyDataPolicy(), - "google_bigquery_datapolicy_data_policy_iam_binding": tpgiamresource.ResourceIamBinding(bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamSchema, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamUpdaterProducer, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIdParseFunc), - "google_bigquery_datapolicy_data_policy_iam_member": tpgiamresource.ResourceIamMember(bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamSchema, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamUpdaterProducer, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIdParseFunc), - "google_bigquery_datapolicy_data_policy_iam_policy": tpgiamresource.ResourceIamPolicy(bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamSchema, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamUpdaterProducer, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIdParseFunc), - "google_bigquery_data_transfer_config": bigquerydatatransfer.ResourceBigqueryDataTransferConfig(), - "google_bigquery_bi_reservation": bigqueryreservation.ResourceBigqueryReservationBiReservation(), - "google_bigquery_capacity_commitment": bigqueryreservation.ResourceBigqueryReservationCapacityCommitment(), - "google_bigquery_reservation": bigqueryreservation.ResourceBigqueryReservationReservation(), - "google_bigquery_reservation_assignment": bigqueryreservation.ResourceBigqueryReservationReservationAssignment(), - "google_bigtable_app_profile": bigtable.ResourceBigtableAppProfile(), - "google_billing_budget": billing.ResourceBillingBudget(), - "google_binary_authorization_attestor": binaryauthorization.ResourceBinaryAuthorizationAttestor(), - "google_binary_authorization_attestor_iam_binding": tpgiamresource.ResourceIamBinding(binaryauthorization.BinaryAuthorizationAttestorIamSchema, binaryauthorization.BinaryAuthorizationAttestorIamUpdaterProducer, binaryauthorization.BinaryAuthorizationAttestorIdParseFunc), - "google_binary_authorization_attestor_iam_member": tpgiamresource.ResourceIamMember(binaryauthorization.BinaryAuthorizationAttestorIamSchema, binaryauthorization.BinaryAuthorizationAttestorIamUpdaterProducer, binaryauthorization.BinaryAuthorizationAttestorIdParseFunc), - "google_binary_authorization_attestor_iam_policy": tpgiamresource.ResourceIamPolicy(binaryauthorization.BinaryAuthorizationAttestorIamSchema, binaryauthorization.BinaryAuthorizationAttestorIamUpdaterProducer, binaryauthorization.BinaryAuthorizationAttestorIdParseFunc), - "google_binary_authorization_policy": binaryauthorization.ResourceBinaryAuthorizationPolicy(), - "google_blockchain_node_engine_blockchain_nodes": blockchainnodeengine.ResourceBlockchainNodeEngineBlockchainNodes(), - "google_certificate_manager_certificate": certificatemanager.ResourceCertificateManagerCertificate(), - "google_certificate_manager_certificate_issuance_config": certificatemanager.ResourceCertificateManagerCertificateIssuanceConfig(), - "google_certificate_manager_certificate_map": certificatemanager.ResourceCertificateManagerCertificateMap(), - "google_certificate_manager_certificate_map_entry": certificatemanager.ResourceCertificateManagerCertificateMapEntry(), - "google_certificate_manager_dns_authorization": certificatemanager.ResourceCertificateManagerDnsAuthorization(), - "google_certificate_manager_trust_config": certificatemanager.ResourceCertificateManagerTrustConfig(), - "google_cloud_asset_folder_feed": cloudasset.ResourceCloudAssetFolderFeed(), - "google_cloud_asset_organization_feed": cloudasset.ResourceCloudAssetOrganizationFeed(), - "google_cloud_asset_project_feed": cloudasset.ResourceCloudAssetProjectFeed(), - "google_cloudbuild_bitbucket_server_config": cloudbuild.ResourceCloudBuildBitbucketServerConfig(), - "google_cloudbuild_trigger": cloudbuild.ResourceCloudBuildTrigger(), - "google_cloudbuildv2_connection": cloudbuildv2.ResourceCloudbuildv2Connection(), - "google_cloudbuildv2_connection_iam_binding": tpgiamresource.ResourceIamBinding(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc), - "google_cloudbuildv2_connection_iam_member": tpgiamresource.ResourceIamMember(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc), - "google_cloudbuildv2_connection_iam_policy": tpgiamresource.ResourceIamPolicy(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc), - "google_cloudbuildv2_repository": cloudbuildv2.ResourceCloudbuildv2Repository(), - "google_clouddeploy_automation": clouddeploy.ResourceClouddeployAutomation(), - "google_clouddeploy_custom_target_type": clouddeploy.ResourceClouddeployCustomTargetType(), - "google_clouddeploy_custom_target_type_iam_binding": tpgiamresource.ResourceIamBinding(clouddeploy.ClouddeployCustomTargetTypeIamSchema, clouddeploy.ClouddeployCustomTargetTypeIamUpdaterProducer, clouddeploy.ClouddeployCustomTargetTypeIdParseFunc), - "google_clouddeploy_custom_target_type_iam_member": tpgiamresource.ResourceIamMember(clouddeploy.ClouddeployCustomTargetTypeIamSchema, clouddeploy.ClouddeployCustomTargetTypeIamUpdaterProducer, clouddeploy.ClouddeployCustomTargetTypeIdParseFunc), - "google_clouddeploy_custom_target_type_iam_policy": tpgiamresource.ResourceIamPolicy(clouddeploy.ClouddeployCustomTargetTypeIamSchema, clouddeploy.ClouddeployCustomTargetTypeIamUpdaterProducer, clouddeploy.ClouddeployCustomTargetTypeIdParseFunc), - "google_clouddeploy_delivery_pipeline_iam_binding": tpgiamresource.ResourceIamBinding(clouddeploy.ClouddeployDeliveryPipelineIamSchema, clouddeploy.ClouddeployDeliveryPipelineIamUpdaterProducer, clouddeploy.ClouddeployDeliveryPipelineIdParseFunc), - "google_clouddeploy_delivery_pipeline_iam_member": tpgiamresource.ResourceIamMember(clouddeploy.ClouddeployDeliveryPipelineIamSchema, clouddeploy.ClouddeployDeliveryPipelineIamUpdaterProducer, clouddeploy.ClouddeployDeliveryPipelineIdParseFunc), - "google_clouddeploy_delivery_pipeline_iam_policy": tpgiamresource.ResourceIamPolicy(clouddeploy.ClouddeployDeliveryPipelineIamSchema, clouddeploy.ClouddeployDeliveryPipelineIamUpdaterProducer, clouddeploy.ClouddeployDeliveryPipelineIdParseFunc), - "google_clouddeploy_target_iam_binding": tpgiamresource.ResourceIamBinding(clouddeploy.ClouddeployTargetIamSchema, clouddeploy.ClouddeployTargetIamUpdaterProducer, clouddeploy.ClouddeployTargetIdParseFunc), - "google_clouddeploy_target_iam_member": tpgiamresource.ResourceIamMember(clouddeploy.ClouddeployTargetIamSchema, clouddeploy.ClouddeployTargetIamUpdaterProducer, clouddeploy.ClouddeployTargetIdParseFunc), - "google_clouddeploy_target_iam_policy": tpgiamresource.ResourceIamPolicy(clouddeploy.ClouddeployTargetIamSchema, clouddeploy.ClouddeployTargetIamUpdaterProducer, clouddeploy.ClouddeployTargetIdParseFunc), - "google_clouddomains_registration": clouddomains.ResourceClouddomainsRegistration(), - "google_cloudfunctions_function_iam_binding": tpgiamresource.ResourceIamBinding(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc), - "google_cloudfunctions_function_iam_member": tpgiamresource.ResourceIamMember(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc), - "google_cloudfunctions_function_iam_policy": tpgiamresource.ResourceIamPolicy(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc), - "google_cloudfunctions2_function": cloudfunctions2.ResourceCloudfunctions2function(), - "google_cloudfunctions2_function_iam_binding": tpgiamresource.ResourceIamBinding(cloudfunctions2.Cloudfunctions2functionIamSchema, cloudfunctions2.Cloudfunctions2functionIamUpdaterProducer, cloudfunctions2.Cloudfunctions2functionIdParseFunc), - "google_cloudfunctions2_function_iam_member": tpgiamresource.ResourceIamMember(cloudfunctions2.Cloudfunctions2functionIamSchema, cloudfunctions2.Cloudfunctions2functionIamUpdaterProducer, cloudfunctions2.Cloudfunctions2functionIdParseFunc), - "google_cloudfunctions2_function_iam_policy": tpgiamresource.ResourceIamPolicy(cloudfunctions2.Cloudfunctions2functionIamSchema, cloudfunctions2.Cloudfunctions2functionIamUpdaterProducer, cloudfunctions2.Cloudfunctions2functionIdParseFunc), - "google_cloud_identity_group": cloudidentity.ResourceCloudIdentityGroup(), - "google_cloud_identity_group_membership": cloudidentity.ResourceCloudIdentityGroupMembership(), - "google_cloud_ids_endpoint": cloudids.ResourceCloudIdsEndpoint(), - "google_cloud_quotas_quota_preference": cloudquotas.ResourceCloudQuotasQuotaPreference(), - "google_cloud_run_domain_mapping": cloudrun.ResourceCloudRunDomainMapping(), - "google_cloud_run_service": cloudrun.ResourceCloudRunService(), - "google_cloud_run_service_iam_binding": tpgiamresource.ResourceIamBinding(cloudrun.CloudRunServiceIamSchema, cloudrun.CloudRunServiceIamUpdaterProducer, cloudrun.CloudRunServiceIdParseFunc), - "google_cloud_run_service_iam_member": tpgiamresource.ResourceIamMember(cloudrun.CloudRunServiceIamSchema, cloudrun.CloudRunServiceIamUpdaterProducer, cloudrun.CloudRunServiceIdParseFunc), - "google_cloud_run_service_iam_policy": tpgiamresource.ResourceIamPolicy(cloudrun.CloudRunServiceIamSchema, cloudrun.CloudRunServiceIamUpdaterProducer, cloudrun.CloudRunServiceIdParseFunc), - "google_cloud_run_v2_job": cloudrunv2.ResourceCloudRunV2Job(), - "google_cloud_run_v2_job_iam_binding": tpgiamresource.ResourceIamBinding(cloudrunv2.CloudRunV2JobIamSchema, cloudrunv2.CloudRunV2JobIamUpdaterProducer, cloudrunv2.CloudRunV2JobIdParseFunc), - "google_cloud_run_v2_job_iam_member": tpgiamresource.ResourceIamMember(cloudrunv2.CloudRunV2JobIamSchema, cloudrunv2.CloudRunV2JobIamUpdaterProducer, cloudrunv2.CloudRunV2JobIdParseFunc), - "google_cloud_run_v2_job_iam_policy": tpgiamresource.ResourceIamPolicy(cloudrunv2.CloudRunV2JobIamSchema, cloudrunv2.CloudRunV2JobIamUpdaterProducer, cloudrunv2.CloudRunV2JobIdParseFunc), - "google_cloud_run_v2_service": cloudrunv2.ResourceCloudRunV2Service(), - "google_cloud_run_v2_service_iam_binding": tpgiamresource.ResourceIamBinding(cloudrunv2.CloudRunV2ServiceIamSchema, cloudrunv2.CloudRunV2ServiceIamUpdaterProducer, cloudrunv2.CloudRunV2ServiceIdParseFunc), - "google_cloud_run_v2_service_iam_member": tpgiamresource.ResourceIamMember(cloudrunv2.CloudRunV2ServiceIamSchema, cloudrunv2.CloudRunV2ServiceIamUpdaterProducer, cloudrunv2.CloudRunV2ServiceIdParseFunc), - "google_cloud_run_v2_service_iam_policy": tpgiamresource.ResourceIamPolicy(cloudrunv2.CloudRunV2ServiceIamSchema, cloudrunv2.CloudRunV2ServiceIamUpdaterProducer, cloudrunv2.CloudRunV2ServiceIdParseFunc), - "google_cloud_scheduler_job": cloudscheduler.ResourceCloudSchedulerJob(), - "google_cloud_tasks_queue": cloudtasks.ResourceCloudTasksQueue(), - "google_cloud_tasks_queue_iam_binding": tpgiamresource.ResourceIamBinding(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc), - "google_cloud_tasks_queue_iam_member": tpgiamresource.ResourceIamMember(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc), - "google_cloud_tasks_queue_iam_policy": tpgiamresource.ResourceIamPolicy(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc), - "google_compute_address": compute.ResourceComputeAddress(), - "google_compute_autoscaler": compute.ResourceComputeAutoscaler(), - "google_compute_backend_bucket": compute.ResourceComputeBackendBucket(), - "google_compute_backend_bucket_signed_url_key": compute.ResourceComputeBackendBucketSignedUrlKey(), - "google_compute_backend_service": compute.ResourceComputeBackendService(), - "google_compute_backend_service_signed_url_key": compute.ResourceComputeBackendServiceSignedUrlKey(), - "google_compute_disk": compute.ResourceComputeDisk(), - "google_compute_disk_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeDiskIamSchema, compute.ComputeDiskIamUpdaterProducer, compute.ComputeDiskIdParseFunc), - "google_compute_disk_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeDiskIamSchema, compute.ComputeDiskIamUpdaterProducer, compute.ComputeDiskIdParseFunc), - "google_compute_disk_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeDiskIamSchema, compute.ComputeDiskIamUpdaterProducer, compute.ComputeDiskIdParseFunc), - "google_compute_disk_resource_policy_attachment": compute.ResourceComputeDiskResourcePolicyAttachment(), - "google_compute_external_vpn_gateway": compute.ResourceComputeExternalVpnGateway(), - "google_compute_firewall": compute.ResourceComputeFirewall(), - "google_compute_forwarding_rule": compute.ResourceComputeForwardingRule(), - "google_compute_global_address": compute.ResourceComputeGlobalAddress(), - "google_compute_global_forwarding_rule": compute.ResourceComputeGlobalForwardingRule(), - "google_compute_global_network_endpoint": compute.ResourceComputeGlobalNetworkEndpoint(), - "google_compute_global_network_endpoint_group": compute.ResourceComputeGlobalNetworkEndpointGroup(), - "google_compute_ha_vpn_gateway": compute.ResourceComputeHaVpnGateway(), - "google_compute_health_check": compute.ResourceComputeHealthCheck(), - "google_compute_http_health_check": compute.ResourceComputeHttpHealthCheck(), - "google_compute_https_health_check": compute.ResourceComputeHttpsHealthCheck(), - "google_compute_image": compute.ResourceComputeImage(), - "google_compute_image_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeImageIamSchema, compute.ComputeImageIamUpdaterProducer, compute.ComputeImageIdParseFunc), - "google_compute_image_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeImageIamSchema, compute.ComputeImageIamUpdaterProducer, compute.ComputeImageIdParseFunc), - "google_compute_image_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeImageIamSchema, compute.ComputeImageIamUpdaterProducer, compute.ComputeImageIdParseFunc), - "google_compute_instance_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeInstanceIamSchema, compute.ComputeInstanceIamUpdaterProducer, compute.ComputeInstanceIdParseFunc), - "google_compute_instance_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeInstanceIamSchema, compute.ComputeInstanceIamUpdaterProducer, compute.ComputeInstanceIdParseFunc), - "google_compute_instance_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeInstanceIamSchema, compute.ComputeInstanceIamUpdaterProducer, compute.ComputeInstanceIdParseFunc), - "google_compute_instance_group_membership": compute.ResourceComputeInstanceGroupMembership(), - "google_compute_instance_group_named_port": compute.ResourceComputeInstanceGroupNamedPort(), - "google_compute_instance_settings": compute.ResourceComputeInstanceSettings(), - "google_compute_interconnect": compute.ResourceComputeInterconnect(), - "google_compute_interconnect_attachment": compute.ResourceComputeInterconnectAttachment(), - "google_compute_managed_ssl_certificate": compute.ResourceComputeManagedSslCertificate(), - "google_compute_network": compute.ResourceComputeNetwork(), - "google_compute_network_attachment": compute.ResourceComputeNetworkAttachment(), - "google_compute_network_endpoint": compute.ResourceComputeNetworkEndpoint(), - "google_compute_network_endpoint_group": compute.ResourceComputeNetworkEndpointGroup(), - "google_compute_network_endpoints": compute.ResourceComputeNetworkEndpoints(), - "google_compute_network_firewall_policy": compute.ResourceComputeNetworkFirewallPolicy(), - "google_compute_network_peering_routes_config": compute.ResourceComputeNetworkPeeringRoutesConfig(), - "google_compute_node_group": compute.ResourceComputeNodeGroup(), - "google_compute_node_template": compute.ResourceComputeNodeTemplate(), - "google_compute_packet_mirroring": compute.ResourceComputePacketMirroring(), - "google_compute_per_instance_config": compute.ResourceComputePerInstanceConfig(), - "google_compute_project_cloud_armor_tier": compute.ResourceComputeProjectCloudArmorTier(), - "google_compute_public_advertised_prefix": compute.ResourceComputePublicAdvertisedPrefix(), - "google_compute_public_delegated_prefix": compute.ResourceComputePublicDelegatedPrefix(), - "google_compute_region_autoscaler": compute.ResourceComputeRegionAutoscaler(), - "google_compute_region_backend_service": compute.ResourceComputeRegionBackendService(), - "google_compute_region_commitment": compute.ResourceComputeRegionCommitment(), - "google_compute_region_disk": compute.ResourceComputeRegionDisk(), - "google_compute_region_disk_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeRegionDiskIamSchema, compute.ComputeRegionDiskIamUpdaterProducer, compute.ComputeRegionDiskIdParseFunc), - "google_compute_region_disk_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeRegionDiskIamSchema, compute.ComputeRegionDiskIamUpdaterProducer, compute.ComputeRegionDiskIdParseFunc), - "google_compute_region_disk_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeRegionDiskIamSchema, compute.ComputeRegionDiskIamUpdaterProducer, compute.ComputeRegionDiskIdParseFunc), - "google_compute_region_disk_resource_policy_attachment": compute.ResourceComputeRegionDiskResourcePolicyAttachment(), - "google_compute_region_health_check": compute.ResourceComputeRegionHealthCheck(), - "google_compute_region_network_endpoint": compute.ResourceComputeRegionNetworkEndpoint(), - "google_compute_region_network_endpoint_group": compute.ResourceComputeRegionNetworkEndpointGroup(), - "google_compute_region_network_firewall_policy": compute.ResourceComputeRegionNetworkFirewallPolicy(), - "google_compute_region_per_instance_config": compute.ResourceComputeRegionPerInstanceConfig(), - "google_compute_region_ssl_certificate": compute.ResourceComputeRegionSslCertificate(), - "google_compute_region_ssl_policy": compute.ResourceComputeRegionSslPolicy(), - "google_compute_region_target_http_proxy": compute.ResourceComputeRegionTargetHttpProxy(), - "google_compute_region_target_https_proxy": compute.ResourceComputeRegionTargetHttpsProxy(), - "google_compute_region_target_tcp_proxy": compute.ResourceComputeRegionTargetTcpProxy(), - "google_compute_region_url_map": compute.ResourceComputeRegionUrlMap(), - "google_compute_reservation": compute.ResourceComputeReservation(), - "google_compute_resource_policy": compute.ResourceComputeResourcePolicy(), - "google_compute_route": compute.ResourceComputeRoute(), - "google_compute_router": compute.ResourceComputeRouter(), - "google_compute_router_nat": compute.ResourceComputeRouterNat(), - "google_compute_security_policy_rule": compute.ResourceComputeSecurityPolicyRule(), - "google_compute_service_attachment": compute.ResourceComputeServiceAttachment(), - "google_compute_snapshot": compute.ResourceComputeSnapshot(), - "google_compute_snapshot_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeSnapshotIamSchema, compute.ComputeSnapshotIamUpdaterProducer, compute.ComputeSnapshotIdParseFunc), - "google_compute_snapshot_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeSnapshotIamSchema, compute.ComputeSnapshotIamUpdaterProducer, compute.ComputeSnapshotIdParseFunc), - "google_compute_snapshot_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeSnapshotIamSchema, compute.ComputeSnapshotIamUpdaterProducer, compute.ComputeSnapshotIdParseFunc), - "google_compute_ssl_certificate": compute.ResourceComputeSslCertificate(), - "google_compute_ssl_policy": compute.ResourceComputeSslPolicy(), - "google_compute_subnetwork": compute.ResourceComputeSubnetwork(), - "google_compute_subnetwork_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeSubnetworkIamSchema, compute.ComputeSubnetworkIamUpdaterProducer, compute.ComputeSubnetworkIdParseFunc), - "google_compute_subnetwork_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeSubnetworkIamSchema, compute.ComputeSubnetworkIamUpdaterProducer, compute.ComputeSubnetworkIdParseFunc), - "google_compute_subnetwork_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeSubnetworkIamSchema, compute.ComputeSubnetworkIamUpdaterProducer, compute.ComputeSubnetworkIdParseFunc), - "google_compute_target_grpc_proxy": compute.ResourceComputeTargetGrpcProxy(), - "google_compute_target_http_proxy": compute.ResourceComputeTargetHttpProxy(), - "google_compute_target_https_proxy": compute.ResourceComputeTargetHttpsProxy(), - "google_compute_target_instance": compute.ResourceComputeTargetInstance(), - "google_compute_target_ssl_proxy": compute.ResourceComputeTargetSslProxy(), - "google_compute_target_tcp_proxy": compute.ResourceComputeTargetTcpProxy(), - "google_compute_url_map": compute.ResourceComputeUrlMap(), - "google_compute_vpn_gateway": compute.ResourceComputeVpnGateway(), - "google_compute_vpn_tunnel": compute.ResourceComputeVpnTunnel(), - "google_container_analysis_note": containeranalysis.ResourceContainerAnalysisNote(), - "google_container_analysis_note_iam_binding": tpgiamresource.ResourceIamBinding(containeranalysis.ContainerAnalysisNoteIamSchema, containeranalysis.ContainerAnalysisNoteIamUpdaterProducer, containeranalysis.ContainerAnalysisNoteIdParseFunc), - "google_container_analysis_note_iam_member": tpgiamresource.ResourceIamMember(containeranalysis.ContainerAnalysisNoteIamSchema, containeranalysis.ContainerAnalysisNoteIamUpdaterProducer, containeranalysis.ContainerAnalysisNoteIdParseFunc), - "google_container_analysis_note_iam_policy": tpgiamresource.ResourceIamPolicy(containeranalysis.ContainerAnalysisNoteIamSchema, containeranalysis.ContainerAnalysisNoteIamUpdaterProducer, containeranalysis.ContainerAnalysisNoteIdParseFunc), - "google_container_analysis_occurrence": containeranalysis.ResourceContainerAnalysisOccurrence(), - "google_container_attached_cluster": containerattached.ResourceContainerAttachedCluster(), - "google_billing_project_info": corebilling.ResourceCoreBillingProjectInfo(), - "google_database_migration_service_connection_profile": databasemigrationservice.ResourceDatabaseMigrationServiceConnectionProfile(), - "google_database_migration_service_private_connection": databasemigrationservice.ResourceDatabaseMigrationServicePrivateConnection(), - "google_data_catalog_entry": datacatalog.ResourceDataCatalogEntry(), - "google_data_catalog_entry_group": datacatalog.ResourceDataCatalogEntryGroup(), - "google_data_catalog_entry_group_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogEntryGroupIamSchema, datacatalog.DataCatalogEntryGroupIamUpdaterProducer, datacatalog.DataCatalogEntryGroupIdParseFunc), - "google_data_catalog_entry_group_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogEntryGroupIamSchema, datacatalog.DataCatalogEntryGroupIamUpdaterProducer, datacatalog.DataCatalogEntryGroupIdParseFunc), - "google_data_catalog_entry_group_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogEntryGroupIamSchema, datacatalog.DataCatalogEntryGroupIamUpdaterProducer, datacatalog.DataCatalogEntryGroupIdParseFunc), - "google_data_catalog_policy_tag": datacatalog.ResourceDataCatalogPolicyTag(), - "google_data_catalog_policy_tag_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogPolicyTagIamSchema, datacatalog.DataCatalogPolicyTagIamUpdaterProducer, datacatalog.DataCatalogPolicyTagIdParseFunc), - "google_data_catalog_policy_tag_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogPolicyTagIamSchema, datacatalog.DataCatalogPolicyTagIamUpdaterProducer, datacatalog.DataCatalogPolicyTagIdParseFunc), - "google_data_catalog_policy_tag_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogPolicyTagIamSchema, datacatalog.DataCatalogPolicyTagIamUpdaterProducer, datacatalog.DataCatalogPolicyTagIdParseFunc), - "google_data_catalog_tag": datacatalog.ResourceDataCatalogTag(), - "google_data_catalog_tag_template": datacatalog.ResourceDataCatalogTagTemplate(), - "google_data_catalog_tag_template_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer, datacatalog.DataCatalogTagTemplateIdParseFunc), - "google_data_catalog_tag_template_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer, datacatalog.DataCatalogTagTemplateIdParseFunc), - "google_data_catalog_tag_template_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer, datacatalog.DataCatalogTagTemplateIdParseFunc), - "google_data_catalog_taxonomy": datacatalog.ResourceDataCatalogTaxonomy(), - "google_data_catalog_taxonomy_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), - "google_data_catalog_taxonomy_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), - "google_data_catalog_taxonomy_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), - "google_data_fusion_instance": datafusion.ResourceDataFusionInstance(), - "google_data_fusion_instance_iam_binding": tpgiamresource.ResourceIamBinding(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), - "google_data_fusion_instance_iam_member": tpgiamresource.ResourceIamMember(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), - "google_data_fusion_instance_iam_policy": tpgiamresource.ResourceIamPolicy(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), - "google_data_loss_prevention_deidentify_template": datalossprevention.ResourceDataLossPreventionDeidentifyTemplate(), - "google_data_loss_prevention_discovery_config": datalossprevention.ResourceDataLossPreventionDiscoveryConfig(), - "google_data_loss_prevention_inspect_template": datalossprevention.ResourceDataLossPreventionInspectTemplate(), - "google_data_loss_prevention_job_trigger": datalossprevention.ResourceDataLossPreventionJobTrigger(), - "google_data_loss_prevention_stored_info_type": datalossprevention.ResourceDataLossPreventionStoredInfoType(), - "google_data_pipeline_pipeline": datapipeline.ResourceDataPipelinePipeline(), - "google_dataplex_aspect_type": dataplex.ResourceDataplexAspectType(), - "google_dataplex_aspect_type_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexAspectTypeIamSchema, dataplex.DataplexAspectTypeIamUpdaterProducer, dataplex.DataplexAspectTypeIdParseFunc), - "google_dataplex_aspect_type_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexAspectTypeIamSchema, dataplex.DataplexAspectTypeIamUpdaterProducer, dataplex.DataplexAspectTypeIdParseFunc), - "google_dataplex_aspect_type_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexAspectTypeIamSchema, dataplex.DataplexAspectTypeIamUpdaterProducer, dataplex.DataplexAspectTypeIdParseFunc), - "google_dataplex_asset_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer, dataplex.DataplexAssetIdParseFunc), - "google_dataplex_asset_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer, dataplex.DataplexAssetIdParseFunc), - "google_dataplex_asset_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer, dataplex.DataplexAssetIdParseFunc), - "google_dataplex_datascan": dataplex.ResourceDataplexDatascan(), - "google_dataplex_datascan_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer, dataplex.DataplexDatascanIdParseFunc), - "google_dataplex_datascan_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer, dataplex.DataplexDatascanIdParseFunc), - "google_dataplex_datascan_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer, dataplex.DataplexDatascanIdParseFunc), - "google_dataplex_entry_group": dataplex.ResourceDataplexEntryGroup(), - "google_dataplex_entry_group_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexEntryGroupIamSchema, dataplex.DataplexEntryGroupIamUpdaterProducer, dataplex.DataplexEntryGroupIdParseFunc), - "google_dataplex_entry_group_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexEntryGroupIamSchema, dataplex.DataplexEntryGroupIamUpdaterProducer, dataplex.DataplexEntryGroupIdParseFunc), - "google_dataplex_entry_group_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexEntryGroupIamSchema, dataplex.DataplexEntryGroupIamUpdaterProducer, dataplex.DataplexEntryGroupIdParseFunc), - "google_dataplex_entry_type": dataplex.ResourceDataplexEntryType(), - "google_dataplex_entry_type_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexEntryTypeIamSchema, dataplex.DataplexEntryTypeIamUpdaterProducer, dataplex.DataplexEntryTypeIdParseFunc), - "google_dataplex_entry_type_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexEntryTypeIamSchema, dataplex.DataplexEntryTypeIamUpdaterProducer, dataplex.DataplexEntryTypeIdParseFunc), - "google_dataplex_entry_type_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexEntryTypeIamSchema, dataplex.DataplexEntryTypeIamUpdaterProducer, dataplex.DataplexEntryTypeIdParseFunc), - "google_dataplex_lake_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer, dataplex.DataplexLakeIdParseFunc), - "google_dataplex_lake_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer, dataplex.DataplexLakeIdParseFunc), - "google_dataplex_lake_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer, dataplex.DataplexLakeIdParseFunc), - "google_dataplex_task": dataplex.ResourceDataplexTask(), - "google_dataplex_task_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer, dataplex.DataplexTaskIdParseFunc), - "google_dataplex_task_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer, dataplex.DataplexTaskIdParseFunc), - "google_dataplex_task_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer, dataplex.DataplexTaskIdParseFunc), - "google_dataplex_zone_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer, dataplex.DataplexZoneIdParseFunc), - "google_dataplex_zone_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer, dataplex.DataplexZoneIdParseFunc), - "google_dataplex_zone_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer, dataplex.DataplexZoneIdParseFunc), - "google_dataproc_autoscaling_policy": dataproc.ResourceDataprocAutoscalingPolicy(), - "google_dataproc_autoscaling_policy_iam_binding": tpgiamresource.ResourceIamBinding(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer, dataproc.DataprocAutoscalingPolicyIdParseFunc), - "google_dataproc_autoscaling_policy_iam_member": tpgiamresource.ResourceIamMember(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer, dataproc.DataprocAutoscalingPolicyIdParseFunc), - "google_dataproc_autoscaling_policy_iam_policy": tpgiamresource.ResourceIamPolicy(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer, dataproc.DataprocAutoscalingPolicyIdParseFunc), - "google_dataproc_metastore_federation": dataprocmetastore.ResourceDataprocMetastoreFederation(), - "google_dataproc_metastore_federation_iam_binding": tpgiamresource.ResourceIamBinding(dataprocmetastore.DataprocMetastoreFederationIamSchema, dataprocmetastore.DataprocMetastoreFederationIamUpdaterProducer, dataprocmetastore.DataprocMetastoreFederationIdParseFunc), - "google_dataproc_metastore_federation_iam_member": tpgiamresource.ResourceIamMember(dataprocmetastore.DataprocMetastoreFederationIamSchema, dataprocmetastore.DataprocMetastoreFederationIamUpdaterProducer, dataprocmetastore.DataprocMetastoreFederationIdParseFunc), - "google_dataproc_metastore_federation_iam_policy": tpgiamresource.ResourceIamPolicy(dataprocmetastore.DataprocMetastoreFederationIamSchema, dataprocmetastore.DataprocMetastoreFederationIamUpdaterProducer, dataprocmetastore.DataprocMetastoreFederationIdParseFunc), - "google_dataproc_metastore_service": dataprocmetastore.ResourceDataprocMetastoreService(), - "google_dataproc_metastore_service_iam_binding": tpgiamresource.ResourceIamBinding(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), - "google_dataproc_metastore_service_iam_member": tpgiamresource.ResourceIamMember(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), - "google_dataproc_metastore_service_iam_policy": tpgiamresource.ResourceIamPolicy(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), - "google_datastore_index": datastore.ResourceDatastoreIndex(), - "google_datastream_connection_profile": datastream.ResourceDatastreamConnectionProfile(), - "google_datastream_private_connection": datastream.ResourceDatastreamPrivateConnection(), - "google_datastream_stream": datastream.ResourceDatastreamStream(), - "google_deployment_manager_deployment": deploymentmanager.ResourceDeploymentManagerDeployment(), - "google_dialogflow_agent": dialogflow.ResourceDialogflowAgent(), - "google_dialogflow_entity_type": dialogflow.ResourceDialogflowEntityType(), - "google_dialogflow_fulfillment": dialogflow.ResourceDialogflowFulfillment(), - "google_dialogflow_intent": dialogflow.ResourceDialogflowIntent(), - "google_dialogflow_cx_agent": dialogflowcx.ResourceDialogflowCXAgent(), - "google_dialogflow_cx_entity_type": dialogflowcx.ResourceDialogflowCXEntityType(), - "google_dialogflow_cx_environment": dialogflowcx.ResourceDialogflowCXEnvironment(), - "google_dialogflow_cx_flow": dialogflowcx.ResourceDialogflowCXFlow(), - "google_dialogflow_cx_intent": dialogflowcx.ResourceDialogflowCXIntent(), - "google_dialogflow_cx_page": dialogflowcx.ResourceDialogflowCXPage(), - "google_dialogflow_cx_security_settings": dialogflowcx.ResourceDialogflowCXSecuritySettings(), - "google_dialogflow_cx_test_case": dialogflowcx.ResourceDialogflowCXTestCase(), - "google_dialogflow_cx_version": dialogflowcx.ResourceDialogflowCXVersion(), - "google_dialogflow_cx_webhook": dialogflowcx.ResourceDialogflowCXWebhook(), - "google_discovery_engine_chat_engine": discoveryengine.ResourceDiscoveryEngineChatEngine(), - "google_discovery_engine_data_store": discoveryengine.ResourceDiscoveryEngineDataStore(), - "google_discovery_engine_search_engine": discoveryengine.ResourceDiscoveryEngineSearchEngine(), - "google_dns_managed_zone": dns.ResourceDNSManagedZone(), - "google_dns_managed_zone_iam_binding": tpgiamresource.ResourceIamBinding(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer, dns.DNSManagedZoneIdParseFunc), - "google_dns_managed_zone_iam_member": tpgiamresource.ResourceIamMember(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer, dns.DNSManagedZoneIdParseFunc), - "google_dns_managed_zone_iam_policy": tpgiamresource.ResourceIamPolicy(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer, dns.DNSManagedZoneIdParseFunc), - "google_dns_policy": dns.ResourceDNSPolicy(), - "google_dns_response_policy": dns.ResourceDNSResponsePolicy(), - "google_dns_response_policy_rule": dns.ResourceDNSResponsePolicyRule(), - "google_document_ai_processor": documentai.ResourceDocumentAIProcessor(), - "google_document_ai_processor_default_version": documentai.ResourceDocumentAIProcessorDefaultVersion(), - "google_document_ai_warehouse_document_schema": documentaiwarehouse.ResourceDocumentAIWarehouseDocumentSchema(), - "google_document_ai_warehouse_location": documentaiwarehouse.ResourceDocumentAIWarehouseLocation(), - "google_edgecontainer_cluster": edgecontainer.ResourceEdgecontainerCluster(), - "google_edgecontainer_node_pool": edgecontainer.ResourceEdgecontainerNodePool(), - "google_edgecontainer_vpn_connection": edgecontainer.ResourceEdgecontainerVpnConnection(), - "google_edgenetwork_network": edgenetwork.ResourceEdgenetworkNetwork(), - "google_edgenetwork_subnet": edgenetwork.ResourceEdgenetworkSubnet(), - "google_essential_contacts_contact": essentialcontacts.ResourceEssentialContactsContact(), - "google_filestore_backup": filestore.ResourceFilestoreBackup(), - "google_filestore_instance": filestore.ResourceFilestoreInstance(), - "google_filestore_snapshot": filestore.ResourceFilestoreSnapshot(), - "google_firebase_app_check_app_attest_config": firebaseappcheck.ResourceFirebaseAppCheckAppAttestConfig(), - "google_firebase_app_check_debug_token": firebaseappcheck.ResourceFirebaseAppCheckDebugToken(), - "google_firebase_app_check_device_check_config": firebaseappcheck.ResourceFirebaseAppCheckDeviceCheckConfig(), - "google_firebase_app_check_play_integrity_config": firebaseappcheck.ResourceFirebaseAppCheckPlayIntegrityConfig(), - "google_firebase_app_check_recaptcha_enterprise_config": firebaseappcheck.ResourceFirebaseAppCheckRecaptchaEnterpriseConfig(), - "google_firebase_app_check_recaptcha_v3_config": firebaseappcheck.ResourceFirebaseAppCheckRecaptchaV3Config(), - "google_firebase_app_check_service_config": firebaseappcheck.ResourceFirebaseAppCheckServiceConfig(), - "google_firestore_backup_schedule": firestore.ResourceFirestoreBackupSchedule(), - "google_firestore_database": firestore.ResourceFirestoreDatabase(), - "google_firestore_document": firestore.ResourceFirestoreDocument(), - "google_firestore_field": firestore.ResourceFirestoreField(), - "google_firestore_index": firestore.ResourceFirestoreIndex(), - "google_gke_backup_backup_plan": gkebackup.ResourceGKEBackupBackupPlan(), - "google_gke_backup_backup_plan_iam_binding": tpgiamresource.ResourceIamBinding(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc), - "google_gke_backup_backup_plan_iam_member": tpgiamresource.ResourceIamMember(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc), - "google_gke_backup_backup_plan_iam_policy": tpgiamresource.ResourceIamPolicy(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc), - "google_gke_backup_restore_plan": gkebackup.ResourceGKEBackupRestorePlan(), - "google_gke_backup_restore_plan_iam_binding": tpgiamresource.ResourceIamBinding(gkebackup.GKEBackupRestorePlanIamSchema, gkebackup.GKEBackupRestorePlanIamUpdaterProducer, gkebackup.GKEBackupRestorePlanIdParseFunc), - "google_gke_backup_restore_plan_iam_member": tpgiamresource.ResourceIamMember(gkebackup.GKEBackupRestorePlanIamSchema, gkebackup.GKEBackupRestorePlanIamUpdaterProducer, gkebackup.GKEBackupRestorePlanIdParseFunc), - "google_gke_backup_restore_plan_iam_policy": tpgiamresource.ResourceIamPolicy(gkebackup.GKEBackupRestorePlanIamSchema, gkebackup.GKEBackupRestorePlanIamUpdaterProducer, gkebackup.GKEBackupRestorePlanIdParseFunc), - "google_gke_hub_membership": gkehub.ResourceGKEHubMembership(), - "google_gke_hub_membership_iam_binding": tpgiamresource.ResourceIamBinding(gkehub.GKEHubMembershipIamSchema, gkehub.GKEHubMembershipIamUpdaterProducer, gkehub.GKEHubMembershipIdParseFunc), - "google_gke_hub_membership_iam_member": tpgiamresource.ResourceIamMember(gkehub.GKEHubMembershipIamSchema, gkehub.GKEHubMembershipIamUpdaterProducer, gkehub.GKEHubMembershipIdParseFunc), - "google_gke_hub_membership_iam_policy": tpgiamresource.ResourceIamPolicy(gkehub.GKEHubMembershipIamSchema, gkehub.GKEHubMembershipIamUpdaterProducer, gkehub.GKEHubMembershipIdParseFunc), - "google_gke_hub_feature": gkehub2.ResourceGKEHub2Feature(), - "google_gke_hub_feature_iam_binding": tpgiamresource.ResourceIamBinding(gkehub2.GKEHub2FeatureIamSchema, gkehub2.GKEHub2FeatureIamUpdaterProducer, gkehub2.GKEHub2FeatureIdParseFunc), - "google_gke_hub_feature_iam_member": tpgiamresource.ResourceIamMember(gkehub2.GKEHub2FeatureIamSchema, gkehub2.GKEHub2FeatureIamUpdaterProducer, gkehub2.GKEHub2FeatureIdParseFunc), - "google_gke_hub_feature_iam_policy": tpgiamresource.ResourceIamPolicy(gkehub2.GKEHub2FeatureIamSchema, gkehub2.GKEHub2FeatureIamUpdaterProducer, gkehub2.GKEHub2FeatureIdParseFunc), - "google_gke_hub_fleet": gkehub2.ResourceGKEHub2Fleet(), - "google_gke_hub_membership_binding": gkehub2.ResourceGKEHub2MembershipBinding(), - "google_gke_hub_namespace": gkehub2.ResourceGKEHub2Namespace(), - "google_gke_hub_scope": gkehub2.ResourceGKEHub2Scope(), - "google_gke_hub_scope_iam_binding": tpgiamresource.ResourceIamBinding(gkehub2.GKEHub2ScopeIamSchema, gkehub2.GKEHub2ScopeIamUpdaterProducer, gkehub2.GKEHub2ScopeIdParseFunc), - "google_gke_hub_scope_iam_member": tpgiamresource.ResourceIamMember(gkehub2.GKEHub2ScopeIamSchema, gkehub2.GKEHub2ScopeIamUpdaterProducer, gkehub2.GKEHub2ScopeIdParseFunc), - "google_gke_hub_scope_iam_policy": tpgiamresource.ResourceIamPolicy(gkehub2.GKEHub2ScopeIamSchema, gkehub2.GKEHub2ScopeIamUpdaterProducer, gkehub2.GKEHub2ScopeIdParseFunc), - "google_gke_hub_scope_rbac_role_binding": gkehub2.ResourceGKEHub2ScopeRBACRoleBinding(), - "google_gkeonprem_bare_metal_admin_cluster": gkeonprem.ResourceGkeonpremBareMetalAdminCluster(), - "google_gkeonprem_bare_metal_cluster": gkeonprem.ResourceGkeonpremBareMetalCluster(), - "google_gkeonprem_bare_metal_node_pool": gkeonprem.ResourceGkeonpremBareMetalNodePool(), - "google_gkeonprem_vmware_cluster": gkeonprem.ResourceGkeonpremVmwareCluster(), - "google_gkeonprem_vmware_node_pool": gkeonprem.ResourceGkeonpremVmwareNodePool(), - "google_healthcare_consent_store": healthcare.ResourceHealthcareConsentStore(), - "google_healthcare_consent_store_iam_binding": tpgiamresource.ResourceIamBinding(healthcare.HealthcareConsentStoreIamSchema, healthcare.HealthcareConsentStoreIamUpdaterProducer, healthcare.HealthcareConsentStoreIdParseFunc), - "google_healthcare_consent_store_iam_member": tpgiamresource.ResourceIamMember(healthcare.HealthcareConsentStoreIamSchema, healthcare.HealthcareConsentStoreIamUpdaterProducer, healthcare.HealthcareConsentStoreIdParseFunc), - "google_healthcare_consent_store_iam_policy": tpgiamresource.ResourceIamPolicy(healthcare.HealthcareConsentStoreIamSchema, healthcare.HealthcareConsentStoreIamUpdaterProducer, healthcare.HealthcareConsentStoreIdParseFunc), - "google_healthcare_dataset": healthcare.ResourceHealthcareDataset(), - "google_healthcare_dicom_store": healthcare.ResourceHealthcareDicomStore(), - "google_healthcare_fhir_store": healthcare.ResourceHealthcareFhirStore(), - "google_healthcare_hl7_v2_store": healthcare.ResourceHealthcareHl7V2Store(), - "google_iam_access_boundary_policy": iam2.ResourceIAM2AccessBoundaryPolicy(), - "google_iam_deny_policy": iam2.ResourceIAM2DenyPolicy(), - "google_iam_workload_identity_pool": iambeta.ResourceIAMBetaWorkloadIdentityPool(), - "google_iam_workload_identity_pool_provider": iambeta.ResourceIAMBetaWorkloadIdentityPoolProvider(), - "google_iam_workforce_pool": iamworkforcepool.ResourceIAMWorkforcePoolWorkforcePool(), - "google_iam_workforce_pool_provider": iamworkforcepool.ResourceIAMWorkforcePoolWorkforcePoolProvider(), - "google_iap_app_engine_service_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapAppEngineServiceIamSchema, iap.IapAppEngineServiceIamUpdaterProducer, iap.IapAppEngineServiceIdParseFunc), - "google_iap_app_engine_service_iam_member": tpgiamresource.ResourceIamMember(iap.IapAppEngineServiceIamSchema, iap.IapAppEngineServiceIamUpdaterProducer, iap.IapAppEngineServiceIdParseFunc), - "google_iap_app_engine_service_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapAppEngineServiceIamSchema, iap.IapAppEngineServiceIamUpdaterProducer, iap.IapAppEngineServiceIdParseFunc), - "google_iap_app_engine_version_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapAppEngineVersionIamSchema, iap.IapAppEngineVersionIamUpdaterProducer, iap.IapAppEngineVersionIdParseFunc), - "google_iap_app_engine_version_iam_member": tpgiamresource.ResourceIamMember(iap.IapAppEngineVersionIamSchema, iap.IapAppEngineVersionIamUpdaterProducer, iap.IapAppEngineVersionIdParseFunc), - "google_iap_app_engine_version_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapAppEngineVersionIamSchema, iap.IapAppEngineVersionIamUpdaterProducer, iap.IapAppEngineVersionIdParseFunc), - "google_iap_brand": iap.ResourceIapBrand(), - "google_iap_client": iap.ResourceIapClient(), - "google_iap_tunnel_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapTunnelIamSchema, iap.IapTunnelIamUpdaterProducer, iap.IapTunnelIdParseFunc), - "google_iap_tunnel_iam_member": tpgiamresource.ResourceIamMember(iap.IapTunnelIamSchema, iap.IapTunnelIamUpdaterProducer, iap.IapTunnelIdParseFunc), - "google_iap_tunnel_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapTunnelIamSchema, iap.IapTunnelIamUpdaterProducer, iap.IapTunnelIdParseFunc), - "google_iap_tunnel_dest_group": iap.ResourceIapTunnelDestGroup(), - "google_iap_tunnel_dest_group_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapTunnelDestGroupIamSchema, iap.IapTunnelDestGroupIamUpdaterProducer, iap.IapTunnelDestGroupIdParseFunc), - "google_iap_tunnel_dest_group_iam_member": tpgiamresource.ResourceIamMember(iap.IapTunnelDestGroupIamSchema, iap.IapTunnelDestGroupIamUpdaterProducer, iap.IapTunnelDestGroupIdParseFunc), - "google_iap_tunnel_dest_group_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapTunnelDestGroupIamSchema, iap.IapTunnelDestGroupIamUpdaterProducer, iap.IapTunnelDestGroupIdParseFunc), - "google_iap_tunnel_instance_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapTunnelInstanceIamSchema, iap.IapTunnelInstanceIamUpdaterProducer, iap.IapTunnelInstanceIdParseFunc), - "google_iap_tunnel_instance_iam_member": tpgiamresource.ResourceIamMember(iap.IapTunnelInstanceIamSchema, iap.IapTunnelInstanceIamUpdaterProducer, iap.IapTunnelInstanceIdParseFunc), - "google_iap_tunnel_instance_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapTunnelInstanceIamSchema, iap.IapTunnelInstanceIamUpdaterProducer, iap.IapTunnelInstanceIdParseFunc), - "google_iap_web_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebIamSchema, iap.IapWebIamUpdaterProducer, iap.IapWebIdParseFunc), - "google_iap_web_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebIamSchema, iap.IapWebIamUpdaterProducer, iap.IapWebIdParseFunc), - "google_iap_web_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebIamSchema, iap.IapWebIamUpdaterProducer, iap.IapWebIdParseFunc), - "google_iap_web_backend_service_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebBackendServiceIamSchema, iap.IapWebBackendServiceIamUpdaterProducer, iap.IapWebBackendServiceIdParseFunc), - "google_iap_web_backend_service_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebBackendServiceIamSchema, iap.IapWebBackendServiceIamUpdaterProducer, iap.IapWebBackendServiceIdParseFunc), - "google_iap_web_backend_service_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebBackendServiceIamSchema, iap.IapWebBackendServiceIamUpdaterProducer, iap.IapWebBackendServiceIdParseFunc), - "google_iap_web_region_backend_service_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer, iap.IapWebRegionBackendServiceIdParseFunc), - "google_iap_web_region_backend_service_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer, iap.IapWebRegionBackendServiceIdParseFunc), - "google_iap_web_region_backend_service_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer, iap.IapWebRegionBackendServiceIdParseFunc), - "google_iap_web_type_app_engine_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer, iap.IapWebTypeAppEngineIdParseFunc), - "google_iap_web_type_app_engine_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer, iap.IapWebTypeAppEngineIdParseFunc), - "google_iap_web_type_app_engine_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer, iap.IapWebTypeAppEngineIdParseFunc), - "google_iap_web_type_compute_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer, iap.IapWebTypeComputeIdParseFunc), - "google_iap_web_type_compute_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer, iap.IapWebTypeComputeIdParseFunc), - "google_iap_web_type_compute_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer, iap.IapWebTypeComputeIdParseFunc), - "google_identity_platform_config": identityplatform.ResourceIdentityPlatformConfig(), - "google_identity_platform_default_supported_idp_config": identityplatform.ResourceIdentityPlatformDefaultSupportedIdpConfig(), - "google_identity_platform_inbound_saml_config": identityplatform.ResourceIdentityPlatformInboundSamlConfig(), - "google_identity_platform_oauth_idp_config": identityplatform.ResourceIdentityPlatformOauthIdpConfig(), - "google_identity_platform_project_default_config": identityplatform.ResourceIdentityPlatformProjectDefaultConfig(), - "google_identity_platform_tenant": identityplatform.ResourceIdentityPlatformTenant(), - "google_identity_platform_tenant_default_supported_idp_config": identityplatform.ResourceIdentityPlatformTenantDefaultSupportedIdpConfig(), - "google_identity_platform_tenant_inbound_saml_config": identityplatform.ResourceIdentityPlatformTenantInboundSamlConfig(), - "google_identity_platform_tenant_oauth_idp_config": identityplatform.ResourceIdentityPlatformTenantOauthIdpConfig(), - "google_integration_connectors_connection": integrationconnectors.ResourceIntegrationConnectorsConnection(), - "google_integration_connectors_endpoint_attachment": integrationconnectors.ResourceIntegrationConnectorsEndpointAttachment(), - "google_integration_connectors_managed_zone": integrationconnectors.ResourceIntegrationConnectorsManagedZone(), - "google_integrations_auth_config": integrations.ResourceIntegrationsAuthConfig(), - "google_integrations_client": integrations.ResourceIntegrationsClient(), - "google_kms_crypto_key": kms.ResourceKMSCryptoKey(), - "google_kms_crypto_key_version": kms.ResourceKMSCryptoKeyVersion(), - "google_kms_ekm_connection": kms.ResourceKMSEkmConnection(), - "google_kms_key_ring": kms.ResourceKMSKeyRing(), - "google_kms_key_ring_import_job": kms.ResourceKMSKeyRingImportJob(), - "google_kms_secret_ciphertext": kms.ResourceKMSSecretCiphertext(), - "google_logging_folder_settings": logging.ResourceLoggingFolderSettings(), - "google_logging_linked_dataset": logging.ResourceLoggingLinkedDataset(), - "google_logging_log_view": logging.ResourceLoggingLogView(), - "google_logging_metric": logging.ResourceLoggingMetric(), - "google_logging_organization_settings": logging.ResourceLoggingOrganizationSettings(), - "google_looker_instance": looker.ResourceLookerInstance(), - "google_memcache_instance": memcache.ResourceMemcacheInstance(), - "google_migration_center_group": migrationcenter.ResourceMigrationCenterGroup(), - "google_migration_center_preference_set": migrationcenter.ResourceMigrationCenterPreferenceSet(), - "google_ml_engine_model": mlengine.ResourceMLEngineModel(), - "google_monitoring_alert_policy": monitoring.ResourceMonitoringAlertPolicy(), - "google_monitoring_service": monitoring.ResourceMonitoringGenericService(), - "google_monitoring_group": monitoring.ResourceMonitoringGroup(), - "google_monitoring_metric_descriptor": monitoring.ResourceMonitoringMetricDescriptor(), - "google_monitoring_monitored_project": monitoring.ResourceMonitoringMonitoredProject(), - "google_monitoring_notification_channel": monitoring.ResourceMonitoringNotificationChannel(), - "google_monitoring_custom_service": monitoring.ResourceMonitoringService(), - "google_monitoring_slo": monitoring.ResourceMonitoringSlo(), - "google_monitoring_uptime_check_config": monitoring.ResourceMonitoringUptimeCheckConfig(), - "google_netapp_volume": netapp.ResourceNetappVolume(), - "google_netapp_volume_replication": netapp.ResourceNetappVolumeReplication(), - "google_netapp_volume_snapshot": netapp.ResourceNetappVolumeSnapshot(), - "google_netapp_active_directory": netapp.ResourceNetappactiveDirectory(), - "google_netapp_backup": netapp.ResourceNetappbackup(), - "google_netapp_backup_policy": netapp.ResourceNetappbackupPolicy(), - "google_netapp_backup_vault": netapp.ResourceNetappbackupVault(), - "google_netapp_kmsconfig": netapp.ResourceNetappkmsconfig(), - "google_netapp_storage_pool": netapp.ResourceNetappstoragePool(), - "google_network_connectivity_internal_range": networkconnectivity.ResourceNetworkConnectivityInternalRange(), - "google_network_connectivity_policy_based_route": networkconnectivity.ResourceNetworkConnectivityPolicyBasedRoute(), - "google_network_connectivity_regional_endpoint": networkconnectivity.ResourceNetworkConnectivityRegionalEndpoint(), - "google_network_connectivity_service_connection_policy": networkconnectivity.ResourceNetworkConnectivityServiceConnectionPolicy(), - "google_network_management_connectivity_test": networkmanagement.ResourceNetworkManagementConnectivityTest(), - "google_network_security_address_group": networksecurity.ResourceNetworkSecurityAddressGroup(), - "google_network_security_firewall_endpoint": networksecurity.ResourceNetworkSecurityFirewallEndpoint(), - "google_network_security_firewall_endpoint_association": networksecurity.ResourceNetworkSecurityFirewallEndpointAssociation(), - "google_network_security_gateway_security_policy": networksecurity.ResourceNetworkSecurityGatewaySecurityPolicy(), - "google_network_security_gateway_security_policy_rule": networksecurity.ResourceNetworkSecurityGatewaySecurityPolicyRule(), - "google_network_security_address_group_iam_binding": tpgiamresource.ResourceIamBinding(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), - "google_network_security_address_group_iam_member": tpgiamresource.ResourceIamMember(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), - "google_network_security_address_group_iam_policy": tpgiamresource.ResourceIamPolicy(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), - "google_network_security_security_profile": networksecurity.ResourceNetworkSecuritySecurityProfile(), - "google_network_security_security_profile_group": networksecurity.ResourceNetworkSecuritySecurityProfileGroup(), - "google_network_security_tls_inspection_policy": networksecurity.ResourceNetworkSecurityTlsInspectionPolicy(), - "google_network_security_url_lists": networksecurity.ResourceNetworkSecurityUrlLists(), - "google_network_services_edge_cache_keyset": networkservices.ResourceNetworkServicesEdgeCacheKeyset(), - "google_network_services_edge_cache_origin": networkservices.ResourceNetworkServicesEdgeCacheOrigin(), - "google_network_services_edge_cache_service": networkservices.ResourceNetworkServicesEdgeCacheService(), - "google_network_services_gateway": networkservices.ResourceNetworkServicesGateway(), - "google_network_services_lb_route_extension": networkservices.ResourceNetworkServicesLbRouteExtension(), - "google_network_services_lb_traffic_extension": networkservices.ResourceNetworkServicesLbTrafficExtension(), - "google_notebooks_environment": notebooks.ResourceNotebooksEnvironment(), - "google_notebooks_instance": notebooks.ResourceNotebooksInstance(), - "google_notebooks_instance_iam_binding": tpgiamresource.ResourceIamBinding(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer, notebooks.NotebooksInstanceIdParseFunc), - "google_notebooks_instance_iam_member": tpgiamresource.ResourceIamMember(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer, notebooks.NotebooksInstanceIdParseFunc), - "google_notebooks_instance_iam_policy": tpgiamresource.ResourceIamPolicy(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer, notebooks.NotebooksInstanceIdParseFunc), - "google_notebooks_location": notebooks.ResourceNotebooksLocation(), - "google_notebooks_runtime": notebooks.ResourceNotebooksRuntime(), - "google_notebooks_runtime_iam_binding": tpgiamresource.ResourceIamBinding(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer, notebooks.NotebooksRuntimeIdParseFunc), - "google_notebooks_runtime_iam_member": tpgiamresource.ResourceIamMember(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer, notebooks.NotebooksRuntimeIdParseFunc), - "google_notebooks_runtime_iam_policy": tpgiamresource.ResourceIamPolicy(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer, notebooks.NotebooksRuntimeIdParseFunc), - "google_org_policy_custom_constraint": orgpolicy.ResourceOrgPolicyCustomConstraint(), - "google_org_policy_policy": orgpolicy.ResourceOrgPolicyPolicy(), - "google_os_config_patch_deployment": osconfig.ResourceOSConfigPatchDeployment(), - "google_os_login_ssh_public_key": oslogin.ResourceOSLoginSSHPublicKey(), - "google_privateca_ca_pool": privateca.ResourcePrivatecaCaPool(), - "google_privateca_ca_pool_iam_binding": tpgiamresource.ResourceIamBinding(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), - "google_privateca_ca_pool_iam_member": tpgiamresource.ResourceIamMember(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), - "google_privateca_ca_pool_iam_policy": tpgiamresource.ResourceIamPolicy(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), - "google_privateca_certificate": privateca.ResourcePrivatecaCertificate(), - "google_privateca_certificate_authority": privateca.ResourcePrivatecaCertificateAuthority(), - "google_privateca_certificate_template": privateca.ResourcePrivatecaCertificateTemplate(), - "google_privateca_certificate_template_iam_binding": tpgiamresource.ResourceIamBinding(privateca.PrivatecaCertificateTemplateIamSchema, privateca.PrivatecaCertificateTemplateIamUpdaterProducer, privateca.PrivatecaCertificateTemplateIdParseFunc), - "google_privateca_certificate_template_iam_member": tpgiamresource.ResourceIamMember(privateca.PrivatecaCertificateTemplateIamSchema, privateca.PrivatecaCertificateTemplateIamUpdaterProducer, privateca.PrivatecaCertificateTemplateIdParseFunc), - "google_privateca_certificate_template_iam_policy": tpgiamresource.ResourceIamPolicy(privateca.PrivatecaCertificateTemplateIamSchema, privateca.PrivatecaCertificateTemplateIamUpdaterProducer, privateca.PrivatecaCertificateTemplateIdParseFunc), - "google_public_ca_external_account_key": publicca.ResourcePublicCAExternalAccountKey(), - "google_pubsub_schema": pubsub.ResourcePubsubSchema(), - "google_pubsub_schema_iam_binding": tpgiamresource.ResourceIamBinding(pubsub.PubsubSchemaIamSchema, pubsub.PubsubSchemaIamUpdaterProducer, pubsub.PubsubSchemaIdParseFunc), - "google_pubsub_schema_iam_member": tpgiamresource.ResourceIamMember(pubsub.PubsubSchemaIamSchema, pubsub.PubsubSchemaIamUpdaterProducer, pubsub.PubsubSchemaIdParseFunc), - "google_pubsub_schema_iam_policy": tpgiamresource.ResourceIamPolicy(pubsub.PubsubSchemaIamSchema, pubsub.PubsubSchemaIamUpdaterProducer, pubsub.PubsubSchemaIdParseFunc), - "google_pubsub_subscription": pubsub.ResourcePubsubSubscription(), - "google_pubsub_topic": pubsub.ResourcePubsubTopic(), - "google_pubsub_topic_iam_binding": tpgiamresource.ResourceIamBinding(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer, pubsub.PubsubTopicIdParseFunc), - "google_pubsub_topic_iam_member": tpgiamresource.ResourceIamMember(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer, pubsub.PubsubTopicIdParseFunc), - "google_pubsub_topic_iam_policy": tpgiamresource.ResourceIamPolicy(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer, pubsub.PubsubTopicIdParseFunc), - "google_pubsub_lite_reservation": pubsublite.ResourcePubsubLiteReservation(), - "google_pubsub_lite_subscription": pubsublite.ResourcePubsubLiteSubscription(), - "google_pubsub_lite_topic": pubsublite.ResourcePubsubLiteTopic(), - "google_redis_cluster": redis.ResourceRedisCluster(), - "google_redis_instance": redis.ResourceRedisInstance(), - "google_resource_manager_lien": resourcemanager.ResourceResourceManagerLien(), - "google_secret_manager_secret": secretmanager.ResourceSecretManagerSecret(), - "google_secret_manager_secret_iam_binding": tpgiamresource.ResourceIamBinding(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer, secretmanager.SecretManagerSecretIdParseFunc), - "google_secret_manager_secret_iam_member": tpgiamresource.ResourceIamMember(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer, secretmanager.SecretManagerSecretIdParseFunc), - "google_secret_manager_secret_iam_policy": tpgiamresource.ResourceIamPolicy(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer, secretmanager.SecretManagerSecretIdParseFunc), - "google_secret_manager_secret_version": secretmanager.ResourceSecretManagerSecretVersion(), - "google_secure_source_manager_instance": securesourcemanager.ResourceSecureSourceManagerInstance(), - "google_secure_source_manager_instance_iam_binding": tpgiamresource.ResourceIamBinding(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer, securesourcemanager.SecureSourceManagerInstanceIdParseFunc), - "google_secure_source_manager_instance_iam_member": tpgiamresource.ResourceIamMember(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer, securesourcemanager.SecureSourceManagerInstanceIdParseFunc), - "google_secure_source_manager_instance_iam_policy": tpgiamresource.ResourceIamPolicy(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer, securesourcemanager.SecureSourceManagerInstanceIdParseFunc), - "google_secure_source_manager_repository": securesourcemanager.ResourceSecureSourceManagerRepository(), - "google_secure_source_manager_repository_iam_binding": tpgiamresource.ResourceIamBinding(securesourcemanager.SecureSourceManagerRepositoryIamSchema, securesourcemanager.SecureSourceManagerRepositoryIamUpdaterProducer, securesourcemanager.SecureSourceManagerRepositoryIdParseFunc), - "google_secure_source_manager_repository_iam_member": tpgiamresource.ResourceIamMember(securesourcemanager.SecureSourceManagerRepositoryIamSchema, securesourcemanager.SecureSourceManagerRepositoryIamUpdaterProducer, securesourcemanager.SecureSourceManagerRepositoryIdParseFunc), - "google_secure_source_manager_repository_iam_policy": tpgiamresource.ResourceIamPolicy(securesourcemanager.SecureSourceManagerRepositoryIamSchema, securesourcemanager.SecureSourceManagerRepositoryIamUpdaterProducer, securesourcemanager.SecureSourceManagerRepositoryIdParseFunc), - "google_scc_event_threat_detection_custom_module": securitycenter.ResourceSecurityCenterEventThreatDetectionCustomModule(), - "google_scc_folder_custom_module": securitycenter.ResourceSecurityCenterFolderCustomModule(), - "google_scc_mute_config": securitycenter.ResourceSecurityCenterMuteConfig(), - "google_scc_notification_config": securitycenter.ResourceSecurityCenterNotificationConfig(), - "google_scc_organization_custom_module": securitycenter.ResourceSecurityCenterOrganizationCustomModule(), - "google_scc_project_custom_module": securitycenter.ResourceSecurityCenterProjectCustomModule(), - "google_scc_source": securitycenter.ResourceSecurityCenterSource(), - "google_scc_source_iam_binding": tpgiamresource.ResourceIamBinding(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc), - "google_scc_source_iam_member": tpgiamresource.ResourceIamMember(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc), - "google_scc_source_iam_policy": tpgiamresource.ResourceIamPolicy(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc), - "google_scc_management_folder_security_health_analytics_custom_module": securitycentermanagement.ResourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule(), - "google_scc_management_organization_event_threat_detection_custom_module": securitycentermanagement.ResourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModule(), - "google_scc_management_organization_security_health_analytics_custom_module": securitycentermanagement.ResourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule(), - "google_scc_management_project_security_health_analytics_custom_module": securitycentermanagement.ResourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule(), - "google_scc_v2_organization_notification_config": securitycenterv2.ResourceSecurityCenterV2OrganizationNotificationConfig(), - "google_securityposture_posture": securityposture.ResourceSecurityposturePosture(), - "google_securityposture_posture_deployment": securityposture.ResourceSecurityposturePostureDeployment(), - "google_endpoints_service_iam_binding": tpgiamresource.ResourceIamBinding(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer, servicemanagement.ServiceManagementServiceIdParseFunc), - "google_endpoints_service_iam_member": tpgiamresource.ResourceIamMember(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer, servicemanagement.ServiceManagementServiceIdParseFunc), - "google_endpoints_service_iam_policy": tpgiamresource.ResourceIamPolicy(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer, servicemanagement.ServiceManagementServiceIdParseFunc), - "google_endpoints_service_consumers_iam_binding": tpgiamresource.ResourceIamBinding(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer, servicemanagement.ServiceManagementServiceConsumersIdParseFunc), - "google_endpoints_service_consumers_iam_member": tpgiamresource.ResourceIamMember(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer, servicemanagement.ServiceManagementServiceConsumersIdParseFunc), - "google_endpoints_service_consumers_iam_policy": tpgiamresource.ResourceIamPolicy(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer, servicemanagement.ServiceManagementServiceConsumersIdParseFunc), - "google_service_networking_vpc_service_controls": servicenetworking.ResourceServiceNetworkingVPCServiceControls(), - "google_sourcerepo_repository": sourcerepo.ResourceSourceRepoRepository(), - "google_sourcerepo_repository_iam_binding": tpgiamresource.ResourceIamBinding(sourcerepo.SourceRepoRepositoryIamSchema, sourcerepo.SourceRepoRepositoryIamUpdaterProducer, sourcerepo.SourceRepoRepositoryIdParseFunc), - "google_sourcerepo_repository_iam_member": tpgiamresource.ResourceIamMember(sourcerepo.SourceRepoRepositoryIamSchema, sourcerepo.SourceRepoRepositoryIamUpdaterProducer, sourcerepo.SourceRepoRepositoryIdParseFunc), - "google_sourcerepo_repository_iam_policy": tpgiamresource.ResourceIamPolicy(sourcerepo.SourceRepoRepositoryIamSchema, sourcerepo.SourceRepoRepositoryIamUpdaterProducer, sourcerepo.SourceRepoRepositoryIdParseFunc), - "google_spanner_database": spanner.ResourceSpannerDatabase(), - "google_spanner_instance": spanner.ResourceSpannerInstance(), - "google_spanner_instance_config": spanner.ResourceSpannerInstanceConfig(), - "google_sql_database": sql.ResourceSQLDatabase(), - "google_sql_source_representation_instance": sql.ResourceSQLSourceRepresentationInstance(), - "google_storage_bucket_iam_binding": tpgiamresource.ResourceIamBinding(storage.StorageBucketIamSchema, storage.StorageBucketIamUpdaterProducer, storage.StorageBucketIdParseFunc), - "google_storage_bucket_iam_member": tpgiamresource.ResourceIamMember(storage.StorageBucketIamSchema, storage.StorageBucketIamUpdaterProducer, storage.StorageBucketIdParseFunc), - "google_storage_bucket_iam_policy": tpgiamresource.ResourceIamPolicy(storage.StorageBucketIamSchema, storage.StorageBucketIamUpdaterProducer, storage.StorageBucketIdParseFunc), - "google_storage_bucket_access_control": storage.ResourceStorageBucketAccessControl(), - "google_storage_default_object_access_control": storage.ResourceStorageDefaultObjectAccessControl(), - "google_storage_hmac_key": storage.ResourceStorageHmacKey(), - "google_storage_managed_folder": storage.ResourceStorageManagedFolder(), - "google_storage_object_access_control": storage.ResourceStorageObjectAccessControl(), - "google_storage_insights_report_config": storageinsights.ResourceStorageInsightsReportConfig(), - "google_storage_transfer_agent_pool": storagetransfer.ResourceStorageTransferAgentPool(), - "google_tags_tag_binding": tags.ResourceTagsTagBinding(), - "google_tags_tag_key": tags.ResourceTagsTagKey(), - "google_tags_tag_key_iam_binding": tpgiamresource.ResourceIamBinding(tags.TagsTagKeyIamSchema, tags.TagsTagKeyIamUpdaterProducer, tags.TagsTagKeyIdParseFunc), - "google_tags_tag_key_iam_member": tpgiamresource.ResourceIamMember(tags.TagsTagKeyIamSchema, tags.TagsTagKeyIamUpdaterProducer, tags.TagsTagKeyIdParseFunc), - "google_tags_tag_key_iam_policy": tpgiamresource.ResourceIamPolicy(tags.TagsTagKeyIamSchema, tags.TagsTagKeyIamUpdaterProducer, tags.TagsTagKeyIdParseFunc), - "google_tags_tag_value": tags.ResourceTagsTagValue(), - "google_tags_tag_value_iam_binding": tpgiamresource.ResourceIamBinding(tags.TagsTagValueIamSchema, tags.TagsTagValueIamUpdaterProducer, tags.TagsTagValueIdParseFunc), - "google_tags_tag_value_iam_member": tpgiamresource.ResourceIamMember(tags.TagsTagValueIamSchema, tags.TagsTagValueIamUpdaterProducer, tags.TagsTagValueIdParseFunc), - "google_tags_tag_value_iam_policy": tpgiamresource.ResourceIamPolicy(tags.TagsTagValueIamSchema, tags.TagsTagValueIamUpdaterProducer, tags.TagsTagValueIdParseFunc), - "google_tpu_node": tpu.ResourceTPUNode(), - "google_vertex_ai_dataset": vertexai.ResourceVertexAIDataset(), - "google_vertex_ai_deployment_resource_pool": vertexai.ResourceVertexAIDeploymentResourcePool(), - "google_vertex_ai_endpoint": vertexai.ResourceVertexAIEndpoint(), - "google_vertex_ai_feature_group": vertexai.ResourceVertexAIFeatureGroup(), - "google_vertex_ai_feature_group_feature": vertexai.ResourceVertexAIFeatureGroupFeature(), - "google_vertex_ai_feature_online_store": vertexai.ResourceVertexAIFeatureOnlineStore(), - "google_vertex_ai_feature_online_store_featureview": vertexai.ResourceVertexAIFeatureOnlineStoreFeatureview(), - "google_vertex_ai_featurestore": vertexai.ResourceVertexAIFeaturestore(), - "google_vertex_ai_featurestore_entitytype": vertexai.ResourceVertexAIFeaturestoreEntitytype(), - "google_vertex_ai_featurestore_entitytype_feature": vertexai.ResourceVertexAIFeaturestoreEntitytypeFeature(), - "google_vertex_ai_index": vertexai.ResourceVertexAIIndex(), - "google_vertex_ai_index_endpoint": vertexai.ResourceVertexAIIndexEndpoint(), - "google_vertex_ai_tensorboard": vertexai.ResourceVertexAITensorboard(), - "google_vmwareengine_cluster": vmwareengine.ResourceVmwareengineCluster(), - "google_vmwareengine_external_access_rule": vmwareengine.ResourceVmwareengineExternalAccessRule(), - "google_vmwareengine_external_address": vmwareengine.ResourceVmwareengineExternalAddress(), - "google_vmwareengine_network": vmwareengine.ResourceVmwareengineNetwork(), - "google_vmwareengine_network_peering": vmwareengine.ResourceVmwareengineNetworkPeering(), - "google_vmwareengine_network_policy": vmwareengine.ResourceVmwareengineNetworkPolicy(), - "google_vmwareengine_private_cloud": vmwareengine.ResourceVmwareenginePrivateCloud(), - "google_vmwareengine_subnet": vmwareengine.ResourceVmwareengineSubnet(), - "google_vpc_access_connector": vpcaccess.ResourceVPCAccessConnector(), - "google_workbench_instance": workbench.ResourceWorkbenchInstance(), - "google_workbench_instance_iam_binding": tpgiamresource.ResourceIamBinding(workbench.WorkbenchInstanceIamSchema, workbench.WorkbenchInstanceIamUpdaterProducer, workbench.WorkbenchInstanceIdParseFunc), - "google_workbench_instance_iam_member": tpgiamresource.ResourceIamMember(workbench.WorkbenchInstanceIamSchema, workbench.WorkbenchInstanceIamUpdaterProducer, workbench.WorkbenchInstanceIdParseFunc), - "google_workbench_instance_iam_policy": tpgiamresource.ResourceIamPolicy(workbench.WorkbenchInstanceIamSchema, workbench.WorkbenchInstanceIamUpdaterProducer, workbench.WorkbenchInstanceIdParseFunc), - "google_workflows_workflow": workflows.ResourceWorkflowsWorkflow(), + "google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(), + "google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(), + "google_project_access_approval_settings": accessapproval.ResourceAccessApprovalProjectSettings(), + "google_access_context_manager_access_level": accesscontextmanager.ResourceAccessContextManagerAccessLevel(), + "google_access_context_manager_access_level_condition": accesscontextmanager.ResourceAccessContextManagerAccessLevelCondition(), + "google_access_context_manager_access_levels": accesscontextmanager.ResourceAccessContextManagerAccessLevels(), + "google_access_context_manager_access_policy": accesscontextmanager.ResourceAccessContextManagerAccessPolicy(), + "google_access_context_manager_access_policy_iam_binding": tpgiamresource.ResourceIamBinding(accesscontextmanager.AccessContextManagerAccessPolicyIamSchema, accesscontextmanager.AccessContextManagerAccessPolicyIamUpdaterProducer, accesscontextmanager.AccessContextManagerAccessPolicyIdParseFunc), + "google_access_context_manager_access_policy_iam_member": tpgiamresource.ResourceIamMember(accesscontextmanager.AccessContextManagerAccessPolicyIamSchema, accesscontextmanager.AccessContextManagerAccessPolicyIamUpdaterProducer, accesscontextmanager.AccessContextManagerAccessPolicyIdParseFunc), + "google_access_context_manager_access_policy_iam_policy": tpgiamresource.ResourceIamPolicy(accesscontextmanager.AccessContextManagerAccessPolicyIamSchema, accesscontextmanager.AccessContextManagerAccessPolicyIamUpdaterProducer, accesscontextmanager.AccessContextManagerAccessPolicyIdParseFunc), + "google_access_context_manager_authorized_orgs_desc": accesscontextmanager.ResourceAccessContextManagerAuthorizedOrgsDesc(), + "google_access_context_manager_egress_policy": accesscontextmanager.ResourceAccessContextManagerEgressPolicy(), + "google_access_context_manager_gcp_user_access_binding": accesscontextmanager.ResourceAccessContextManagerGcpUserAccessBinding(), + "google_access_context_manager_ingress_policy": accesscontextmanager.ResourceAccessContextManagerIngressPolicy(), + "google_access_context_manager_service_perimeter": accesscontextmanager.ResourceAccessContextManagerServicePerimeter(), + "google_access_context_manager_service_perimeter_egress_policy": accesscontextmanager.ResourceAccessContextManagerServicePerimeterEgressPolicy(), + "google_access_context_manager_service_perimeter_ingress_policy": accesscontextmanager.ResourceAccessContextManagerServicePerimeterIngressPolicy(), + "google_access_context_manager_service_perimeter_resource": accesscontextmanager.ResourceAccessContextManagerServicePerimeterResource(), + "google_access_context_manager_service_perimeters": accesscontextmanager.ResourceAccessContextManagerServicePerimeters(), + "google_active_directory_domain": activedirectory.ResourceActiveDirectoryDomain(), + "google_active_directory_domain_trust": activedirectory.ResourceActiveDirectoryDomainTrust(), + "google_alloydb_backup": alloydb.ResourceAlloydbBackup(), + "google_alloydb_cluster": alloydb.ResourceAlloydbCluster(), + "google_alloydb_instance": alloydb.ResourceAlloydbInstance(), + "google_alloydb_user": alloydb.ResourceAlloydbUser(), + "google_apigee_addons_config": apigee.ResourceApigeeAddonsConfig(), + "google_apigee_endpoint_attachment": apigee.ResourceApigeeEndpointAttachment(), + "google_apigee_env_keystore": apigee.ResourceApigeeEnvKeystore(), + "google_apigee_env_references": apigee.ResourceApigeeEnvReferences(), + "google_apigee_envgroup": apigee.ResourceApigeeEnvgroup(), + "google_apigee_envgroup_attachment": apigee.ResourceApigeeEnvgroupAttachment(), + "google_apigee_environment": apigee.ResourceApigeeEnvironment(), + "google_apigee_environment_iam_binding": tpgiamresource.ResourceIamBinding(apigee.ApigeeEnvironmentIamSchema, apigee.ApigeeEnvironmentIamUpdaterProducer, apigee.ApigeeEnvironmentIdParseFunc), + "google_apigee_environment_iam_member": tpgiamresource.ResourceIamMember(apigee.ApigeeEnvironmentIamSchema, apigee.ApigeeEnvironmentIamUpdaterProducer, apigee.ApigeeEnvironmentIdParseFunc), + "google_apigee_environment_iam_policy": tpgiamresource.ResourceIamPolicy(apigee.ApigeeEnvironmentIamSchema, apigee.ApigeeEnvironmentIamUpdaterProducer, apigee.ApigeeEnvironmentIdParseFunc), + "google_apigee_instance": apigee.ResourceApigeeInstance(), + "google_apigee_instance_attachment": apigee.ResourceApigeeInstanceAttachment(), + "google_apigee_keystores_aliases_self_signed_cert": apigee.ResourceApigeeKeystoresAliasesSelfSignedCert(), + "google_apigee_nat_address": apigee.ResourceApigeeNatAddress(), + "google_apigee_organization": apigee.ResourceApigeeOrganization(), + "google_apigee_sync_authorization": apigee.ResourceApigeeSyncAuthorization(), + "google_apigee_target_server": apigee.ResourceApigeeTargetServer(), + "google_app_engine_application_url_dispatch_rules": appengine.ResourceAppEngineApplicationUrlDispatchRules(), + "google_app_engine_domain_mapping": appengine.ResourceAppEngineDomainMapping(), + "google_app_engine_firewall_rule": appengine.ResourceAppEngineFirewallRule(), + "google_app_engine_flexible_app_version": appengine.ResourceAppEngineFlexibleAppVersion(), + "google_app_engine_service_network_settings": appengine.ResourceAppEngineServiceNetworkSettings(), + "google_app_engine_service_split_traffic": appengine.ResourceAppEngineServiceSplitTraffic(), + "google_app_engine_standard_app_version": appengine.ResourceAppEngineStandardAppVersion(), + "google_apphub_application": apphub.ResourceApphubApplication(), + "google_apphub_service": apphub.ResourceApphubService(), + "google_apphub_service_project_attachment": apphub.ResourceApphubServiceProjectAttachment(), + "google_apphub_workload": apphub.ResourceApphubWorkload(), + "google_artifact_registry_repository": artifactregistry.ResourceArtifactRegistryRepository(), + "google_artifact_registry_repository_iam_binding": tpgiamresource.ResourceIamBinding(artifactregistry.ArtifactRegistryRepositoryIamSchema, artifactregistry.ArtifactRegistryRepositoryIamUpdaterProducer, artifactregistry.ArtifactRegistryRepositoryIdParseFunc), + "google_artifact_registry_repository_iam_member": tpgiamresource.ResourceIamMember(artifactregistry.ArtifactRegistryRepositoryIamSchema, artifactregistry.ArtifactRegistryRepositoryIamUpdaterProducer, artifactregistry.ArtifactRegistryRepositoryIdParseFunc), + "google_artifact_registry_repository_iam_policy": tpgiamresource.ResourceIamPolicy(artifactregistry.ArtifactRegistryRepositoryIamSchema, artifactregistry.ArtifactRegistryRepositoryIamUpdaterProducer, artifactregistry.ArtifactRegistryRepositoryIdParseFunc), + "google_beyondcorp_app_connection": beyondcorp.ResourceBeyondcorpAppConnection(), + "google_beyondcorp_app_connector": beyondcorp.ResourceBeyondcorpAppConnector(), + "google_beyondcorp_app_gateway": beyondcorp.ResourceBeyondcorpAppGateway(), + "google_biglake_catalog": biglake.ResourceBiglakeCatalog(), + "google_biglake_database": biglake.ResourceBiglakeDatabase(), + "google_biglake_table": biglake.ResourceBiglakeTable(), + "google_bigquery_dataset": bigquery.ResourceBigQueryDataset(), + "google_bigquery_dataset_access": bigquery.ResourceBigQueryDatasetAccess(), + "google_bigquery_job": bigquery.ResourceBigQueryJob(), + "google_bigquery_routine": bigquery.ResourceBigQueryRoutine(), + "google_bigquery_table_iam_binding": tpgiamresource.ResourceIamBinding(bigquery.BigQueryTableIamSchema, bigquery.BigQueryTableIamUpdaterProducer, bigquery.BigQueryTableIdParseFunc), + "google_bigquery_table_iam_member": tpgiamresource.ResourceIamMember(bigquery.BigQueryTableIamSchema, bigquery.BigQueryTableIamUpdaterProducer, bigquery.BigQueryTableIdParseFunc), + "google_bigquery_table_iam_policy": tpgiamresource.ResourceIamPolicy(bigquery.BigQueryTableIamSchema, bigquery.BigQueryTableIamUpdaterProducer, bigquery.BigQueryTableIdParseFunc), + "google_bigquery_analytics_hub_data_exchange": bigqueryanalyticshub.ResourceBigqueryAnalyticsHubDataExchange(), + "google_bigquery_analytics_hub_data_exchange_iam_binding": tpgiamresource.ResourceIamBinding(bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIdParseFunc), + "google_bigquery_analytics_hub_data_exchange_iam_member": tpgiamresource.ResourceIamMember(bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIdParseFunc), + "google_bigquery_analytics_hub_data_exchange_iam_policy": tpgiamresource.ResourceIamPolicy(bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubDataExchangeIdParseFunc), + "google_bigquery_analytics_hub_listing": bigqueryanalyticshub.ResourceBigqueryAnalyticsHubListing(), + "google_bigquery_analytics_hub_listing_iam_binding": tpgiamresource.ResourceIamBinding(bigqueryanalyticshub.BigqueryAnalyticsHubListingIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubListingIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubListingIdParseFunc), + "google_bigquery_analytics_hub_listing_iam_member": tpgiamresource.ResourceIamMember(bigqueryanalyticshub.BigqueryAnalyticsHubListingIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubListingIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubListingIdParseFunc), + "google_bigquery_analytics_hub_listing_iam_policy": tpgiamresource.ResourceIamPolicy(bigqueryanalyticshub.BigqueryAnalyticsHubListingIamSchema, bigqueryanalyticshub.BigqueryAnalyticsHubListingIamUpdaterProducer, bigqueryanalyticshub.BigqueryAnalyticsHubListingIdParseFunc), + "google_bigquery_connection": bigqueryconnection.ResourceBigqueryConnectionConnection(), + "google_bigquery_connection_iam_binding": tpgiamresource.ResourceIamBinding(bigqueryconnection.BigqueryConnectionConnectionIamSchema, bigqueryconnection.BigqueryConnectionConnectionIamUpdaterProducer, bigqueryconnection.BigqueryConnectionConnectionIdParseFunc), + "google_bigquery_connection_iam_member": tpgiamresource.ResourceIamMember(bigqueryconnection.BigqueryConnectionConnectionIamSchema, bigqueryconnection.BigqueryConnectionConnectionIamUpdaterProducer, bigqueryconnection.BigqueryConnectionConnectionIdParseFunc), + "google_bigquery_connection_iam_policy": tpgiamresource.ResourceIamPolicy(bigqueryconnection.BigqueryConnectionConnectionIamSchema, bigqueryconnection.BigqueryConnectionConnectionIamUpdaterProducer, bigqueryconnection.BigqueryConnectionConnectionIdParseFunc), + "google_bigquery_datapolicy_data_policy": bigquerydatapolicy.ResourceBigqueryDatapolicyDataPolicy(), + "google_bigquery_datapolicy_data_policy_iam_binding": tpgiamresource.ResourceIamBinding(bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamSchema, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamUpdaterProducer, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIdParseFunc), + "google_bigquery_datapolicy_data_policy_iam_member": tpgiamresource.ResourceIamMember(bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamSchema, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamUpdaterProducer, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIdParseFunc), + "google_bigquery_datapolicy_data_policy_iam_policy": tpgiamresource.ResourceIamPolicy(bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamSchema, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIamUpdaterProducer, bigquerydatapolicy.BigqueryDatapolicyDataPolicyIdParseFunc), + "google_bigquery_data_transfer_config": bigquerydatatransfer.ResourceBigqueryDataTransferConfig(), + "google_bigquery_bi_reservation": bigqueryreservation.ResourceBigqueryReservationBiReservation(), + "google_bigquery_capacity_commitment": bigqueryreservation.ResourceBigqueryReservationCapacityCommitment(), + "google_bigquery_reservation": bigqueryreservation.ResourceBigqueryReservationReservation(), + "google_bigtable_app_profile": bigtable.ResourceBigtableAppProfile(), + "google_billing_budget": billing.ResourceBillingBudget(), + "google_binary_authorization_attestor": binaryauthorization.ResourceBinaryAuthorizationAttestor(), + "google_binary_authorization_attestor_iam_binding": tpgiamresource.ResourceIamBinding(binaryauthorization.BinaryAuthorizationAttestorIamSchema, binaryauthorization.BinaryAuthorizationAttestorIamUpdaterProducer, binaryauthorization.BinaryAuthorizationAttestorIdParseFunc), + "google_binary_authorization_attestor_iam_member": tpgiamresource.ResourceIamMember(binaryauthorization.BinaryAuthorizationAttestorIamSchema, binaryauthorization.BinaryAuthorizationAttestorIamUpdaterProducer, binaryauthorization.BinaryAuthorizationAttestorIdParseFunc), + "google_binary_authorization_attestor_iam_policy": tpgiamresource.ResourceIamPolicy(binaryauthorization.BinaryAuthorizationAttestorIamSchema, binaryauthorization.BinaryAuthorizationAttestorIamUpdaterProducer, binaryauthorization.BinaryAuthorizationAttestorIdParseFunc), + "google_binary_authorization_policy": binaryauthorization.ResourceBinaryAuthorizationPolicy(), + "google_blockchain_node_engine_blockchain_nodes": blockchainnodeengine.ResourceBlockchainNodeEngineBlockchainNodes(), + "google_certificate_manager_certificate": certificatemanager.ResourceCertificateManagerCertificate(), + "google_certificate_manager_certificate_issuance_config": certificatemanager.ResourceCertificateManagerCertificateIssuanceConfig(), + "google_certificate_manager_certificate_map": certificatemanager.ResourceCertificateManagerCertificateMap(), + "google_certificate_manager_certificate_map_entry": certificatemanager.ResourceCertificateManagerCertificateMapEntry(), + "google_certificate_manager_dns_authorization": certificatemanager.ResourceCertificateManagerDnsAuthorization(), + "google_certificate_manager_trust_config": certificatemanager.ResourceCertificateManagerTrustConfig(), + "google_cloud_asset_folder_feed": cloudasset.ResourceCloudAssetFolderFeed(), + "google_cloud_asset_organization_feed": cloudasset.ResourceCloudAssetOrganizationFeed(), + "google_cloud_asset_project_feed": cloudasset.ResourceCloudAssetProjectFeed(), + "google_cloudbuild_bitbucket_server_config": cloudbuild.ResourceCloudBuildBitbucketServerConfig(), + "google_cloudbuild_trigger": cloudbuild.ResourceCloudBuildTrigger(), + "google_cloudbuildv2_connection": cloudbuildv2.ResourceCloudbuildv2Connection(), + "google_cloudbuildv2_connection_iam_binding": tpgiamresource.ResourceIamBinding(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc), + "google_cloudbuildv2_connection_iam_member": tpgiamresource.ResourceIamMember(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc), + "google_cloudbuildv2_connection_iam_policy": tpgiamresource.ResourceIamPolicy(cloudbuildv2.Cloudbuildv2ConnectionIamSchema, cloudbuildv2.Cloudbuildv2ConnectionIamUpdaterProducer, cloudbuildv2.Cloudbuildv2ConnectionIdParseFunc), + "google_cloudbuildv2_repository": cloudbuildv2.ResourceCloudbuildv2Repository(), + "google_clouddeploy_automation": clouddeploy.ResourceClouddeployAutomation(), + "google_clouddeploy_custom_target_type": clouddeploy.ResourceClouddeployCustomTargetType(), + "google_clouddeploy_custom_target_type_iam_binding": tpgiamresource.ResourceIamBinding(clouddeploy.ClouddeployCustomTargetTypeIamSchema, clouddeploy.ClouddeployCustomTargetTypeIamUpdaterProducer, clouddeploy.ClouddeployCustomTargetTypeIdParseFunc), + "google_clouddeploy_custom_target_type_iam_member": tpgiamresource.ResourceIamMember(clouddeploy.ClouddeployCustomTargetTypeIamSchema, clouddeploy.ClouddeployCustomTargetTypeIamUpdaterProducer, clouddeploy.ClouddeployCustomTargetTypeIdParseFunc), + "google_clouddeploy_custom_target_type_iam_policy": tpgiamresource.ResourceIamPolicy(clouddeploy.ClouddeployCustomTargetTypeIamSchema, clouddeploy.ClouddeployCustomTargetTypeIamUpdaterProducer, clouddeploy.ClouddeployCustomTargetTypeIdParseFunc), + "google_clouddeploy_delivery_pipeline_iam_binding": tpgiamresource.ResourceIamBinding(clouddeploy.ClouddeployDeliveryPipelineIamSchema, clouddeploy.ClouddeployDeliveryPipelineIamUpdaterProducer, clouddeploy.ClouddeployDeliveryPipelineIdParseFunc), + "google_clouddeploy_delivery_pipeline_iam_member": tpgiamresource.ResourceIamMember(clouddeploy.ClouddeployDeliveryPipelineIamSchema, clouddeploy.ClouddeployDeliveryPipelineIamUpdaterProducer, clouddeploy.ClouddeployDeliveryPipelineIdParseFunc), + "google_clouddeploy_delivery_pipeline_iam_policy": tpgiamresource.ResourceIamPolicy(clouddeploy.ClouddeployDeliveryPipelineIamSchema, clouddeploy.ClouddeployDeliveryPipelineIamUpdaterProducer, clouddeploy.ClouddeployDeliveryPipelineIdParseFunc), + "google_clouddeploy_target_iam_binding": tpgiamresource.ResourceIamBinding(clouddeploy.ClouddeployTargetIamSchema, clouddeploy.ClouddeployTargetIamUpdaterProducer, clouddeploy.ClouddeployTargetIdParseFunc), + "google_clouddeploy_target_iam_member": tpgiamresource.ResourceIamMember(clouddeploy.ClouddeployTargetIamSchema, clouddeploy.ClouddeployTargetIamUpdaterProducer, clouddeploy.ClouddeployTargetIdParseFunc), + "google_clouddeploy_target_iam_policy": tpgiamresource.ResourceIamPolicy(clouddeploy.ClouddeployTargetIamSchema, clouddeploy.ClouddeployTargetIamUpdaterProducer, clouddeploy.ClouddeployTargetIdParseFunc), + "google_clouddomains_registration": clouddomains.ResourceClouddomainsRegistration(), + "google_cloudfunctions_function_iam_binding": tpgiamresource.ResourceIamBinding(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc), + "google_cloudfunctions_function_iam_member": tpgiamresource.ResourceIamMember(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc), + "google_cloudfunctions_function_iam_policy": tpgiamresource.ResourceIamPolicy(cloudfunctions.CloudFunctionsCloudFunctionIamSchema, cloudfunctions.CloudFunctionsCloudFunctionIamUpdaterProducer, cloudfunctions.CloudFunctionsCloudFunctionIdParseFunc), + "google_cloudfunctions2_function": cloudfunctions2.ResourceCloudfunctions2function(), + "google_cloudfunctions2_function_iam_binding": tpgiamresource.ResourceIamBinding(cloudfunctions2.Cloudfunctions2functionIamSchema, cloudfunctions2.Cloudfunctions2functionIamUpdaterProducer, cloudfunctions2.Cloudfunctions2functionIdParseFunc), + "google_cloudfunctions2_function_iam_member": tpgiamresource.ResourceIamMember(cloudfunctions2.Cloudfunctions2functionIamSchema, cloudfunctions2.Cloudfunctions2functionIamUpdaterProducer, cloudfunctions2.Cloudfunctions2functionIdParseFunc), + "google_cloudfunctions2_function_iam_policy": tpgiamresource.ResourceIamPolicy(cloudfunctions2.Cloudfunctions2functionIamSchema, cloudfunctions2.Cloudfunctions2functionIamUpdaterProducer, cloudfunctions2.Cloudfunctions2functionIdParseFunc), + "google_cloud_identity_group": cloudidentity.ResourceCloudIdentityGroup(), + "google_cloud_identity_group_membership": cloudidentity.ResourceCloudIdentityGroupMembership(), + "google_cloud_ids_endpoint": cloudids.ResourceCloudIdsEndpoint(), + "google_cloud_run_domain_mapping": cloudrun.ResourceCloudRunDomainMapping(), + "google_cloud_run_service": cloudrun.ResourceCloudRunService(), + "google_cloud_run_service_iam_binding": tpgiamresource.ResourceIamBinding(cloudrun.CloudRunServiceIamSchema, cloudrun.CloudRunServiceIamUpdaterProducer, cloudrun.CloudRunServiceIdParseFunc), + "google_cloud_run_service_iam_member": tpgiamresource.ResourceIamMember(cloudrun.CloudRunServiceIamSchema, cloudrun.CloudRunServiceIamUpdaterProducer, cloudrun.CloudRunServiceIdParseFunc), + "google_cloud_run_service_iam_policy": tpgiamresource.ResourceIamPolicy(cloudrun.CloudRunServiceIamSchema, cloudrun.CloudRunServiceIamUpdaterProducer, cloudrun.CloudRunServiceIdParseFunc), + "google_cloud_run_v2_job": cloudrunv2.ResourceCloudRunV2Job(), + "google_cloud_run_v2_job_iam_binding": tpgiamresource.ResourceIamBinding(cloudrunv2.CloudRunV2JobIamSchema, cloudrunv2.CloudRunV2JobIamUpdaterProducer, cloudrunv2.CloudRunV2JobIdParseFunc), + "google_cloud_run_v2_job_iam_member": tpgiamresource.ResourceIamMember(cloudrunv2.CloudRunV2JobIamSchema, cloudrunv2.CloudRunV2JobIamUpdaterProducer, cloudrunv2.CloudRunV2JobIdParseFunc), + "google_cloud_run_v2_job_iam_policy": tpgiamresource.ResourceIamPolicy(cloudrunv2.CloudRunV2JobIamSchema, cloudrunv2.CloudRunV2JobIamUpdaterProducer, cloudrunv2.CloudRunV2JobIdParseFunc), + "google_cloud_run_v2_service": cloudrunv2.ResourceCloudRunV2Service(), + "google_cloud_run_v2_service_iam_binding": tpgiamresource.ResourceIamBinding(cloudrunv2.CloudRunV2ServiceIamSchema, cloudrunv2.CloudRunV2ServiceIamUpdaterProducer, cloudrunv2.CloudRunV2ServiceIdParseFunc), + "google_cloud_run_v2_service_iam_member": tpgiamresource.ResourceIamMember(cloudrunv2.CloudRunV2ServiceIamSchema, cloudrunv2.CloudRunV2ServiceIamUpdaterProducer, cloudrunv2.CloudRunV2ServiceIdParseFunc), + "google_cloud_run_v2_service_iam_policy": tpgiamresource.ResourceIamPolicy(cloudrunv2.CloudRunV2ServiceIamSchema, cloudrunv2.CloudRunV2ServiceIamUpdaterProducer, cloudrunv2.CloudRunV2ServiceIdParseFunc), + "google_cloud_scheduler_job": cloudscheduler.ResourceCloudSchedulerJob(), + "google_cloud_tasks_queue": cloudtasks.ResourceCloudTasksQueue(), + "google_cloud_tasks_queue_iam_binding": tpgiamresource.ResourceIamBinding(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc), + "google_cloud_tasks_queue_iam_member": tpgiamresource.ResourceIamMember(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc), + "google_cloud_tasks_queue_iam_policy": tpgiamresource.ResourceIamPolicy(cloudtasks.CloudTasksQueueIamSchema, cloudtasks.CloudTasksQueueIamUpdaterProducer, cloudtasks.CloudTasksQueueIdParseFunc), + "google_compute_address": compute.ResourceComputeAddress(), + "google_compute_autoscaler": compute.ResourceComputeAutoscaler(), + "google_compute_backend_bucket": compute.ResourceComputeBackendBucket(), + "google_compute_backend_bucket_signed_url_key": compute.ResourceComputeBackendBucketSignedUrlKey(), + "google_compute_backend_service": compute.ResourceComputeBackendService(), + "google_compute_backend_service_signed_url_key": compute.ResourceComputeBackendServiceSignedUrlKey(), + "google_compute_disk": compute.ResourceComputeDisk(), + "google_compute_disk_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeDiskIamSchema, compute.ComputeDiskIamUpdaterProducer, compute.ComputeDiskIdParseFunc), + "google_compute_disk_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeDiskIamSchema, compute.ComputeDiskIamUpdaterProducer, compute.ComputeDiskIdParseFunc), + "google_compute_disk_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeDiskIamSchema, compute.ComputeDiskIamUpdaterProducer, compute.ComputeDiskIdParseFunc), + "google_compute_disk_resource_policy_attachment": compute.ResourceComputeDiskResourcePolicyAttachment(), + "google_compute_external_vpn_gateway": compute.ResourceComputeExternalVpnGateway(), + "google_compute_firewall": compute.ResourceComputeFirewall(), + "google_compute_forwarding_rule": compute.ResourceComputeForwardingRule(), + "google_compute_global_address": compute.ResourceComputeGlobalAddress(), + "google_compute_global_forwarding_rule": compute.ResourceComputeGlobalForwardingRule(), + "google_compute_global_network_endpoint": compute.ResourceComputeGlobalNetworkEndpoint(), + "google_compute_global_network_endpoint_group": compute.ResourceComputeGlobalNetworkEndpointGroup(), + "google_compute_ha_vpn_gateway": compute.ResourceComputeHaVpnGateway(), + "google_compute_health_check": compute.ResourceComputeHealthCheck(), + "google_compute_http_health_check": compute.ResourceComputeHttpHealthCheck(), + "google_compute_https_health_check": compute.ResourceComputeHttpsHealthCheck(), + "google_compute_image": compute.ResourceComputeImage(), + "google_compute_image_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeImageIamSchema, compute.ComputeImageIamUpdaterProducer, compute.ComputeImageIdParseFunc), + "google_compute_image_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeImageIamSchema, compute.ComputeImageIamUpdaterProducer, compute.ComputeImageIdParseFunc), + "google_compute_image_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeImageIamSchema, compute.ComputeImageIamUpdaterProducer, compute.ComputeImageIdParseFunc), + "google_compute_instance_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeInstanceIamSchema, compute.ComputeInstanceIamUpdaterProducer, compute.ComputeInstanceIdParseFunc), + "google_compute_instance_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeInstanceIamSchema, compute.ComputeInstanceIamUpdaterProducer, compute.ComputeInstanceIdParseFunc), + "google_compute_instance_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeInstanceIamSchema, compute.ComputeInstanceIamUpdaterProducer, compute.ComputeInstanceIdParseFunc), + "google_compute_instance_group_membership": compute.ResourceComputeInstanceGroupMembership(), + "google_compute_instance_group_named_port": compute.ResourceComputeInstanceGroupNamedPort(), + "google_compute_interconnect_attachment": compute.ResourceComputeInterconnectAttachment(), + "google_compute_managed_ssl_certificate": compute.ResourceComputeManagedSslCertificate(), + "google_compute_network": compute.ResourceComputeNetwork(), + "google_compute_network_endpoint": compute.ResourceComputeNetworkEndpoint(), + "google_compute_network_endpoint_group": compute.ResourceComputeNetworkEndpointGroup(), + "google_compute_network_endpoints": compute.ResourceComputeNetworkEndpoints(), + "google_compute_network_firewall_policy": compute.ResourceComputeNetworkFirewallPolicy(), + "google_compute_network_peering_routes_config": compute.ResourceComputeNetworkPeeringRoutesConfig(), + "google_compute_node_group": compute.ResourceComputeNodeGroup(), + "google_compute_node_template": compute.ResourceComputeNodeTemplate(), + "google_compute_packet_mirroring": compute.ResourceComputePacketMirroring(), + "google_compute_per_instance_config": compute.ResourceComputePerInstanceConfig(), + "google_compute_public_advertised_prefix": compute.ResourceComputePublicAdvertisedPrefix(), + "google_compute_public_delegated_prefix": compute.ResourceComputePublicDelegatedPrefix(), + "google_compute_region_autoscaler": compute.ResourceComputeRegionAutoscaler(), + "google_compute_region_backend_service": compute.ResourceComputeRegionBackendService(), + "google_compute_region_commitment": compute.ResourceComputeRegionCommitment(), + "google_compute_region_disk": compute.ResourceComputeRegionDisk(), + "google_compute_region_disk_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeRegionDiskIamSchema, compute.ComputeRegionDiskIamUpdaterProducer, compute.ComputeRegionDiskIdParseFunc), + "google_compute_region_disk_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeRegionDiskIamSchema, compute.ComputeRegionDiskIamUpdaterProducer, compute.ComputeRegionDiskIdParseFunc), + "google_compute_region_disk_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeRegionDiskIamSchema, compute.ComputeRegionDiskIamUpdaterProducer, compute.ComputeRegionDiskIdParseFunc), + "google_compute_region_disk_resource_policy_attachment": compute.ResourceComputeRegionDiskResourcePolicyAttachment(), + "google_compute_region_health_check": compute.ResourceComputeRegionHealthCheck(), + "google_compute_region_network_endpoint": compute.ResourceComputeRegionNetworkEndpoint(), + "google_compute_region_network_endpoint_group": compute.ResourceComputeRegionNetworkEndpointGroup(), + "google_compute_region_network_firewall_policy": compute.ResourceComputeRegionNetworkFirewallPolicy(), + "google_compute_region_per_instance_config": compute.ResourceComputeRegionPerInstanceConfig(), + "google_compute_region_ssl_certificate": compute.ResourceComputeRegionSslCertificate(), + "google_compute_region_ssl_policy": compute.ResourceComputeRegionSslPolicy(), + "google_compute_region_target_http_proxy": compute.ResourceComputeRegionTargetHttpProxy(), + "google_compute_region_target_https_proxy": compute.ResourceComputeRegionTargetHttpsProxy(), + "google_compute_region_target_tcp_proxy": compute.ResourceComputeRegionTargetTcpProxy(), + "google_compute_region_url_map": compute.ResourceComputeRegionUrlMap(), + "google_compute_reservation": compute.ResourceComputeReservation(), + "google_compute_resource_policy": compute.ResourceComputeResourcePolicy(), + "google_compute_route": compute.ResourceComputeRoute(), + "google_compute_router": compute.ResourceComputeRouter(), + "google_compute_router_nat": compute.ResourceComputeRouterNat(), + "google_compute_service_attachment": compute.ResourceComputeServiceAttachment(), + "google_compute_snapshot": compute.ResourceComputeSnapshot(), + "google_compute_snapshot_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeSnapshotIamSchema, compute.ComputeSnapshotIamUpdaterProducer, compute.ComputeSnapshotIdParseFunc), + "google_compute_snapshot_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeSnapshotIamSchema, compute.ComputeSnapshotIamUpdaterProducer, compute.ComputeSnapshotIdParseFunc), + "google_compute_snapshot_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeSnapshotIamSchema, compute.ComputeSnapshotIamUpdaterProducer, compute.ComputeSnapshotIdParseFunc), + "google_compute_ssl_certificate": compute.ResourceComputeSslCertificate(), + "google_compute_ssl_policy": compute.ResourceComputeSslPolicy(), + "google_compute_subnetwork": compute.ResourceComputeSubnetwork(), + "google_compute_subnetwork_iam_binding": tpgiamresource.ResourceIamBinding(compute.ComputeSubnetworkIamSchema, compute.ComputeSubnetworkIamUpdaterProducer, compute.ComputeSubnetworkIdParseFunc), + "google_compute_subnetwork_iam_member": tpgiamresource.ResourceIamMember(compute.ComputeSubnetworkIamSchema, compute.ComputeSubnetworkIamUpdaterProducer, compute.ComputeSubnetworkIdParseFunc), + "google_compute_subnetwork_iam_policy": tpgiamresource.ResourceIamPolicy(compute.ComputeSubnetworkIamSchema, compute.ComputeSubnetworkIamUpdaterProducer, compute.ComputeSubnetworkIdParseFunc), + "google_compute_target_grpc_proxy": compute.ResourceComputeTargetGrpcProxy(), + "google_compute_target_http_proxy": compute.ResourceComputeTargetHttpProxy(), + "google_compute_target_https_proxy": compute.ResourceComputeTargetHttpsProxy(), + "google_compute_target_instance": compute.ResourceComputeTargetInstance(), + "google_compute_target_ssl_proxy": compute.ResourceComputeTargetSslProxy(), + "google_compute_target_tcp_proxy": compute.ResourceComputeTargetTcpProxy(), + "google_compute_url_map": compute.ResourceComputeUrlMap(), + "google_compute_vpn_gateway": compute.ResourceComputeVpnGateway(), + "google_compute_vpn_tunnel": compute.ResourceComputeVpnTunnel(), + "google_container_analysis_note": containeranalysis.ResourceContainerAnalysisNote(), + "google_container_analysis_note_iam_binding": tpgiamresource.ResourceIamBinding(containeranalysis.ContainerAnalysisNoteIamSchema, containeranalysis.ContainerAnalysisNoteIamUpdaterProducer, containeranalysis.ContainerAnalysisNoteIdParseFunc), + "google_container_analysis_note_iam_member": tpgiamresource.ResourceIamMember(containeranalysis.ContainerAnalysisNoteIamSchema, containeranalysis.ContainerAnalysisNoteIamUpdaterProducer, containeranalysis.ContainerAnalysisNoteIdParseFunc), + "google_container_analysis_note_iam_policy": tpgiamresource.ResourceIamPolicy(containeranalysis.ContainerAnalysisNoteIamSchema, containeranalysis.ContainerAnalysisNoteIamUpdaterProducer, containeranalysis.ContainerAnalysisNoteIdParseFunc), + "google_container_analysis_occurrence": containeranalysis.ResourceContainerAnalysisOccurrence(), + "google_container_attached_cluster": containerattached.ResourceContainerAttachedCluster(), + "google_billing_project_info": corebilling.ResourceCoreBillingProjectInfo(), + "google_database_migration_service_connection_profile": databasemigrationservice.ResourceDatabaseMigrationServiceConnectionProfile(), + "google_database_migration_service_private_connection": databasemigrationservice.ResourceDatabaseMigrationServicePrivateConnection(), + "google_data_catalog_entry": datacatalog.ResourceDataCatalogEntry(), + "google_data_catalog_entry_group": datacatalog.ResourceDataCatalogEntryGroup(), + "google_data_catalog_entry_group_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogEntryGroupIamSchema, datacatalog.DataCatalogEntryGroupIamUpdaterProducer, datacatalog.DataCatalogEntryGroupIdParseFunc), + "google_data_catalog_entry_group_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogEntryGroupIamSchema, datacatalog.DataCatalogEntryGroupIamUpdaterProducer, datacatalog.DataCatalogEntryGroupIdParseFunc), + "google_data_catalog_entry_group_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogEntryGroupIamSchema, datacatalog.DataCatalogEntryGroupIamUpdaterProducer, datacatalog.DataCatalogEntryGroupIdParseFunc), + "google_data_catalog_policy_tag": datacatalog.ResourceDataCatalogPolicyTag(), + "google_data_catalog_policy_tag_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogPolicyTagIamSchema, datacatalog.DataCatalogPolicyTagIamUpdaterProducer, datacatalog.DataCatalogPolicyTagIdParseFunc), + "google_data_catalog_policy_tag_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogPolicyTagIamSchema, datacatalog.DataCatalogPolicyTagIamUpdaterProducer, datacatalog.DataCatalogPolicyTagIdParseFunc), + "google_data_catalog_policy_tag_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogPolicyTagIamSchema, datacatalog.DataCatalogPolicyTagIamUpdaterProducer, datacatalog.DataCatalogPolicyTagIdParseFunc), + "google_data_catalog_tag": datacatalog.ResourceDataCatalogTag(), + "google_data_catalog_tag_template": datacatalog.ResourceDataCatalogTagTemplate(), + "google_data_catalog_tag_template_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer, datacatalog.DataCatalogTagTemplateIdParseFunc), + "google_data_catalog_tag_template_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer, datacatalog.DataCatalogTagTemplateIdParseFunc), + "google_data_catalog_tag_template_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogTagTemplateIamSchema, datacatalog.DataCatalogTagTemplateIamUpdaterProducer, datacatalog.DataCatalogTagTemplateIdParseFunc), + "google_data_catalog_taxonomy": datacatalog.ResourceDataCatalogTaxonomy(), + "google_data_catalog_taxonomy_iam_binding": tpgiamresource.ResourceIamBinding(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), + "google_data_catalog_taxonomy_iam_member": tpgiamresource.ResourceIamMember(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), + "google_data_catalog_taxonomy_iam_policy": tpgiamresource.ResourceIamPolicy(datacatalog.DataCatalogTaxonomyIamSchema, datacatalog.DataCatalogTaxonomyIamUpdaterProducer, datacatalog.DataCatalogTaxonomyIdParseFunc), + "google_data_fusion_instance": datafusion.ResourceDataFusionInstance(), + "google_data_fusion_instance_iam_binding": tpgiamresource.ResourceIamBinding(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), + "google_data_fusion_instance_iam_member": tpgiamresource.ResourceIamMember(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), + "google_data_fusion_instance_iam_policy": tpgiamresource.ResourceIamPolicy(datafusion.DataFusionInstanceIamSchema, datafusion.DataFusionInstanceIamUpdaterProducer, datafusion.DataFusionInstanceIdParseFunc), + "google_data_loss_prevention_deidentify_template": datalossprevention.ResourceDataLossPreventionDeidentifyTemplate(), + "google_data_loss_prevention_inspect_template": datalossprevention.ResourceDataLossPreventionInspectTemplate(), + "google_data_loss_prevention_job_trigger": datalossprevention.ResourceDataLossPreventionJobTrigger(), + "google_data_loss_prevention_stored_info_type": datalossprevention.ResourceDataLossPreventionStoredInfoType(), + "google_data_pipeline_pipeline": datapipeline.ResourceDataPipelinePipeline(), + "google_dataplex_asset_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer, dataplex.DataplexAssetIdParseFunc), + "google_dataplex_asset_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer, dataplex.DataplexAssetIdParseFunc), + "google_dataplex_asset_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexAssetIamSchema, dataplex.DataplexAssetIamUpdaterProducer, dataplex.DataplexAssetIdParseFunc), + "google_dataplex_datascan": dataplex.ResourceDataplexDatascan(), + "google_dataplex_datascan_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer, dataplex.DataplexDatascanIdParseFunc), + "google_dataplex_datascan_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer, dataplex.DataplexDatascanIdParseFunc), + "google_dataplex_datascan_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexDatascanIamSchema, dataplex.DataplexDatascanIamUpdaterProducer, dataplex.DataplexDatascanIdParseFunc), + "google_dataplex_lake_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer, dataplex.DataplexLakeIdParseFunc), + "google_dataplex_lake_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer, dataplex.DataplexLakeIdParseFunc), + "google_dataplex_lake_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexLakeIamSchema, dataplex.DataplexLakeIamUpdaterProducer, dataplex.DataplexLakeIdParseFunc), + "google_dataplex_task": dataplex.ResourceDataplexTask(), + "google_dataplex_task_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer, dataplex.DataplexTaskIdParseFunc), + "google_dataplex_task_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer, dataplex.DataplexTaskIdParseFunc), + "google_dataplex_task_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexTaskIamSchema, dataplex.DataplexTaskIamUpdaterProducer, dataplex.DataplexTaskIdParseFunc), + "google_dataplex_zone_iam_binding": tpgiamresource.ResourceIamBinding(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer, dataplex.DataplexZoneIdParseFunc), + "google_dataplex_zone_iam_member": tpgiamresource.ResourceIamMember(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer, dataplex.DataplexZoneIdParseFunc), + "google_dataplex_zone_iam_policy": tpgiamresource.ResourceIamPolicy(dataplex.DataplexZoneIamSchema, dataplex.DataplexZoneIamUpdaterProducer, dataplex.DataplexZoneIdParseFunc), + "google_dataproc_autoscaling_policy": dataproc.ResourceDataprocAutoscalingPolicy(), + "google_dataproc_autoscaling_policy_iam_binding": tpgiamresource.ResourceIamBinding(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer, dataproc.DataprocAutoscalingPolicyIdParseFunc), + "google_dataproc_autoscaling_policy_iam_member": tpgiamresource.ResourceIamMember(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer, dataproc.DataprocAutoscalingPolicyIdParseFunc), + "google_dataproc_autoscaling_policy_iam_policy": tpgiamresource.ResourceIamPolicy(dataproc.DataprocAutoscalingPolicyIamSchema, dataproc.DataprocAutoscalingPolicyIamUpdaterProducer, dataproc.DataprocAutoscalingPolicyIdParseFunc), + "google_dataproc_metastore_service": dataprocmetastore.ResourceDataprocMetastoreService(), + "google_dataproc_metastore_service_iam_binding": tpgiamresource.ResourceIamBinding(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), + "google_dataproc_metastore_service_iam_member": tpgiamresource.ResourceIamMember(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), + "google_dataproc_metastore_service_iam_policy": tpgiamresource.ResourceIamPolicy(dataprocmetastore.DataprocMetastoreServiceIamSchema, dataprocmetastore.DataprocMetastoreServiceIamUpdaterProducer, dataprocmetastore.DataprocMetastoreServiceIdParseFunc), + "google_datastore_index": datastore.ResourceDatastoreIndex(), + "google_datastream_connection_profile": datastream.ResourceDatastreamConnectionProfile(), + "google_datastream_private_connection": datastream.ResourceDatastreamPrivateConnection(), + "google_datastream_stream": datastream.ResourceDatastreamStream(), + "google_deployment_manager_deployment": deploymentmanager.ResourceDeploymentManagerDeployment(), + "google_dialogflow_agent": dialogflow.ResourceDialogflowAgent(), + "google_dialogflow_entity_type": dialogflow.ResourceDialogflowEntityType(), + "google_dialogflow_fulfillment": dialogflow.ResourceDialogflowFulfillment(), + "google_dialogflow_intent": dialogflow.ResourceDialogflowIntent(), + "google_dialogflow_cx_agent": dialogflowcx.ResourceDialogflowCXAgent(), + "google_dialogflow_cx_entity_type": dialogflowcx.ResourceDialogflowCXEntityType(), + "google_dialogflow_cx_environment": dialogflowcx.ResourceDialogflowCXEnvironment(), + "google_dialogflow_cx_flow": dialogflowcx.ResourceDialogflowCXFlow(), + "google_dialogflow_cx_intent": dialogflowcx.ResourceDialogflowCXIntent(), + "google_dialogflow_cx_page": dialogflowcx.ResourceDialogflowCXPage(), + "google_dialogflow_cx_security_settings": dialogflowcx.ResourceDialogflowCXSecuritySettings(), + "google_dialogflow_cx_test_case": dialogflowcx.ResourceDialogflowCXTestCase(), + "google_dialogflow_cx_version": dialogflowcx.ResourceDialogflowCXVersion(), + "google_dialogflow_cx_webhook": dialogflowcx.ResourceDialogflowCXWebhook(), + "google_discovery_engine_chat_engine": discoveryengine.ResourceDiscoveryEngineChatEngine(), + "google_discovery_engine_data_store": discoveryengine.ResourceDiscoveryEngineDataStore(), + "google_discovery_engine_search_engine": discoveryengine.ResourceDiscoveryEngineSearchEngine(), + "google_dns_managed_zone": dns.ResourceDNSManagedZone(), + "google_dns_managed_zone_iam_binding": tpgiamresource.ResourceIamBinding(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer, dns.DNSManagedZoneIdParseFunc), + "google_dns_managed_zone_iam_member": tpgiamresource.ResourceIamMember(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer, dns.DNSManagedZoneIdParseFunc), + "google_dns_managed_zone_iam_policy": tpgiamresource.ResourceIamPolicy(dns.DNSManagedZoneIamSchema, dns.DNSManagedZoneIamUpdaterProducer, dns.DNSManagedZoneIdParseFunc), + "google_dns_policy": dns.ResourceDNSPolicy(), + "google_dns_response_policy": dns.ResourceDNSResponsePolicy(), + "google_dns_response_policy_rule": dns.ResourceDNSResponsePolicyRule(), + "google_document_ai_processor": documentai.ResourceDocumentAIProcessor(), + "google_document_ai_processor_default_version": documentai.ResourceDocumentAIProcessorDefaultVersion(), + "google_document_ai_warehouse_document_schema": documentaiwarehouse.ResourceDocumentAIWarehouseDocumentSchema(), + "google_document_ai_warehouse_location": documentaiwarehouse.ResourceDocumentAIWarehouseLocation(), + "google_edgecontainer_cluster": edgecontainer.ResourceEdgecontainerCluster(), + "google_edgecontainer_node_pool": edgecontainer.ResourceEdgecontainerNodePool(), + "google_edgecontainer_vpn_connection": edgecontainer.ResourceEdgecontainerVpnConnection(), + "google_edgenetwork_network": edgenetwork.ResourceEdgenetworkNetwork(), + "google_edgenetwork_subnet": edgenetwork.ResourceEdgenetworkSubnet(), + "google_essential_contacts_contact": essentialcontacts.ResourceEssentialContactsContact(), + "google_filestore_backup": filestore.ResourceFilestoreBackup(), + "google_filestore_instance": filestore.ResourceFilestoreInstance(), + "google_filestore_snapshot": filestore.ResourceFilestoreSnapshot(), + "google_firebase_app_check_app_attest_config": firebaseappcheck.ResourceFirebaseAppCheckAppAttestConfig(), + "google_firebase_app_check_debug_token": firebaseappcheck.ResourceFirebaseAppCheckDebugToken(), + "google_firebase_app_check_device_check_config": firebaseappcheck.ResourceFirebaseAppCheckDeviceCheckConfig(), + "google_firebase_app_check_play_integrity_config": firebaseappcheck.ResourceFirebaseAppCheckPlayIntegrityConfig(), + "google_firebase_app_check_recaptcha_enterprise_config": firebaseappcheck.ResourceFirebaseAppCheckRecaptchaEnterpriseConfig(), + "google_firebase_app_check_recaptcha_v3_config": firebaseappcheck.ResourceFirebaseAppCheckRecaptchaV3Config(), + "google_firebase_app_check_service_config": firebaseappcheck.ResourceFirebaseAppCheckServiceConfig(), + "google_firestore_backup_schedule": firestore.ResourceFirestoreBackupSchedule(), + "google_firestore_database": firestore.ResourceFirestoreDatabase(), + "google_firestore_document": firestore.ResourceFirestoreDocument(), + "google_firestore_field": firestore.ResourceFirestoreField(), + "google_firestore_index": firestore.ResourceFirestoreIndex(), + "google_gke_backup_backup_plan": gkebackup.ResourceGKEBackupBackupPlan(), + "google_gke_backup_backup_plan_iam_binding": tpgiamresource.ResourceIamBinding(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc), + "google_gke_backup_backup_plan_iam_member": tpgiamresource.ResourceIamMember(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc), + "google_gke_backup_backup_plan_iam_policy": tpgiamresource.ResourceIamPolicy(gkebackup.GKEBackupBackupPlanIamSchema, gkebackup.GKEBackupBackupPlanIamUpdaterProducer, gkebackup.GKEBackupBackupPlanIdParseFunc), + "google_gke_backup_restore_plan": gkebackup.ResourceGKEBackupRestorePlan(), + "google_gke_backup_restore_plan_iam_binding": tpgiamresource.ResourceIamBinding(gkebackup.GKEBackupRestorePlanIamSchema, gkebackup.GKEBackupRestorePlanIamUpdaterProducer, gkebackup.GKEBackupRestorePlanIdParseFunc), + "google_gke_backup_restore_plan_iam_member": tpgiamresource.ResourceIamMember(gkebackup.GKEBackupRestorePlanIamSchema, gkebackup.GKEBackupRestorePlanIamUpdaterProducer, gkebackup.GKEBackupRestorePlanIdParseFunc), + "google_gke_backup_restore_plan_iam_policy": tpgiamresource.ResourceIamPolicy(gkebackup.GKEBackupRestorePlanIamSchema, gkebackup.GKEBackupRestorePlanIamUpdaterProducer, gkebackup.GKEBackupRestorePlanIdParseFunc), + "google_gke_hub_membership": gkehub.ResourceGKEHubMembership(), + "google_gke_hub_membership_iam_binding": tpgiamresource.ResourceIamBinding(gkehub.GKEHubMembershipIamSchema, gkehub.GKEHubMembershipIamUpdaterProducer, gkehub.GKEHubMembershipIdParseFunc), + "google_gke_hub_membership_iam_member": tpgiamresource.ResourceIamMember(gkehub.GKEHubMembershipIamSchema, gkehub.GKEHubMembershipIamUpdaterProducer, gkehub.GKEHubMembershipIdParseFunc), + "google_gke_hub_membership_iam_policy": tpgiamresource.ResourceIamPolicy(gkehub.GKEHubMembershipIamSchema, gkehub.GKEHubMembershipIamUpdaterProducer, gkehub.GKEHubMembershipIdParseFunc), + "google_gke_hub_feature": gkehub2.ResourceGKEHub2Feature(), + "google_gke_hub_feature_iam_binding": tpgiamresource.ResourceIamBinding(gkehub2.GKEHub2FeatureIamSchema, gkehub2.GKEHub2FeatureIamUpdaterProducer, gkehub2.GKEHub2FeatureIdParseFunc), + "google_gke_hub_feature_iam_member": tpgiamresource.ResourceIamMember(gkehub2.GKEHub2FeatureIamSchema, gkehub2.GKEHub2FeatureIamUpdaterProducer, gkehub2.GKEHub2FeatureIdParseFunc), + "google_gke_hub_feature_iam_policy": tpgiamresource.ResourceIamPolicy(gkehub2.GKEHub2FeatureIamSchema, gkehub2.GKEHub2FeatureIamUpdaterProducer, gkehub2.GKEHub2FeatureIdParseFunc), + "google_gke_hub_fleet": gkehub2.ResourceGKEHub2Fleet(), + "google_gke_hub_membership_binding": gkehub2.ResourceGKEHub2MembershipBinding(), + "google_gke_hub_namespace": gkehub2.ResourceGKEHub2Namespace(), + "google_gke_hub_scope": gkehub2.ResourceGKEHub2Scope(), + "google_gke_hub_scope_iam_binding": tpgiamresource.ResourceIamBinding(gkehub2.GKEHub2ScopeIamSchema, gkehub2.GKEHub2ScopeIamUpdaterProducer, gkehub2.GKEHub2ScopeIdParseFunc), + "google_gke_hub_scope_iam_member": tpgiamresource.ResourceIamMember(gkehub2.GKEHub2ScopeIamSchema, gkehub2.GKEHub2ScopeIamUpdaterProducer, gkehub2.GKEHub2ScopeIdParseFunc), + "google_gke_hub_scope_iam_policy": tpgiamresource.ResourceIamPolicy(gkehub2.GKEHub2ScopeIamSchema, gkehub2.GKEHub2ScopeIamUpdaterProducer, gkehub2.GKEHub2ScopeIdParseFunc), + "google_gke_hub_scope_rbac_role_binding": gkehub2.ResourceGKEHub2ScopeRBACRoleBinding(), + "google_gkeonprem_bare_metal_admin_cluster": gkeonprem.ResourceGkeonpremBareMetalAdminCluster(), + "google_gkeonprem_bare_metal_cluster": gkeonprem.ResourceGkeonpremBareMetalCluster(), + "google_gkeonprem_bare_metal_node_pool": gkeonprem.ResourceGkeonpremBareMetalNodePool(), + "google_gkeonprem_vmware_cluster": gkeonprem.ResourceGkeonpremVmwareCluster(), + "google_gkeonprem_vmware_node_pool": gkeonprem.ResourceGkeonpremVmwareNodePool(), + "google_healthcare_consent_store": healthcare.ResourceHealthcareConsentStore(), + "google_healthcare_consent_store_iam_binding": tpgiamresource.ResourceIamBinding(healthcare.HealthcareConsentStoreIamSchema, healthcare.HealthcareConsentStoreIamUpdaterProducer, healthcare.HealthcareConsentStoreIdParseFunc), + "google_healthcare_consent_store_iam_member": tpgiamresource.ResourceIamMember(healthcare.HealthcareConsentStoreIamSchema, healthcare.HealthcareConsentStoreIamUpdaterProducer, healthcare.HealthcareConsentStoreIdParseFunc), + "google_healthcare_consent_store_iam_policy": tpgiamresource.ResourceIamPolicy(healthcare.HealthcareConsentStoreIamSchema, healthcare.HealthcareConsentStoreIamUpdaterProducer, healthcare.HealthcareConsentStoreIdParseFunc), + "google_healthcare_dataset": healthcare.ResourceHealthcareDataset(), + "google_healthcare_dicom_store": healthcare.ResourceHealthcareDicomStore(), + "google_healthcare_fhir_store": healthcare.ResourceHealthcareFhirStore(), + "google_healthcare_hl7_v2_store": healthcare.ResourceHealthcareHl7V2Store(), + "google_iam_access_boundary_policy": iam2.ResourceIAM2AccessBoundaryPolicy(), + "google_iam_deny_policy": iam2.ResourceIAM2DenyPolicy(), + "google_iam_workload_identity_pool": iambeta.ResourceIAMBetaWorkloadIdentityPool(), + "google_iam_workload_identity_pool_provider": iambeta.ResourceIAMBetaWorkloadIdentityPoolProvider(), + "google_iam_workforce_pool": iamworkforcepool.ResourceIAMWorkforcePoolWorkforcePool(), + "google_iam_workforce_pool_provider": iamworkforcepool.ResourceIAMWorkforcePoolWorkforcePoolProvider(), + "google_iap_app_engine_service_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapAppEngineServiceIamSchema, iap.IapAppEngineServiceIamUpdaterProducer, iap.IapAppEngineServiceIdParseFunc), + "google_iap_app_engine_service_iam_member": tpgiamresource.ResourceIamMember(iap.IapAppEngineServiceIamSchema, iap.IapAppEngineServiceIamUpdaterProducer, iap.IapAppEngineServiceIdParseFunc), + "google_iap_app_engine_service_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapAppEngineServiceIamSchema, iap.IapAppEngineServiceIamUpdaterProducer, iap.IapAppEngineServiceIdParseFunc), + "google_iap_app_engine_version_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapAppEngineVersionIamSchema, iap.IapAppEngineVersionIamUpdaterProducer, iap.IapAppEngineVersionIdParseFunc), + "google_iap_app_engine_version_iam_member": tpgiamresource.ResourceIamMember(iap.IapAppEngineVersionIamSchema, iap.IapAppEngineVersionIamUpdaterProducer, iap.IapAppEngineVersionIdParseFunc), + "google_iap_app_engine_version_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapAppEngineVersionIamSchema, iap.IapAppEngineVersionIamUpdaterProducer, iap.IapAppEngineVersionIdParseFunc), + "google_iap_brand": iap.ResourceIapBrand(), + "google_iap_client": iap.ResourceIapClient(), + "google_iap_tunnel_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapTunnelIamSchema, iap.IapTunnelIamUpdaterProducer, iap.IapTunnelIdParseFunc), + "google_iap_tunnel_iam_member": tpgiamresource.ResourceIamMember(iap.IapTunnelIamSchema, iap.IapTunnelIamUpdaterProducer, iap.IapTunnelIdParseFunc), + "google_iap_tunnel_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapTunnelIamSchema, iap.IapTunnelIamUpdaterProducer, iap.IapTunnelIdParseFunc), + "google_iap_tunnel_dest_group": iap.ResourceIapTunnelDestGroup(), + "google_iap_tunnel_dest_group_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapTunnelDestGroupIamSchema, iap.IapTunnelDestGroupIamUpdaterProducer, iap.IapTunnelDestGroupIdParseFunc), + "google_iap_tunnel_dest_group_iam_member": tpgiamresource.ResourceIamMember(iap.IapTunnelDestGroupIamSchema, iap.IapTunnelDestGroupIamUpdaterProducer, iap.IapTunnelDestGroupIdParseFunc), + "google_iap_tunnel_dest_group_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapTunnelDestGroupIamSchema, iap.IapTunnelDestGroupIamUpdaterProducer, iap.IapTunnelDestGroupIdParseFunc), + "google_iap_tunnel_instance_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapTunnelInstanceIamSchema, iap.IapTunnelInstanceIamUpdaterProducer, iap.IapTunnelInstanceIdParseFunc), + "google_iap_tunnel_instance_iam_member": tpgiamresource.ResourceIamMember(iap.IapTunnelInstanceIamSchema, iap.IapTunnelInstanceIamUpdaterProducer, iap.IapTunnelInstanceIdParseFunc), + "google_iap_tunnel_instance_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapTunnelInstanceIamSchema, iap.IapTunnelInstanceIamUpdaterProducer, iap.IapTunnelInstanceIdParseFunc), + "google_iap_web_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebIamSchema, iap.IapWebIamUpdaterProducer, iap.IapWebIdParseFunc), + "google_iap_web_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebIamSchema, iap.IapWebIamUpdaterProducer, iap.IapWebIdParseFunc), + "google_iap_web_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebIamSchema, iap.IapWebIamUpdaterProducer, iap.IapWebIdParseFunc), + "google_iap_web_backend_service_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebBackendServiceIamSchema, iap.IapWebBackendServiceIamUpdaterProducer, iap.IapWebBackendServiceIdParseFunc), + "google_iap_web_backend_service_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebBackendServiceIamSchema, iap.IapWebBackendServiceIamUpdaterProducer, iap.IapWebBackendServiceIdParseFunc), + "google_iap_web_backend_service_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebBackendServiceIamSchema, iap.IapWebBackendServiceIamUpdaterProducer, iap.IapWebBackendServiceIdParseFunc), + "google_iap_web_region_backend_service_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer, iap.IapWebRegionBackendServiceIdParseFunc), + "google_iap_web_region_backend_service_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer, iap.IapWebRegionBackendServiceIdParseFunc), + "google_iap_web_region_backend_service_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebRegionBackendServiceIamSchema, iap.IapWebRegionBackendServiceIamUpdaterProducer, iap.IapWebRegionBackendServiceIdParseFunc), + "google_iap_web_type_app_engine_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer, iap.IapWebTypeAppEngineIdParseFunc), + "google_iap_web_type_app_engine_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer, iap.IapWebTypeAppEngineIdParseFunc), + "google_iap_web_type_app_engine_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebTypeAppEngineIamSchema, iap.IapWebTypeAppEngineIamUpdaterProducer, iap.IapWebTypeAppEngineIdParseFunc), + "google_iap_web_type_compute_iam_binding": tpgiamresource.ResourceIamBinding(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer, iap.IapWebTypeComputeIdParseFunc), + "google_iap_web_type_compute_iam_member": tpgiamresource.ResourceIamMember(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer, iap.IapWebTypeComputeIdParseFunc), + "google_iap_web_type_compute_iam_policy": tpgiamresource.ResourceIamPolicy(iap.IapWebTypeComputeIamSchema, iap.IapWebTypeComputeIamUpdaterProducer, iap.IapWebTypeComputeIdParseFunc), + "google_identity_platform_config": identityplatform.ResourceIdentityPlatformConfig(), + "google_identity_platform_default_supported_idp_config": identityplatform.ResourceIdentityPlatformDefaultSupportedIdpConfig(), + "google_identity_platform_inbound_saml_config": identityplatform.ResourceIdentityPlatformInboundSamlConfig(), + "google_identity_platform_oauth_idp_config": identityplatform.ResourceIdentityPlatformOauthIdpConfig(), + "google_identity_platform_project_default_config": identityplatform.ResourceIdentityPlatformProjectDefaultConfig(), + "google_identity_platform_tenant": identityplatform.ResourceIdentityPlatformTenant(), + "google_identity_platform_tenant_default_supported_idp_config": identityplatform.ResourceIdentityPlatformTenantDefaultSupportedIdpConfig(), + "google_identity_platform_tenant_inbound_saml_config": identityplatform.ResourceIdentityPlatformTenantInboundSamlConfig(), + "google_identity_platform_tenant_oauth_idp_config": identityplatform.ResourceIdentityPlatformTenantOauthIdpConfig(), + "google_integration_connectors_connection": integrationconnectors.ResourceIntegrationConnectorsConnection(), + "google_integration_connectors_endpoint_attachment": integrationconnectors.ResourceIntegrationConnectorsEndpointAttachment(), + "google_kms_crypto_key": kms.ResourceKMSCryptoKey(), + "google_kms_crypto_key_version": kms.ResourceKMSCryptoKeyVersion(), + "google_kms_ekm_connection": kms.ResourceKMSEkmConnection(), + "google_kms_key_ring": kms.ResourceKMSKeyRing(), + "google_kms_key_ring_import_job": kms.ResourceKMSKeyRingImportJob(), + "google_kms_secret_ciphertext": kms.ResourceKMSSecretCiphertext(), + "google_logging_folder_settings": logging.ResourceLoggingFolderSettings(), + "google_logging_linked_dataset": logging.ResourceLoggingLinkedDataset(), + "google_logging_log_view": logging.ResourceLoggingLogView(), + "google_logging_metric": logging.ResourceLoggingMetric(), + "google_logging_organization_settings": logging.ResourceLoggingOrganizationSettings(), + "google_looker_instance": looker.ResourceLookerInstance(), + "google_memcache_instance": memcache.ResourceMemcacheInstance(), + "google_migration_center_group": migrationcenter.ResourceMigrationCenterGroup(), + "google_migration_center_preference_set": migrationcenter.ResourceMigrationCenterPreferenceSet(), + "google_ml_engine_model": mlengine.ResourceMLEngineModel(), + "google_monitoring_alert_policy": monitoring.ResourceMonitoringAlertPolicy(), + "google_monitoring_service": monitoring.ResourceMonitoringGenericService(), + "google_monitoring_group": monitoring.ResourceMonitoringGroup(), + "google_monitoring_metric_descriptor": monitoring.ResourceMonitoringMetricDescriptor(), + "google_monitoring_monitored_project": monitoring.ResourceMonitoringMonitoredProject(), + "google_monitoring_notification_channel": monitoring.ResourceMonitoringNotificationChannel(), + "google_monitoring_custom_service": monitoring.ResourceMonitoringService(), + "google_monitoring_slo": monitoring.ResourceMonitoringSlo(), + "google_monitoring_uptime_check_config": monitoring.ResourceMonitoringUptimeCheckConfig(), + "google_netapp_volume": netapp.ResourceNetappVolume(), + "google_netapp_volume_replication": netapp.ResourceNetappVolumeReplication(), + "google_netapp_volume_snapshot": netapp.ResourceNetappVolumeSnapshot(), + "google_netapp_active_directory": netapp.ResourceNetappactiveDirectory(), + "google_netapp_backup_policy": netapp.ResourceNetappbackupPolicy(), + "google_netapp_backup_vault": netapp.ResourceNetappbackupVault(), + "google_netapp_kmsconfig": netapp.ResourceNetappkmsconfig(), + "google_netapp_storage_pool": netapp.ResourceNetappstoragePool(), + "google_network_connectivity_policy_based_route": networkconnectivity.ResourceNetworkConnectivityPolicyBasedRoute(), + "google_network_connectivity_service_connection_policy": networkconnectivity.ResourceNetworkConnectivityServiceConnectionPolicy(), + "google_network_management_connectivity_test": networkmanagement.ResourceNetworkManagementConnectivityTest(), + "google_network_security_address_group": networksecurity.ResourceNetworkSecurityAddressGroup(), + "google_network_security_gateway_security_policy": networksecurity.ResourceNetworkSecurityGatewaySecurityPolicy(), + "google_network_security_gateway_security_policy_rule": networksecurity.ResourceNetworkSecurityGatewaySecurityPolicyRule(), + "google_network_security_address_group_iam_binding": tpgiamresource.ResourceIamBinding(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), + "google_network_security_address_group_iam_member": tpgiamresource.ResourceIamMember(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), + "google_network_security_address_group_iam_policy": tpgiamresource.ResourceIamPolicy(networksecurity.NetworkSecurityProjectAddressGroupIamSchema, networksecurity.NetworkSecurityProjectAddressGroupIamUpdaterProducer, networksecurity.NetworkSecurityProjectAddressGroupIdParseFunc), + "google_network_security_url_lists": networksecurity.ResourceNetworkSecurityUrlLists(), + "google_network_services_edge_cache_keyset": networkservices.ResourceNetworkServicesEdgeCacheKeyset(), + "google_network_services_edge_cache_origin": networkservices.ResourceNetworkServicesEdgeCacheOrigin(), + "google_network_services_edge_cache_service": networkservices.ResourceNetworkServicesEdgeCacheService(), + "google_network_services_gateway": networkservices.ResourceNetworkServicesGateway(), + "google_notebooks_environment": notebooks.ResourceNotebooksEnvironment(), + "google_notebooks_instance": notebooks.ResourceNotebooksInstance(), + "google_notebooks_instance_iam_binding": tpgiamresource.ResourceIamBinding(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer, notebooks.NotebooksInstanceIdParseFunc), + "google_notebooks_instance_iam_member": tpgiamresource.ResourceIamMember(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer, notebooks.NotebooksInstanceIdParseFunc), + "google_notebooks_instance_iam_policy": tpgiamresource.ResourceIamPolicy(notebooks.NotebooksInstanceIamSchema, notebooks.NotebooksInstanceIamUpdaterProducer, notebooks.NotebooksInstanceIdParseFunc), + "google_notebooks_location": notebooks.ResourceNotebooksLocation(), + "google_notebooks_runtime": notebooks.ResourceNotebooksRuntime(), + "google_notebooks_runtime_iam_binding": tpgiamresource.ResourceIamBinding(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer, notebooks.NotebooksRuntimeIdParseFunc), + "google_notebooks_runtime_iam_member": tpgiamresource.ResourceIamMember(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer, notebooks.NotebooksRuntimeIdParseFunc), + "google_notebooks_runtime_iam_policy": tpgiamresource.ResourceIamPolicy(notebooks.NotebooksRuntimeIamSchema, notebooks.NotebooksRuntimeIamUpdaterProducer, notebooks.NotebooksRuntimeIdParseFunc), + "google_org_policy_custom_constraint": orgpolicy.ResourceOrgPolicyCustomConstraint(), + "google_os_config_patch_deployment": osconfig.ResourceOSConfigPatchDeployment(), + "google_os_login_ssh_public_key": oslogin.ResourceOSLoginSSHPublicKey(), + "google_privateca_ca_pool": privateca.ResourcePrivatecaCaPool(), + "google_privateca_ca_pool_iam_binding": tpgiamresource.ResourceIamBinding(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), + "google_privateca_ca_pool_iam_member": tpgiamresource.ResourceIamMember(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), + "google_privateca_ca_pool_iam_policy": tpgiamresource.ResourceIamPolicy(privateca.PrivatecaCaPoolIamSchema, privateca.PrivatecaCaPoolIamUpdaterProducer, privateca.PrivatecaCaPoolIdParseFunc), + "google_privateca_certificate": privateca.ResourcePrivatecaCertificate(), + "google_privateca_certificate_authority": privateca.ResourcePrivatecaCertificateAuthority(), + "google_privateca_certificate_template_iam_binding": tpgiamresource.ResourceIamBinding(privateca.PrivatecaCertificateTemplateIamSchema, privateca.PrivatecaCertificateTemplateIamUpdaterProducer, privateca.PrivatecaCertificateTemplateIdParseFunc), + "google_privateca_certificate_template_iam_member": tpgiamresource.ResourceIamMember(privateca.PrivatecaCertificateTemplateIamSchema, privateca.PrivatecaCertificateTemplateIamUpdaterProducer, privateca.PrivatecaCertificateTemplateIdParseFunc), + "google_privateca_certificate_template_iam_policy": tpgiamresource.ResourceIamPolicy(privateca.PrivatecaCertificateTemplateIamSchema, privateca.PrivatecaCertificateTemplateIamUpdaterProducer, privateca.PrivatecaCertificateTemplateIdParseFunc), + "google_public_ca_external_account_key": publicca.ResourcePublicCAExternalAccountKey(), + "google_pubsub_schema": pubsub.ResourcePubsubSchema(), + "google_pubsub_schema_iam_binding": tpgiamresource.ResourceIamBinding(pubsub.PubsubSchemaIamSchema, pubsub.PubsubSchemaIamUpdaterProducer, pubsub.PubsubSchemaIdParseFunc), + "google_pubsub_schema_iam_member": tpgiamresource.ResourceIamMember(pubsub.PubsubSchemaIamSchema, pubsub.PubsubSchemaIamUpdaterProducer, pubsub.PubsubSchemaIdParseFunc), + "google_pubsub_schema_iam_policy": tpgiamresource.ResourceIamPolicy(pubsub.PubsubSchemaIamSchema, pubsub.PubsubSchemaIamUpdaterProducer, pubsub.PubsubSchemaIdParseFunc), + "google_pubsub_subscription": pubsub.ResourcePubsubSubscription(), + "google_pubsub_topic": pubsub.ResourcePubsubTopic(), + "google_pubsub_topic_iam_binding": tpgiamresource.ResourceIamBinding(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer, pubsub.PubsubTopicIdParseFunc), + "google_pubsub_topic_iam_member": tpgiamresource.ResourceIamMember(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer, pubsub.PubsubTopicIdParseFunc), + "google_pubsub_topic_iam_policy": tpgiamresource.ResourceIamPolicy(pubsub.PubsubTopicIamSchema, pubsub.PubsubTopicIamUpdaterProducer, pubsub.PubsubTopicIdParseFunc), + "google_pubsub_lite_reservation": pubsublite.ResourcePubsubLiteReservation(), + "google_pubsub_lite_subscription": pubsublite.ResourcePubsubLiteSubscription(), + "google_pubsub_lite_topic": pubsublite.ResourcePubsubLiteTopic(), + "google_redis_cluster": redis.ResourceRedisCluster(), + "google_redis_instance": redis.ResourceRedisInstance(), + "google_resource_manager_lien": resourcemanager.ResourceResourceManagerLien(), + "google_secret_manager_secret": secretmanager.ResourceSecretManagerSecret(), + "google_secret_manager_secret_iam_binding": tpgiamresource.ResourceIamBinding(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer, secretmanager.SecretManagerSecretIdParseFunc), + "google_secret_manager_secret_iam_member": tpgiamresource.ResourceIamMember(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer, secretmanager.SecretManagerSecretIdParseFunc), + "google_secret_manager_secret_iam_policy": tpgiamresource.ResourceIamPolicy(secretmanager.SecretManagerSecretIamSchema, secretmanager.SecretManagerSecretIamUpdaterProducer, secretmanager.SecretManagerSecretIdParseFunc), + "google_secret_manager_secret_version": secretmanager.ResourceSecretManagerSecretVersion(), + "google_secure_source_manager_instance": securesourcemanager.ResourceSecureSourceManagerInstance(), + "google_secure_source_manager_instance_iam_binding": tpgiamresource.ResourceIamBinding(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer, securesourcemanager.SecureSourceManagerInstanceIdParseFunc), + "google_secure_source_manager_instance_iam_member": tpgiamresource.ResourceIamMember(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer, securesourcemanager.SecureSourceManagerInstanceIdParseFunc), + "google_secure_source_manager_instance_iam_policy": tpgiamresource.ResourceIamPolicy(securesourcemanager.SecureSourceManagerInstanceIamSchema, securesourcemanager.SecureSourceManagerInstanceIamUpdaterProducer, securesourcemanager.SecureSourceManagerInstanceIdParseFunc), + "google_scc_event_threat_detection_custom_module": securitycenter.ResourceSecurityCenterEventThreatDetectionCustomModule(), + "google_scc_folder_custom_module": securitycenter.ResourceSecurityCenterFolderCustomModule(), + "google_scc_mute_config": securitycenter.ResourceSecurityCenterMuteConfig(), + "google_scc_notification_config": securitycenter.ResourceSecurityCenterNotificationConfig(), + "google_scc_organization_custom_module": securitycenter.ResourceSecurityCenterOrganizationCustomModule(), + "google_scc_project_custom_module": securitycenter.ResourceSecurityCenterProjectCustomModule(), + "google_scc_source": securitycenter.ResourceSecurityCenterSource(), + "google_scc_source_iam_binding": tpgiamresource.ResourceIamBinding(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc), + "google_scc_source_iam_member": tpgiamresource.ResourceIamMember(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc), + "google_scc_source_iam_policy": tpgiamresource.ResourceIamPolicy(securitycenter.SecurityCenterSourceIamSchema, securitycenter.SecurityCenterSourceIamUpdaterProducer, securitycenter.SecurityCenterSourceIdParseFunc), + "google_securityposture_posture": securityposture.ResourceSecurityposturePosture(), + "google_securityposture_posture_deployment": securityposture.ResourceSecurityposturePostureDeployment(), + "google_endpoints_service_iam_binding": tpgiamresource.ResourceIamBinding(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer, servicemanagement.ServiceManagementServiceIdParseFunc), + "google_endpoints_service_iam_member": tpgiamresource.ResourceIamMember(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer, servicemanagement.ServiceManagementServiceIdParseFunc), + "google_endpoints_service_iam_policy": tpgiamresource.ResourceIamPolicy(servicemanagement.ServiceManagementServiceIamSchema, servicemanagement.ServiceManagementServiceIamUpdaterProducer, servicemanagement.ServiceManagementServiceIdParseFunc), + "google_endpoints_service_consumers_iam_binding": tpgiamresource.ResourceIamBinding(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer, servicemanagement.ServiceManagementServiceConsumersIdParseFunc), + "google_endpoints_service_consumers_iam_member": tpgiamresource.ResourceIamMember(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer, servicemanagement.ServiceManagementServiceConsumersIdParseFunc), + "google_endpoints_service_consumers_iam_policy": tpgiamresource.ResourceIamPolicy(servicemanagement.ServiceManagementServiceConsumersIamSchema, servicemanagement.ServiceManagementServiceConsumersIamUpdaterProducer, servicemanagement.ServiceManagementServiceConsumersIdParseFunc), + "google_sourcerepo_repository": sourcerepo.ResourceSourceRepoRepository(), + "google_sourcerepo_repository_iam_binding": tpgiamresource.ResourceIamBinding(sourcerepo.SourceRepoRepositoryIamSchema, sourcerepo.SourceRepoRepositoryIamUpdaterProducer, sourcerepo.SourceRepoRepositoryIdParseFunc), + "google_sourcerepo_repository_iam_member": tpgiamresource.ResourceIamMember(sourcerepo.SourceRepoRepositoryIamSchema, sourcerepo.SourceRepoRepositoryIamUpdaterProducer, sourcerepo.SourceRepoRepositoryIdParseFunc), + "google_sourcerepo_repository_iam_policy": tpgiamresource.ResourceIamPolicy(sourcerepo.SourceRepoRepositoryIamSchema, sourcerepo.SourceRepoRepositoryIamUpdaterProducer, sourcerepo.SourceRepoRepositoryIdParseFunc), + "google_spanner_database": spanner.ResourceSpannerDatabase(), + "google_spanner_instance": spanner.ResourceSpannerInstance(), + "google_sql_database": sql.ResourceSQLDatabase(), + "google_sql_source_representation_instance": sql.ResourceSQLSourceRepresentationInstance(), + "google_storage_bucket_iam_binding": tpgiamresource.ResourceIamBinding(storage.StorageBucketIamSchema, storage.StorageBucketIamUpdaterProducer, storage.StorageBucketIdParseFunc), + "google_storage_bucket_iam_member": tpgiamresource.ResourceIamMember(storage.StorageBucketIamSchema, storage.StorageBucketIamUpdaterProducer, storage.StorageBucketIdParseFunc), + "google_storage_bucket_iam_policy": tpgiamresource.ResourceIamPolicy(storage.StorageBucketIamSchema, storage.StorageBucketIamUpdaterProducer, storage.StorageBucketIdParseFunc), + "google_storage_bucket_access_control": storage.ResourceStorageBucketAccessControl(), + "google_storage_default_object_access_control": storage.ResourceStorageDefaultObjectAccessControl(), + "google_storage_hmac_key": storage.ResourceStorageHmacKey(), + "google_storage_object_access_control": storage.ResourceStorageObjectAccessControl(), + "google_storage_insights_report_config": storageinsights.ResourceStorageInsightsReportConfig(), + "google_storage_transfer_agent_pool": storagetransfer.ResourceStorageTransferAgentPool(), + "google_tags_tag_binding": tags.ResourceTagsTagBinding(), + "google_tags_tag_key": tags.ResourceTagsTagKey(), + "google_tags_tag_key_iam_binding": tpgiamresource.ResourceIamBinding(tags.TagsTagKeyIamSchema, tags.TagsTagKeyIamUpdaterProducer, tags.TagsTagKeyIdParseFunc), + "google_tags_tag_key_iam_member": tpgiamresource.ResourceIamMember(tags.TagsTagKeyIamSchema, tags.TagsTagKeyIamUpdaterProducer, tags.TagsTagKeyIdParseFunc), + "google_tags_tag_key_iam_policy": tpgiamresource.ResourceIamPolicy(tags.TagsTagKeyIamSchema, tags.TagsTagKeyIamUpdaterProducer, tags.TagsTagKeyIdParseFunc), + "google_tags_tag_value": tags.ResourceTagsTagValue(), + "google_tags_tag_value_iam_binding": tpgiamresource.ResourceIamBinding(tags.TagsTagValueIamSchema, tags.TagsTagValueIamUpdaterProducer, tags.TagsTagValueIdParseFunc), + "google_tags_tag_value_iam_member": tpgiamresource.ResourceIamMember(tags.TagsTagValueIamSchema, tags.TagsTagValueIamUpdaterProducer, tags.TagsTagValueIdParseFunc), + "google_tags_tag_value_iam_policy": tpgiamresource.ResourceIamPolicy(tags.TagsTagValueIamSchema, tags.TagsTagValueIamUpdaterProducer, tags.TagsTagValueIdParseFunc), + "google_tpu_node": tpu.ResourceTPUNode(), + "google_vertex_ai_dataset": vertexai.ResourceVertexAIDataset(), + "google_vertex_ai_endpoint": vertexai.ResourceVertexAIEndpoint(), + "google_vertex_ai_feature_group": vertexai.ResourceVertexAIFeatureGroup(), + "google_vertex_ai_feature_group_feature": vertexai.ResourceVertexAIFeatureGroupFeature(), + "google_vertex_ai_feature_online_store": vertexai.ResourceVertexAIFeatureOnlineStore(), + "google_vertex_ai_feature_online_store_featureview": vertexai.ResourceVertexAIFeatureOnlineStoreFeatureview(), + "google_vertex_ai_featurestore": vertexai.ResourceVertexAIFeaturestore(), + "google_vertex_ai_featurestore_entitytype": vertexai.ResourceVertexAIFeaturestoreEntitytype(), + "google_vertex_ai_featurestore_entitytype_feature": vertexai.ResourceVertexAIFeaturestoreEntitytypeFeature(), + "google_vertex_ai_index": vertexai.ResourceVertexAIIndex(), + "google_vertex_ai_index_endpoint": vertexai.ResourceVertexAIIndexEndpoint(), + "google_vertex_ai_tensorboard": vertexai.ResourceVertexAITensorboard(), + "google_vmwareengine_cluster": vmwareengine.ResourceVmwareengineCluster(), + "google_vmwareengine_external_access_rule": vmwareengine.ResourceVmwareengineExternalAccessRule(), + "google_vmwareengine_external_address": vmwareengine.ResourceVmwareengineExternalAddress(), + "google_vmwareengine_network": vmwareengine.ResourceVmwareengineNetwork(), + "google_vmwareengine_network_peering": vmwareengine.ResourceVmwareengineNetworkPeering(), + "google_vmwareengine_network_policy": vmwareengine.ResourceVmwareengineNetworkPolicy(), + "google_vmwareengine_private_cloud": vmwareengine.ResourceVmwareenginePrivateCloud(), + "google_vmwareengine_subnet": vmwareengine.ResourceVmwareengineSubnet(), + "google_vpc_access_connector": vpcaccess.ResourceVPCAccessConnector(), + "google_workbench_instance": workbench.ResourceWorkbenchInstance(), + "google_workbench_instance_iam_binding": tpgiamresource.ResourceIamBinding(workbench.WorkbenchInstanceIamSchema, workbench.WorkbenchInstanceIamUpdaterProducer, workbench.WorkbenchInstanceIdParseFunc), + "google_workbench_instance_iam_member": tpgiamresource.ResourceIamMember(workbench.WorkbenchInstanceIamSchema, workbench.WorkbenchInstanceIamUpdaterProducer, workbench.WorkbenchInstanceIdParseFunc), + "google_workbench_instance_iam_policy": tpgiamresource.ResourceIamPolicy(workbench.WorkbenchInstanceIamSchema, workbench.WorkbenchInstanceIamUpdaterProducer, workbench.WorkbenchInstanceIdParseFunc), + "google_workflows_workflow": workflows.ResourceWorkflowsWorkflow(), } var handwrittenResources = map[string]*schema.Resource{ @@ -1100,7 +1023,6 @@ var handwrittenResources = map[string]*schema.Resource{ "google_bigtable_gc_policy": bigtable.ResourceBigtableGCPolicy(), "google_bigtable_instance": bigtable.ResourceBigtableInstance(), "google_bigtable_table": bigtable.ResourceBigtableTable(), - "google_bigtable_authorized_view": bigtable.ResourceBigtableAuthorizedView(), "google_billing_subaccount": resourcemanager.ResourceBillingSubaccount(), "google_cloudfunctions_function": cloudfunctions.ResourceCloudFunctionsFunction(), "google_composer_environment": composer.ResourceComposerEnvironment(), @@ -1157,7 +1079,6 @@ var handwrittenResources = map[string]*schema.Resource{ "google_project_default_service_accounts": resourcemanager.ResourceGoogleProjectDefaultServiceAccounts(), "google_project_service": resourcemanager.ResourceGoogleProjectService(), "google_project_iam_custom_role": resourcemanager.ResourceGoogleProjectIamCustomRole(), - "google_project_iam_member_remove": resourcemanager.ResourceGoogleProjectIamMemberRemove(), "google_project_organization_policy": resourcemanager.ResourceGoogleProjectOrganizationPolicy(), "google_project_usage_export_bucket": compute.ResourceProjectUsageBucket(), "google_service_account": resourcemanager.ResourceGoogleServiceAccount(), @@ -1222,9 +1143,6 @@ var handwrittenIAMResources = map[string]*schema.Resource{ "google_spanner_database_iam_binding": tpgiamresource.ResourceIamBinding(spanner.IamSpannerDatabaseSchema, spanner.NewSpannerDatabaseIamUpdater, spanner.SpannerDatabaseIdParseFunc), "google_spanner_database_iam_member": tpgiamresource.ResourceIamMember(spanner.IamSpannerDatabaseSchema, spanner.NewSpannerDatabaseIamUpdater, spanner.SpannerDatabaseIdParseFunc), "google_spanner_database_iam_policy": tpgiamresource.ResourceIamPolicy(spanner.IamSpannerDatabaseSchema, spanner.NewSpannerDatabaseIamUpdater, spanner.SpannerDatabaseIdParseFunc), - "google_storage_managed_folder_iam_binding": tpgiamresource.ResourceIamBinding(storage.StorageManagedFolderIamSchema, storage.StorageManagedFolderIamUpdaterProducer, storage.StorageManagedFolderIdParseFunc), - "google_storage_managed_folder_iam_member": tpgiamresource.ResourceIamMember(storage.StorageManagedFolderIamSchema, storage.StorageManagedFolderIamUpdaterProducer, storage.StorageManagedFolderIdParseFunc), - "google_storage_managed_folder_iam_policy": tpgiamresource.ResourceIamPolicy(storage.StorageManagedFolderIamSchema, storage.StorageManagedFolderIamUpdaterProducer, storage.StorageManagedFolderIdParseFunc), "google_organization_iam_binding": tpgiamresource.ResourceIamBinding(resourcemanager.IamOrganizationSchema, resourcemanager.NewOrganizationIamUpdater, resourcemanager.OrgIdParseFunc), "google_organization_iam_member": tpgiamresource.ResourceIamMember(resourcemanager.IamOrganizationSchema, resourcemanager.NewOrganizationIamUpdater, resourcemanager.OrgIdParseFunc), "google_organization_iam_policy": tpgiamresource.ResourceIamPolicy(resourcemanager.IamOrganizationSchema, resourcemanager.NewOrganizationIamUpdater, resourcemanager.OrgIdParseFunc), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_folder_access_approval_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_folder_access_approval_settings.go index 948a3630dfa..7428da365f9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_folder_access_approval_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_folder_access_approval_settings.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -222,7 +221,6 @@ func resourceAccessApprovalFolderSettingsCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_emails") { @@ -250,7 +248,6 @@ func resourceAccessApprovalFolderSettingsCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FolderSettings: %s", err) @@ -290,14 +287,12 @@ func resourceAccessApprovalFolderSettingsRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessApprovalFolderSettings %q", d.Id())) @@ -363,7 +358,6 @@ func resourceAccessApprovalFolderSettingsUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating FolderSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_emails") { @@ -399,7 +393,6 @@ func resourceAccessApprovalFolderSettingsUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_organization_access_approval_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_organization_access_approval_settings.go index d08bd510131..b35739e7e02 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_organization_access_approval_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_organization_access_approval_settings.go @@ -20,7 +20,6 @@ package accessapproval import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -182,7 +181,6 @@ func resourceAccessApprovalOrganizationSettingsCreate(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_emails") { @@ -210,7 +208,6 @@ func resourceAccessApprovalOrganizationSettingsCreate(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating OrganizationSettings: %s", err) @@ -250,14 +247,12 @@ func resourceAccessApprovalOrganizationSettingsRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessApprovalOrganizationSettings %q", d.Id())) @@ -323,7 +318,6 @@ func resourceAccessApprovalOrganizationSettingsUpdate(d *schema.ResourceData, me } log.Printf("[DEBUG] Updating OrganizationSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_emails") { @@ -359,7 +353,6 @@ func resourceAccessApprovalOrganizationSettingsUpdate(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_project_access_approval_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_project_access_approval_settings.go index bd38ff81f38..06e86af8c38 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_project_access_approval_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accessapproval/resource_project_access_approval_settings.go @@ -20,7 +20,6 @@ package accessapproval import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -196,7 +195,6 @@ func resourceAccessApprovalProjectSettingsCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_emails") { @@ -228,7 +226,6 @@ func resourceAccessApprovalProjectSettingsCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ProjectSettings: %s", err) @@ -268,14 +265,12 @@ func resourceAccessApprovalProjectSettingsRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessApprovalProjectSettings %q", d.Id())) @@ -350,7 +345,6 @@ func resourceAccessApprovalProjectSettingsUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating ProjectSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_emails") { @@ -390,7 +384,6 @@ func resourceAccessApprovalProjectSettingsUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level.go index 5a8f4efa7f2..614a5384b0f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -388,7 +387,6 @@ func resourceAccessContextManagerAccessLevelCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -397,7 +395,6 @@ func resourceAccessContextManagerAccessLevelCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AccessLevel: %s", err) @@ -458,14 +455,12 @@ func resourceAccessContextManagerAccessLevelRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerAccessLevel %q", d.Id())) @@ -536,7 +531,6 @@ func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating AccessLevel %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("title") { @@ -576,7 +570,6 @@ func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -618,8 +611,6 @@ func resourceAccessContextManagerAccessLevelDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AccessLevel %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -629,7 +620,6 @@ func resourceAccessContextManagerAccessLevelDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AccessLevel") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go index 165cf3eda91..08b435b22dc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_level_condition.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -317,7 +316,6 @@ func resourceAccessContextManagerAccessLevelConditionCreate(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -326,7 +324,6 @@ func resourceAccessContextManagerAccessLevelConditionCreate(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AccessLevelCondition: %s", err) @@ -413,14 +410,12 @@ func resourceAccessContextManagerAccessLevelConditionRead(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerAccessLevelCondition %q", d.Id())) @@ -500,8 +495,6 @@ func resourceAccessContextManagerAccessLevelConditionDelete(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AccessLevelCondition %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -511,7 +504,6 @@ func resourceAccessContextManagerAccessLevelConditionDelete(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AccessLevelCondition") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go index a64caf19e78..7713bcc780f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_levels.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -359,7 +358,6 @@ func resourceAccessContextManagerAccessLevelsCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -368,7 +366,6 @@ func resourceAccessContextManagerAccessLevelsCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AccessLevels: %s", err) @@ -415,14 +412,12 @@ func resourceAccessContextManagerAccessLevelsRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerAccessLevels %q", d.Id())) @@ -458,7 +453,6 @@ func resourceAccessContextManagerAccessLevelsUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating AccessLevels %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -473,7 +467,6 @@ func resourceAccessContextManagerAccessLevelsUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go index 3616d09afe4..429f1dc2dce 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_access_policy.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -131,7 +130,6 @@ func resourceAccessContextManagerAccessPolicyCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -140,7 +138,6 @@ func resourceAccessContextManagerAccessPolicyCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AccessPolicy: %s", err) @@ -213,14 +210,12 @@ func resourceAccessContextManagerAccessPolicyRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerAccessPolicy %q", d.Id())) @@ -277,7 +272,6 @@ func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating AccessPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("title") { @@ -309,7 +303,6 @@ func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -351,8 +344,6 @@ func resourceAccessContextManagerAccessPolicyDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AccessPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -362,7 +353,6 @@ func resourceAccessContextManagerAccessPolicyDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AccessPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go index 3a7d400cd3e..f876506090d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_authorized_orgs_desc.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -193,7 +192,6 @@ func resourceAccessContextManagerAuthorizedOrgsDescCreate(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -202,7 +200,6 @@ func resourceAccessContextManagerAuthorizedOrgsDescCreate(d *schema.ResourceData UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AuthorizedOrgsDesc: %s", err) @@ -268,14 +265,12 @@ func resourceAccessContextManagerAuthorizedOrgsDescRead(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerAuthorizedOrgsDesc %q", d.Id())) @@ -334,7 +329,6 @@ func resourceAccessContextManagerAuthorizedOrgsDescUpdate(d *schema.ResourceData } log.Printf("[DEBUG] Updating AuthorizedOrgsDesc %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("orgs") { @@ -360,7 +354,6 @@ func resourceAccessContextManagerAuthorizedOrgsDescUpdate(d *schema.ResourceData UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -401,8 +394,6 @@ func resourceAccessContextManagerAuthorizedOrgsDescDelete(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AuthorizedOrgsDesc %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -412,7 +403,6 @@ func resourceAccessContextManagerAuthorizedOrgsDescDelete(d *schema.ResourceData UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AuthorizedOrgsDesc") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go index 8b93574a1d4..3e78209fd1c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_egress_policy.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -101,7 +100,6 @@ func resourceAccessContextManagerEgressPolicyCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -110,7 +108,6 @@ func resourceAccessContextManagerEgressPolicyCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EgressPolicy: %s", err) @@ -181,14 +178,12 @@ func resourceAccessContextManagerEgressPolicyRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerEgressPolicy %q", d.Id())) @@ -243,8 +238,6 @@ func resourceAccessContextManagerEgressPolicyDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EgressPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -254,7 +247,6 @@ func resourceAccessContextManagerEgressPolicyDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EgressPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go index e3b99cb1bdb..c33b75fb7a1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_gcp_user_access_binding.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -115,7 +114,6 @@ func resourceAccessContextManagerGcpUserAccessBindingCreate(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -124,7 +122,6 @@ func resourceAccessContextManagerGcpUserAccessBindingCreate(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GcpUserAccessBinding: %s", err) @@ -185,14 +182,12 @@ func resourceAccessContextManagerGcpUserAccessBindingRead(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerGcpUserAccessBinding %q", d.Id())) @@ -234,7 +229,6 @@ func resourceAccessContextManagerGcpUserAccessBindingUpdate(d *schema.ResourceDa } log.Printf("[DEBUG] Updating GcpUserAccessBinding %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("access_levels") { @@ -262,7 +256,6 @@ func resourceAccessContextManagerGcpUserAccessBindingUpdate(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -304,8 +297,6 @@ func resourceAccessContextManagerGcpUserAccessBindingDelete(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GcpUserAccessBinding %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -315,7 +306,6 @@ func resourceAccessContextManagerGcpUserAccessBindingDelete(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GcpUserAccessBinding") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go index d1fe8057c73..181050f79ec 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_ingress_policy.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -101,7 +100,6 @@ func resourceAccessContextManagerIngressPolicyCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -110,7 +108,6 @@ func resourceAccessContextManagerIngressPolicyCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating IngressPolicy: %s", err) @@ -181,14 +178,12 @@ func resourceAccessContextManagerIngressPolicyRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerIngressPolicy %q", d.Id())) @@ -243,8 +238,6 @@ func resourceAccessContextManagerIngressPolicyDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting IngressPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -254,7 +247,6 @@ func resourceAccessContextManagerIngressPolicyDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "IngressPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go index 9096e98427c..d67f3dbc7f8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -147,9 +146,10 @@ a perimeter bridge.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this 'EgressPolicy'. -Should be in the format of email address. The email address should -represent individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'EgressPolicy'. +To specify an identity or identity group, use the IAM v1 +format specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -286,9 +286,10 @@ to apply.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this ingress policy. -Should be in the format of email address. The email address should represent -individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'IngressPolicy'. +To specify an identity or identity group, use the IAM v1 +format specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -511,9 +512,10 @@ a perimeter bridge.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this 'EgressPolicy'. -Should be in the format of email address. The email address should -represent individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'EgressPolicy'. +To specify an identity or identity group, use the IAM v1 +format specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -650,9 +652,10 @@ to apply.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this ingress policy. -Should be in the format of email address. The email address should represent -individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'IngressPolicy'. +To specify an identity or identity group, use the IAM v1 +format specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -938,7 +941,6 @@ func resourceAccessContextManagerServicePerimeterCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -947,7 +949,6 @@ func resourceAccessContextManagerServicePerimeterCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServicePerimeter: %s", err) @@ -1008,14 +1009,12 @@ func resourceAccessContextManagerServicePerimeterRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerServicePerimeter %q", d.Id())) @@ -1111,7 +1110,6 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating ServicePerimeter %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("title") { @@ -1155,7 +1153,6 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1204,8 +1201,6 @@ func resourceAccessContextManagerServicePerimeterDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServicePerimeter %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1215,7 +1210,6 @@ func resourceAccessContextManagerServicePerimeterDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServicePerimeter") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go deleted file mode 100644 index 1e7e3d4d2a4..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_dry_run_resource.go +++ /dev/null @@ -1,480 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package accesscontextmanager - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceAccessContextManagerServicePerimeterDryRunResource() *schema.Resource { - return &schema.Resource{ - Create: resourceAccessContextManagerServicePerimeterDryRunResourceCreate, - Read: resourceAccessContextManagerServicePerimeterDryRunResourceRead, - Delete: resourceAccessContextManagerServicePerimeterDryRunResourceDelete, - - Importer: &schema.ResourceImporter{ - State: resourceAccessContextManagerServicePerimeterDryRunResourceImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "perimeter_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The name of the Service Perimeter to add this resource to.`, - }, - "resource": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `A GCP resource that is inside of the service perimeter. -Currently only projects are allowed. -Format: projects/{project_number}`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceAccessContextManagerServicePerimeterDryRunResourceCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - resourceProp, err := expandNestedAccessContextManagerServicePerimeterDryRunResourceResource(d.Get("resource"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("resource"); !tpgresource.IsEmptyValue(reflect.ValueOf(resourceProp)) && (ok || !reflect.DeepEqual(v, resourceProp)) { - obj["resource"] = resourceProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "{{perimeter_name}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{AccessContextManagerBasePath}}{{perimeter_name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new ServicePerimeterDryRunResource: %#v", obj) - - obj, err = resourceAccessContextManagerServicePerimeterDryRunResourcePatchCreateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": "spec.resources"}) - if err != nil { - return err - } - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - obj["use_explicit_dry_run_spec"] = true - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ServicePerimeterDryRunResource: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{perimeter_name}}/{{resource}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // Use the resource in the operation response to populate - // identity fields and d.Id() before read - var opRes map[string]interface{} - err = AccessContextManagerOperationWaitTimeWithResponse( - config, res, &opRes, "Creating ServicePerimeterDryRunResource", userAgent, - d.Timeout(schema.TimeoutCreate)) - if err != nil { - // The resource didn't actually create - d.SetId("") - - return fmt.Errorf("Error waiting to create ServicePerimeterDryRunResource: %s", err) - } - - if _, ok := opRes["spec"]; ok { - opRes, err = flattenNestedAccessContextManagerServicePerimeterDryRunResource(d, meta, opRes) - if err != nil { - return fmt.Errorf("Error getting nested object from operation response: %s", err) - } - if opRes == nil { - // Object isn't there any more - remove it from the state. - return fmt.Errorf("Error decoding response from operation, could not find nested object") - } - } - if err := d.Set("resource", flattenNestedAccessContextManagerServicePerimeterDryRunResourceResource(opRes["resource"], d, config)); err != nil { - return err - } - - // This may have caused the ID to update - update it if so. - id, err = tpgresource.ReplaceVars(d, config, "{{perimeter_name}}/{{resource}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating ServicePerimeterDryRunResource %q: %#v", d.Id(), res) - - return resourceAccessContextManagerServicePerimeterDryRunResourceRead(d, meta) -} - -func resourceAccessContextManagerServicePerimeterDryRunResourceRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{AccessContextManagerBasePath}}{{perimeter_name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerServicePerimeterDryRunResource %q", d.Id())) - } - - res, err = flattenNestedAccessContextManagerServicePerimeterDryRunResource(d, meta, res) - if err != nil { - return err - } - - if res == nil { - // Object isn't there any more - remove it from the state. - log.Printf("[DEBUG] Removing AccessContextManagerServicePerimeterDryRunResource because it couldn't be matched.") - d.SetId("") - return nil - } - - if err := d.Set("resource", flattenNestedAccessContextManagerServicePerimeterDryRunResourceResource(res["resource"], d, config)); err != nil { - return fmt.Errorf("Error reading ServicePerimeterDryRunResource: %s", err) - } - - return nil -} - -func resourceAccessContextManagerServicePerimeterDryRunResourceDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - lockName, err := tpgresource.ReplaceVars(d, config, "{{perimeter_name}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{AccessContextManagerBasePath}}{{perimeter_name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - obj, err = resourceAccessContextManagerServicePerimeterDryRunResourcePatchDeleteEncoder(d, meta, obj) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ServicePerimeterDryRunResource") - } - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": "spec.resources"}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - obj["use_explicit_dry_run_spec"] = true - - log.Printf("[DEBUG] Deleting ServicePerimeterDryRunResource %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ServicePerimeterDryRunResource") - } - - err = AccessContextManagerOperationWaitTime( - config, res, "Deleting ServicePerimeterDryRunResource", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting ServicePerimeterDryRunResource %q: %#v", d.Id(), res) - return nil -} - -func resourceAccessContextManagerServicePerimeterDryRunResourceImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - - // current import_formats can't import fields with forward slashes in their value - parts, err := tpgresource.GetImportIdQualifiers([]string{"accessPolicies/(?P[^/]+)/servicePerimeters/(?P[^/]+)/(?P.+)"}, d, config, d.Id()) - if err != nil { - return nil, err - } - - if err := d.Set("perimeter_name", fmt.Sprintf("accessPolicies/%s/servicePerimeters/%s", parts["accessPolicy"], parts["perimeter"])); err != nil { - return nil, fmt.Errorf("Error setting perimeter_name: %s", err) - } - if err := d.Set("resource", parts["resource"]); err != nil { - return nil, fmt.Errorf("Error setting resource: %s", err) - } - return []*schema.ResourceData{d}, nil -} - -func flattenNestedAccessContextManagerServicePerimeterDryRunResourceResource(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNestedAccessContextManagerServicePerimeterDryRunResourceResource(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func flattenNestedAccessContextManagerServicePerimeterDryRunResource(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - var v interface{} - var ok bool - - v, ok = res["spec"] - if !ok || v == nil { - return nil, nil - } - res = v.(map[string]interface{}) - - v, ok = res["resources"] - if !ok || v == nil { - return nil, nil - } - - switch v.(type) { - case []interface{}: - break - case map[string]interface{}: - // Construct list out of single nested resource - v = []interface{}{v} - default: - return nil, fmt.Errorf("expected list or map for value spec.resources. Actual value: %v", v) - } - - _, item, err := resourceAccessContextManagerServicePerimeterDryRunResourceFindNestedObjectInList(d, meta, v.([]interface{})) - if err != nil { - return nil, err - } - return item, nil -} - -func resourceAccessContextManagerServicePerimeterDryRunResourceFindNestedObjectInList(d *schema.ResourceData, meta interface{}, items []interface{}) (index int, item map[string]interface{}, err error) { - expectedResource, err := expandNestedAccessContextManagerServicePerimeterDryRunResourceResource(d.Get("resource"), d, meta.(*transport_tpg.Config)) - if err != nil { - return -1, nil, err - } - expectedFlattenedResource := flattenNestedAccessContextManagerServicePerimeterDryRunResourceResource(expectedResource, d, meta.(*transport_tpg.Config)) - - // Search list for this resource. - for idx, itemRaw := range items { - if itemRaw == nil { - continue - } - // List response only contains the ID - construct a response object. - item := map[string]interface{}{ - "resource": itemRaw, - } - - itemResource := flattenNestedAccessContextManagerServicePerimeterDryRunResourceResource(item["resource"], d, meta.(*transport_tpg.Config)) - // IsEmptyValue check so that if one is nil and the other is "", that's considered a match - if !(tpgresource.IsEmptyValue(reflect.ValueOf(itemResource)) && tpgresource.IsEmptyValue(reflect.ValueOf(expectedFlattenedResource))) && !reflect.DeepEqual(itemResource, expectedFlattenedResource) { - log.Printf("[DEBUG] Skipping item with resource= %#v, looking for %#v)", itemResource, expectedFlattenedResource) - continue - } - log.Printf("[DEBUG] Found item for resource %q: %#v)", d.Id(), item) - return idx, item, nil - } - return -1, nil, nil -} - -// PatchCreateEncoder handles creating request data to PATCH parent resource -// with list including new object. -func resourceAccessContextManagerServicePerimeterDryRunResourcePatchCreateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - currItems, err := resourceAccessContextManagerServicePerimeterDryRunResourceListForPatch(d, meta) - if err != nil { - return nil, err - } - - _, found, err := resourceAccessContextManagerServicePerimeterDryRunResourceFindNestedObjectInList(d, meta, currItems) - if err != nil { - return nil, err - } - - // Return error if item already created. - if found != nil { - return nil, fmt.Errorf("Unable to create ServicePerimeterDryRunResource, existing object already found: %+v", found) - } - - // Return list with the resource to create appended - res := map[string]interface{}{ - "resources": append(currItems, obj["resource"]), - } - wrapped := map[string]interface{}{ - "spec": res, - } - res = wrapped - - return res, nil -} - -// PatchDeleteEncoder handles creating request data to PATCH parent resource -// with list excluding object to delete. -func resourceAccessContextManagerServicePerimeterDryRunResourcePatchDeleteEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - currItems, err := resourceAccessContextManagerServicePerimeterDryRunResourceListForPatch(d, meta) - if err != nil { - return nil, err - } - - idx, item, err := resourceAccessContextManagerServicePerimeterDryRunResourceFindNestedObjectInList(d, meta, currItems) - if err != nil { - return nil, err - } - if item == nil { - // Spoof 404 error for proper handling by Delete (i.e. no-op) - return nil, tpgresource.Fake404("nested", "AccessContextManagerServicePerimeterDryRunResource") - } - - updatedItems := append(currItems[:idx], currItems[idx+1:]...) - res := map[string]interface{}{ - "resources": updatedItems, - } - wrapped := map[string]interface{}{ - "spec": res, - } - res = wrapped - - return res, nil -} - -// ListForPatch handles making API request to get parent resource and -// extracting list of objects. -func resourceAccessContextManagerServicePerimeterDryRunResourceListForPatch(d *schema.ResourceData, meta interface{}) ([]interface{}, error) { - config := meta.(*transport_tpg.Config) - url, err := tpgresource.ReplaceVars(d, config, "{{AccessContextManagerBasePath}}{{perimeter_name}}") - if err != nil { - return nil, err - } - - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return nil, err - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return nil, err - } - - var v interface{} - var ok bool - if v, ok = res["spec"]; ok && v != nil { - res = v.(map[string]interface{}) - } else { - return nil, nil - } - - v, ok = res["resources"] - if ok && v != nil { - ls, lsOk := v.([]interface{}) - if !lsOk { - return nil, fmt.Errorf(`expected list for nested field "resources"`) - } - return ls, nil - } - return nil, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go index 7905e82bdbe..ac46e8d84fa 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_egress_policy.go @@ -20,8 +20,8 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -35,6 +35,7 @@ func ResourceAccessContextManagerServicePerimeterEgressPolicy() *schema.Resource return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterEgressPolicyCreate, Read: resourceAccessContextManagerServicePerimeterEgressPolicyRead, + Update: resourceAccessContextManagerServicePerimeterEgressPolicyUpdate, Delete: resourceAccessContextManagerServicePerimeterEgressPolicyDelete, Importer: &schema.ResourceImporter{ @@ -43,6 +44,7 @@ func ResourceAccessContextManagerServicePerimeterEgressPolicy() *schema.Resource Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(20 * time.Minute), + Update: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), }, @@ -57,7 +59,6 @@ func ResourceAccessContextManagerServicePerimeterEgressPolicy() *schema.Resource "egress_from": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `Defines conditions on the source of a request causing this 'EgressPolicy' to apply.`, MaxItems: 1, Elem: &schema.Resource{ @@ -65,10 +66,9 @@ func ResourceAccessContextManagerServicePerimeterEgressPolicy() *schema.Resource "identities": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `A list of identities that are allowed access through this 'EgressPolicy'. -Should be in the format of email address. The email address should -represent individual user or service account only.`, +Should be in the format of an email address. The email address should +represent an individual user, service account, or Google group.`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -76,7 +76,6 @@ represent individual user or service account only.`, "identity_type": { Type: schema.TypeString, Optional: true, - ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT", ""}), Description: `Specifies the type of identities that are allowed access to outside the perimeter. If left unspecified, then members of 'identities' field will @@ -85,21 +84,18 @@ be allowed access. Possible values: ["ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SE "source_restriction": { Type: schema.TypeString, Optional: true, - ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"SOURCE_RESTRICTION_UNSPECIFIED", "SOURCE_RESTRICTION_ENABLED", "SOURCE_RESTRICTION_DISABLED", ""}), Description: `Whether to enforce traffic restrictions based on 'sources' field. If the 'sources' field is non-empty, then this field must be set to 'SOURCE_RESTRICTION_ENABLED'. Possible values: ["SOURCE_RESTRICTION_UNSPECIFIED", "SOURCE_RESTRICTION_ENABLED", "SOURCE_RESTRICTION_DISABLED"]`, }, "sources": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `Sources that this EgressPolicy authorizes access from.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "access_level": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `An AccessLevel resource name that allows resources outside the ServicePerimeter to be accessed from the inside.`, }, }, @@ -111,7 +107,6 @@ be allowed access. Possible values: ["ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SE "egress_to": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `Defines the conditions on the 'ApiOperation' and destination resources that cause this 'EgressPolicy' to apply.`, MaxItems: 1, @@ -120,7 +115,6 @@ cause this 'EgressPolicy' to apply.`, "external_resources": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `A list of external resources that are allowed to be accessed. A request matches if it contains an external resource in this list (Example: s3://bucket/path). Currently '*' is not allowed.`, @@ -131,7 +125,6 @@ s3://bucket/path). Currently '*' is not allowed.`, "operations": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `A list of 'ApiOperations' that this egress rule applies to. A request matches if it contains an operation/service in this list.`, Elem: &schema.Resource{ @@ -139,7 +132,6 @@ if it contains an operation/service in this list.`, "method_selectors": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `API methods or permissions to allow. Method or permission must belong to the service specified by 'serviceName' field. A single MethodSelector entry with '*' specified for the 'method' field will allow all methods @@ -149,7 +141,6 @@ AND permissions for the service specified in 'serviceName'.`, "method": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `Value for 'method' should be a valid method name for the corresponding 'serviceName' in 'ApiOperation'. If '*' used as value for method, then ALL methods and permissions are allowed.`, @@ -157,7 +148,6 @@ then ALL methods and permissions are allowed.`, "permission": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `Value for permission should be a valid Cloud IAM permission for the corresponding 'serviceName' in 'ApiOperation'.`, }, @@ -167,7 +157,6 @@ corresponding 'serviceName' in 'ApiOperation'.`, "service_name": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `The name of the API whose methods or permissions the 'IngressPolicy' or 'EgressPolicy' want to allow. A single 'ApiOperation' with serviceName field set to '*' will allow all methods AND permissions for all services.`, @@ -178,7 +167,6 @@ field set to '*' will allow all methods AND permissions for all services.`, "resources": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `A list of resources, currently only projects in the form 'projects/', that match this to stanza. A request matches if it contains a resource in this list. If * is specified for resources, @@ -246,7 +234,6 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyCreate(d *schema.Re billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -255,7 +242,6 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyCreate(d *schema.Re UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServicePerimeterEgressPolicy: %s", err) @@ -329,14 +315,12 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyRead(d *schema.Reso billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerServicePerimeterEgressPolicy %q", d.Id())) @@ -364,6 +348,98 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyRead(d *schema.Reso return nil } +func resourceAccessContextManagerServicePerimeterEgressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + obj := make(map[string]interface{}) + egressFromProp, err := expandNestedAccessContextManagerServicePerimeterEgressPolicyEgressFrom(d.Get("egress_from"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("egress_from"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, egressFromProp)) { + obj["egressFrom"] = egressFromProp + } + egressToProp, err := expandNestedAccessContextManagerServicePerimeterEgressPolicyEgressTo(d.Get("egress_to"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("egress_to"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, egressToProp)) { + obj["egressTo"] = egressToProp + } + + lockName, err := tpgresource.ReplaceVars(d, config, "{{perimeter}}") + if err != nil { + return err + } + transport_tpg.MutexStore.Lock(lockName) + defer transport_tpg.MutexStore.Unlock(lockName) + + url, err := tpgresource.ReplaceVars(d, config, "{{AccessContextManagerBasePath}}{{perimeter}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating ServicePerimeterEgressPolicy %q: %#v", d.Id(), obj) + updateMask := []string{} + + if d.HasChange("egress_from") { + updateMask = append(updateMask, "egressFrom") + } + + if d.HasChange("egress_to") { + updateMask = append(updateMask, "egressTo") + } + // updateMask is a URL parameter but not present in the schema, so ReplaceVars + // won't set it + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + if err != nil { + return err + } + + obj, err = resourceAccessContextManagerServicePerimeterEgressPolicyPatchUpdateEncoder(d, meta, obj) + if err != nil { + return err + } + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + // if updateMask is empty we are not updating anything so skip the post + if len(updateMask) > 0 { + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "PUT", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutUpdate), + }) + + if err != nil { + return fmt.Errorf("Error updating ServicePerimeterEgressPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ServicePerimeterEgressPolicy %q: %#v", d.Id(), res) + } + + err = AccessContextManagerOperationWaitTime( + config, res, "Updating ServicePerimeterEgressPolicy", userAgent, + d.Timeout(schema.TimeoutUpdate)) + + if err != nil { + return err + } + } + + return resourceAccessContextManagerServicePerimeterEgressPolicyRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterEgressPolicyDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -401,8 +477,6 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyDelete(d *schema.Re billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServicePerimeterEgressPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -412,7 +486,6 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyDelete(d *schema.Re UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServicePerimeterEgressPolicy") @@ -861,6 +934,42 @@ func resourceAccessContextManagerServicePerimeterEgressPolicyPatchCreateEncoder( return res, nil } +// PatchUpdateEncoder handles creating request data to PATCH parent resource +// with list including updated object. +func resourceAccessContextManagerServicePerimeterEgressPolicyPatchUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + items, err := resourceAccessContextManagerServicePerimeterEgressPolicyListForPatch(d, meta) + if err != nil { + return nil, err + } + + idx, item, err := resourceAccessContextManagerServicePerimeterEgressPolicyFindNestedObjectInList(d, meta, items) + if err != nil { + return nil, err + } + + // Return error if item to update does not exist. + if item == nil { + return nil, fmt.Errorf("Unable to update ServicePerimeterEgressPolicy %q - not found in list", d.Id()) + } + + // Merge new object into old. + for k, v := range obj { + item[k] = v + } + items[idx] = item + + // Return list with new item added + res := map[string]interface{}{ + "egressPolicies": items, + } + wrapped := map[string]interface{}{ + "status": res, + } + res = wrapped + + return res, nil +} + // PatchDeleteEncoder handles creating request data to PATCH parent resource // with list excluding object to delete. func resourceAccessContextManagerServicePerimeterEgressPolicyPatchDeleteEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go index c190f5b36b5..c7ee8091a65 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_ingress_policy.go @@ -20,8 +20,8 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -35,6 +35,7 @@ func ResourceAccessContextManagerServicePerimeterIngressPolicy() *schema.Resourc return &schema.Resource{ Create: resourceAccessContextManagerServicePerimeterIngressPolicyCreate, Read: resourceAccessContextManagerServicePerimeterIngressPolicyRead, + Update: resourceAccessContextManagerServicePerimeterIngressPolicyUpdate, Delete: resourceAccessContextManagerServicePerimeterIngressPolicyDelete, Importer: &schema.ResourceImporter{ @@ -43,6 +44,7 @@ func ResourceAccessContextManagerServicePerimeterIngressPolicy() *schema.Resourc Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(20 * time.Minute), + Update: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), }, @@ -57,7 +59,6 @@ func ResourceAccessContextManagerServicePerimeterIngressPolicy() *schema.Resourc "ingress_from": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `Defines the conditions on the source of a request causing this 'IngressPolicy' to apply.`, MaxItems: 1, @@ -66,10 +67,9 @@ to apply.`, "identities": { Type: schema.TypeList, Optional: true, - ForceNew: true, - Description: `A list of identities that are allowed access through this ingress policy. -Should be in the format of email address. The email address should represent -individual user or service account only.`, + Description: `A list of identities that are allowed access through this 'IngressPolicy'. +Should be in the format of an email address. The email address should represent +an individual user, service account, or Google group.`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -77,7 +77,6 @@ individual user or service account only.`, "identity_type": { Type: schema.TypeString, Optional: true, - ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVICE_ACCOUNT", ""}), Description: `Specifies the type of identities that are allowed access from outside the perimeter. If left unspecified, then members of 'identities' field will be @@ -86,14 +85,12 @@ allowed access. Possible values: ["ANY_IDENTITY", "ANY_USER_ACCOUNT", "ANY_SERVI "sources": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `Sources that this 'IngressPolicy' authorizes access from.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "access_level": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `An 'AccessLevel' resource name that allow resources within the 'ServicePerimeters' to be accessed from the internet. 'AccessLevels' listed must be in the same policy as this 'ServicePerimeter'. Referencing a nonexistent @@ -106,7 +103,6 @@ If * is specified, then all IngressSources will be allowed.`, "resource": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `A Google Cloud resource that is allowed to ingress the perimeter. Requests from these resources will be allowed to access perimeter data. Currently only projects are allowed. Format 'projects/{project_number}' @@ -123,7 +119,6 @@ of allowing all Google Cloud resources only is not supported.`, "ingress_to": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `Defines the conditions on the 'ApiOperation' and request destination that cause this 'IngressPolicy' to apply.`, MaxItems: 1, @@ -132,7 +127,6 @@ this 'IngressPolicy' to apply.`, "operations": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `A list of 'ApiOperations' the sources specified in corresponding 'IngressFrom' are allowed to perform in this 'ServicePerimeter'.`, Elem: &schema.Resource{ @@ -140,7 +134,6 @@ are allowed to perform in this 'ServicePerimeter'.`, "method_selectors": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `API methods or permissions to allow. Method or permission must belong to the service specified by serviceName field. A single 'MethodSelector' entry with '*' specified for the method field will allow all methods AND @@ -150,7 +143,6 @@ permissions for the service specified in 'serviceName'.`, "method": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `Value for method should be a valid method name for the corresponding serviceName in 'ApiOperation'. If '*' used as value for 'method', then ALL methods and permissions are allowed.`, @@ -158,7 +150,6 @@ ALL methods and permissions are allowed.`, "permission": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `Value for permission should be a valid Cloud IAM permission for the corresponding 'serviceName' in 'ApiOperation'.`, }, @@ -168,7 +159,6 @@ corresponding 'serviceName' in 'ApiOperation'.`, "service_name": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: `The name of the API whose methods or permissions the 'IngressPolicy' or 'EgressPolicy' want to allow. A single 'ApiOperation' with 'serviceName' field set to '*' will allow all methods AND permissions for all services.`, @@ -179,7 +169,6 @@ field set to '*' will allow all methods AND permissions for all services.`, "resources": { Type: schema.TypeList, Optional: true, - ForceNew: true, Description: `A list of resources, currently only projects in the form 'projects/', protected by this 'ServicePerimeter' that are allowed to be accessed by sources defined in the @@ -250,7 +239,6 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyCreate(d *schema.R billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -259,7 +247,6 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyCreate(d *schema.R UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServicePerimeterIngressPolicy: %s", err) @@ -333,14 +320,12 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyRead(d *schema.Res billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerServicePerimeterIngressPolicy %q", d.Id())) @@ -368,6 +353,98 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyRead(d *schema.Res return nil } +func resourceAccessContextManagerServicePerimeterIngressPolicyUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err + } + + billingProject := "" + + obj := make(map[string]interface{}) + ingressFromProp, err := expandNestedAccessContextManagerServicePerimeterIngressPolicyIngressFrom(d.Get("ingress_from"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ingress_from"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, ingressFromProp)) { + obj["ingressFrom"] = ingressFromProp + } + ingressToProp, err := expandNestedAccessContextManagerServicePerimeterIngressPolicyIngressTo(d.Get("ingress_to"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ingress_to"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, ingressToProp)) { + obj["ingressTo"] = ingressToProp + } + + lockName, err := tpgresource.ReplaceVars(d, config, "{{perimeter}}") + if err != nil { + return err + } + transport_tpg.MutexStore.Lock(lockName) + defer transport_tpg.MutexStore.Unlock(lockName) + + url, err := tpgresource.ReplaceVars(d, config, "{{AccessContextManagerBasePath}}{{perimeter}}") + if err != nil { + return err + } + + log.Printf("[DEBUG] Updating ServicePerimeterIngressPolicy %q: %#v", d.Id(), obj) + updateMask := []string{} + + if d.HasChange("ingress_from") { + updateMask = append(updateMask, "ingressFrom") + } + + if d.HasChange("ingress_to") { + updateMask = append(updateMask, "ingressTo") + } + // updateMask is a URL parameter but not present in the schema, so ReplaceVars + // won't set it + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + if err != nil { + return err + } + + obj, err = resourceAccessContextManagerServicePerimeterIngressPolicyPatchUpdateEncoder(d, meta, obj) + if err != nil { + return err + } + + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp + } + + // if updateMask is empty we are not updating anything so skip the post + if len(updateMask) > 0 { + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "PUT", + Project: billingProject, + RawURL: url, + UserAgent: userAgent, + Body: obj, + Timeout: d.Timeout(schema.TimeoutUpdate), + }) + + if err != nil { + return fmt.Errorf("Error updating ServicePerimeterIngressPolicy %q: %s", d.Id(), err) + } else { + log.Printf("[DEBUG] Finished updating ServicePerimeterIngressPolicy %q: %#v", d.Id(), res) + } + + err = AccessContextManagerOperationWaitTime( + config, res, "Updating ServicePerimeterIngressPolicy", userAgent, + d.Timeout(schema.TimeoutUpdate)) + + if err != nil { + return err + } + } + + return resourceAccessContextManagerServicePerimeterIngressPolicyRead(d, meta) +} + func resourceAccessContextManagerServicePerimeterIngressPolicyDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -405,8 +482,6 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyDelete(d *schema.R billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServicePerimeterIngressPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -416,7 +491,6 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyDelete(d *schema.R UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServicePerimeterIngressPolicy") @@ -847,6 +921,42 @@ func resourceAccessContextManagerServicePerimeterIngressPolicyPatchCreateEncoder return res, nil } +// PatchUpdateEncoder handles creating request data to PATCH parent resource +// with list including updated object. +func resourceAccessContextManagerServicePerimeterIngressPolicyPatchUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + items, err := resourceAccessContextManagerServicePerimeterIngressPolicyListForPatch(d, meta) + if err != nil { + return nil, err + } + + idx, item, err := resourceAccessContextManagerServicePerimeterIngressPolicyFindNestedObjectInList(d, meta, items) + if err != nil { + return nil, err + } + + // Return error if item to update does not exist. + if item == nil { + return nil, fmt.Errorf("Unable to update ServicePerimeterIngressPolicy %q - not found in list", d.Id()) + } + + // Merge new object into old. + for k, v := range obj { + item[k] = v + } + items[idx] = item + + // Return list with new item added + res := map[string]interface{}{ + "ingressPolicies": items, + } + wrapped := map[string]interface{}{ + "status": res, + } + res = wrapped + + return res, nil +} + // PatchDeleteEncoder handles creating request data to PATCH parent resource // with list excluding object to delete. func resourceAccessContextManagerServicePerimeterIngressPolicyPatchDeleteEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go index 5e802e12211..1ff6584c857 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeter_resource.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -110,7 +109,6 @@ func resourceAccessContextManagerServicePerimeterResourceCreate(d *schema.Resour billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -119,7 +117,6 @@ func resourceAccessContextManagerServicePerimeterResourceCreate(d *schema.Resour UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServicePerimeterResource: %s", err) @@ -190,14 +187,12 @@ func resourceAccessContextManagerServicePerimeterResourceRead(d *schema.Resource billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerServicePerimeterResource %q", d.Id())) @@ -259,8 +254,6 @@ func resourceAccessContextManagerServicePerimeterResourceDelete(d *schema.Resour billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServicePerimeterResource %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -270,7 +263,6 @@ func resourceAccessContextManagerServicePerimeterResourceDelete(d *schema.Resour UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServicePerimeterResource") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go index 080bc173d6c..832028edf59 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/accesscontextmanager/resource_access_context_manager_service_perimeters.go @@ -20,7 +20,6 @@ package accesscontextmanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -151,9 +150,10 @@ a perimeter bridge.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this 'EgressPolicy'. -Should be in the format of email address. The email address should -represent individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'EgressPolicy'. +To specify an identity or identity group, use the IAM v1 format +specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -290,9 +290,10 @@ to apply.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this ingress policy. -Should be in the format of email address. The email address should represent -individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'IngressPolicy'. +To specify an identity or identity group, use the IAM v1 format +specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -512,9 +513,10 @@ a perimeter bridge.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this 'EgressPolicy'. -Should be in the format of email address. The email address should -represent individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'EgressPolicy'. +To specify an identity or identity group, use the IAM v1 format +specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -740,9 +742,10 @@ to apply.`, "identities": { Type: schema.TypeSet, Optional: true, - Description: `A list of identities that are allowed access through this ingress policy. -Should be in the format of email address. The email address should represent -individual user or service account only.`, + Description: `'A list of identities that are allowed access through this 'IngressPolicy'. +To specify an identity or identity group, use the IAM v1 format +specified [here](https://cloud.google.com/iam/docs/principal-identifiers.md#v1). +The following prefixes are supprted: user, group, serviceAccount, principal, and principalSet.'`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -897,7 +900,6 @@ func resourceAccessContextManagerServicePerimetersCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -906,7 +908,6 @@ func resourceAccessContextManagerServicePerimetersCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServicePerimeters: %s", err) @@ -953,14 +954,12 @@ func resourceAccessContextManagerServicePerimetersRead(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AccessContextManagerServicePerimeters %q", d.Id())) @@ -1002,7 +1001,6 @@ func resourceAccessContextManagerServicePerimetersUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating ServicePerimeters %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1017,7 +1015,6 @@ func resourceAccessContextManagerServicePerimetersUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1099,13 +1096,14 @@ func flattenAccessContextManagerServicePerimetersServicePerimeters(v interface{} return v } l := v.([]interface{}) - apiData := make([]map[string]interface{}, 0, len(l)) + transformed := make([]interface{}, 0, len(l)) for _, raw := range l { original := raw.(map[string]interface{}) if len(original) < 1 { + // Do not include empty json objects coming back from the api continue } - apiData = append(apiData, map[string]interface{}{ + transformed = append(transformed, map[string]interface{}{ "name": flattenAccessContextManagerServicePerimetersServicePerimetersName(original["name"], d, config), "title": flattenAccessContextManagerServicePerimetersServicePerimetersTitle(original["title"], d, config), "description": flattenAccessContextManagerServicePerimetersServicePerimetersDescription(original["description"], d, config), @@ -1117,19 +1115,8 @@ func flattenAccessContextManagerServicePerimetersServicePerimeters(v interface{} "use_explicit_dry_run_spec": flattenAccessContextManagerServicePerimetersServicePerimetersUseExplicitDryRunSpec(original["useExplicitDryRunSpec"], d, config), }) } - configData := []map[string]interface{}{} - for _, item := range d.Get("service_perimeters").([]interface{}) { - configData = append(configData, item.(map[string]interface{})) - } - sorted, err := tpgresource.SortMapsByConfigOrder(configData, apiData, "name") - if err != nil { - log.Printf("[ERROR] Could not sort API response value: %s", err) - return v - } - - return sorted + return transformed } - func flattenAccessContextManagerServicePerimetersServicePerimetersName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain.go index 744621beaa7..7d7cd7d450e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain.go @@ -20,7 +20,6 @@ package activedirectory import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -61,8 +60,8 @@ func ResourceActiveDirectoryDomain() *schema.Resource { Required: true, ForceNew: true, ValidateFunc: verify.ValidateADDomainName(), - Description: `The fully qualified domain name. e.g. mydomain.myorganization.com, with the restrictions -of https://cloud.google.com/managed-microsoft-ad/reference/rest/v1/projects.locations.global.domains.`, + Description: `The fully qualified domain name. e.g. mydomain.myorganization.com, with the restrictions, +https://cloud.google.com/managed-microsoft-ad/reference/rest/v1/projects.locations.global.domains.`, }, "locations": { Type: schema.TypeList, @@ -200,7 +199,6 @@ func resourceActiveDirectoryDomainCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -209,7 +207,6 @@ func resourceActiveDirectoryDomainCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -277,14 +274,12 @@ func resourceActiveDirectoryDomainRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -367,7 +362,6 @@ func resourceActiveDirectoryDomainUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating Domain %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("authorized_networks") { @@ -403,7 +397,6 @@ func resourceActiveDirectoryDomainUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -452,8 +445,6 @@ func resourceActiveDirectoryDomainDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Domain %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -463,7 +454,6 @@ func resourceActiveDirectoryDomainDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain_trust.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain_trust.go index 9f970a77d6c..23c158fcb83 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain_trust.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/activedirectory/resource_active_directory_domain_trust.go @@ -20,7 +20,6 @@ package activedirectory import ( "fmt" "log" - "net/http" "reflect" "time" @@ -58,8 +57,8 @@ func ResourceActiveDirectoryDomainTrust() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: `The fully qualified domain name. e.g. mydomain.myorganization.com, with the restrictions -of https://cloud.google.com/managed-microsoft-ad/reference/rest/v1/projects.locations.global.domains.`, + Description: `The fully qualified domain name. e.g. mydomain.myorganization.com, with the restrictions, +https://cloud.google.com/managed-microsoft-ad/reference/rest/v1/projects.locations.global.domains.`, }, "target_dns_ip_addresses": { Type: schema.TypeSet, @@ -182,7 +181,6 @@ func resourceActiveDirectoryDomainTrustCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -191,7 +189,6 @@ func resourceActiveDirectoryDomainTrustCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DomainTrust: %s", err) @@ -276,14 +273,12 @@ func resourceActiveDirectoryDomainTrustRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ActiveDirectoryDomainTrust %q", d.Id())) @@ -400,7 +395,6 @@ func resourceActiveDirectoryDomainTrustUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating DomainTrust %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -415,7 +409,6 @@ func resourceActiveDirectoryDomainTrustUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -591,6 +584,7 @@ func expandNestedActiveDirectoryDomainTrustTrustHandshakeSecret(v interface{}, d } func resourceActiveDirectoryDomainTrustEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + wrappedReq := map[string]interface{}{ "trust": obj, } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_backup.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_backup.go index c7cc2cf73e7..2290836790a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_backup.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_backup.go @@ -20,7 +20,6 @@ package alloydb import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -337,7 +336,6 @@ func resourceAlloydbBackupCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -346,7 +344,6 @@ func resourceAlloydbBackupCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Backup: %s", err) @@ -399,14 +396,12 @@ func resourceAlloydbBackupRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AlloydbBackup %q", d.Id())) @@ -553,7 +548,6 @@ func resourceAlloydbBackupUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Backup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -601,7 +595,6 @@ func resourceAlloydbBackupUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -649,8 +642,6 @@ func resourceAlloydbBackupDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Backup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -660,7 +651,6 @@ func resourceAlloydbBackupDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Backup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster.go index a8218fdb348..73e71226246 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster.go @@ -20,7 +20,6 @@ package alloydb import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -328,61 +327,6 @@ If not set, defaults to 14 days.`, Please refer to the field 'effective_labels' for all of the labels present on the resource.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "maintenance_update_policy": { - Type: schema.TypeList, - Optional: true, - Description: `MaintenanceUpdatePolicy defines the policy for system updates.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "maintenance_windows": { - Type: schema.TypeList, - Optional: true, - Description: `Preferred windows to perform maintenance. Currently limited to 1.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "day": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"}), - Description: `Preferred day of the week for maintenance, e.g. MONDAY, TUESDAY, etc. Possible values: ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]`, - }, - "start_time": { - Type: schema.TypeList, - Required: true, - Description: `Preferred time to start the maintenance operation on the specified day. Maintenance will start within 1 hour of this time.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "hours": { - Type: schema.TypeInt, - Required: true, - Description: `Hours of day in 24 hour format. Should be from 0 to 23.`, - }, - "minutes": { - Type: schema.TypeInt, - Optional: true, - Description: `Minutes of hour of day. Currently, only the value 0 is supported.`, - }, - "nanos": { - Type: schema.TypeInt, - Optional: true, - Description: `Fractions of seconds in nanoseconds. Currently, only the value 0 is supported.`, - }, - "seconds": { - Type: schema.TypeInt, - Optional: true, - Description: `Seconds of minutes of the time. Currently, only the value 0 is supported.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "network": { Type: schema.TypeString, Computed: true, @@ -392,7 +336,7 @@ Please refer to the field 'effective_labels' for all of the labels present on th Description: `The relative resource name of the VPC network on which the instance can be accessed. It is specified in the following form: "projects/{projectNumber}/global/networks/{network_id}".`, - ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"}, + ExactlyOneOf: []string{"network", "network_config.0.network"}, }, "network_config": { Type: schema.TypeList, @@ -414,22 +358,7 @@ If set, the instance IPs for this cluster will be created in the allocated range DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, Description: `The resource link for the VPC network in which cluster resources are created and from which they are accessible via Private IP. The network must belong to the same project as the cluster. It is specified in the form: "projects/{projectNumber}/global/networks/{network_id}".`, - ExactlyOneOf: []string{"network", "network_config.0.network", "psc_config.0.psc_enabled"}, - }, - }, - }, - }, - "psc_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration for Private Service Connect (PSC) for the cluster.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "psc_enabled": { - Type: schema.TypeBool, - Optional: true, - Description: `Create an instance that allows connections from Private Service Connect endpoints to the instance.`, + ExactlyOneOf: []string{"network", "network_config.0.network"}, }, }, }, @@ -705,12 +634,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro } else if v, ok := d.GetOkExists("database_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(databaseVersionProp)) && (ok || !reflect.DeepEqual(v, databaseVersionProp)) { obj["databaseVersion"] = databaseVersionProp } - pscConfigProp, err := expandAlloydbClusterPscConfig(d.Get("psc_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("psc_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(pscConfigProp)) && (ok || !reflect.DeepEqual(v, pscConfigProp)) { - obj["pscConfig"] = pscConfigProp - } initialUserProp, err := expandAlloydbClusterInitialUser(d.Get("initial_user"), d, config) if err != nil { return err @@ -753,12 +676,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro } else if v, ok := d.GetOkExists("secondary_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(secondaryConfigProp)) && (ok || !reflect.DeepEqual(v, secondaryConfigProp)) { obj["secondaryConfig"] = secondaryConfigProp } - maintenanceUpdatePolicyProp, err := expandAlloydbClusterMaintenanceUpdatePolicy(d.Get("maintenance_update_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("maintenance_update_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(maintenanceUpdatePolicyProp)) && (ok || !reflect.DeepEqual(v, maintenanceUpdatePolicyProp)) { - obj["maintenanceUpdatePolicy"] = maintenanceUpdatePolicyProp - } labelsProp, err := expandAlloydbClusterEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -791,7 +708,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) // Read the restore variables from obj and remove them, since they do not map to anything in the cluster var backupSource interface{} var continuousBackupSource interface{} @@ -864,7 +780,6 @@ func resourceAlloydbClusterCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Cluster: %s", err) @@ -917,14 +832,12 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AlloydbCluster %q", d.Id())) @@ -982,9 +895,6 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("database_version", flattenAlloydbClusterDatabaseVersion(res["databaseVersion"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } - if err := d.Set("psc_config", flattenAlloydbClusterPscConfig(res["pscConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } if err := d.Set("continuous_backup_config", flattenAlloydbClusterContinuousBackupConfig(res["continuousBackupConfig"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -1003,9 +913,6 @@ func resourceAlloydbClusterRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("secondary_config", flattenAlloydbClusterSecondaryConfig(res["secondaryConfig"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } - if err := d.Set("maintenance_update_policy", flattenAlloydbClusterMaintenanceUpdatePolicy(res["maintenanceUpdatePolicy"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } if err := d.Set("terraform_labels", flattenAlloydbClusterTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -1071,12 +978,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro } else if v, ok := d.GetOkExists("database_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, databaseVersionProp)) { obj["databaseVersion"] = databaseVersionProp } - pscConfigProp, err := expandAlloydbClusterPscConfig(d.Get("psc_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("psc_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, pscConfigProp)) { - obj["pscConfig"] = pscConfigProp - } initialUserProp, err := expandAlloydbClusterInitialUser(d.Get("initial_user"), d, config) if err != nil { return err @@ -1107,12 +1008,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro } else if v, ok := d.GetOkExists("secondary_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, secondaryConfigProp)) { obj["secondaryConfig"] = secondaryConfigProp } - maintenanceUpdatePolicyProp, err := expandAlloydbClusterMaintenanceUpdatePolicy(d.Get("maintenance_update_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("maintenance_update_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, maintenanceUpdatePolicyProp)) { - obj["maintenanceUpdatePolicy"] = maintenanceUpdatePolicyProp - } labelsProp, err := expandAlloydbClusterEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -1132,7 +1027,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Cluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("encryption_config") { @@ -1159,10 +1053,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro updateMask = append(updateMask, "databaseVersion") } - if d.HasChange("psc_config") { - updateMask = append(updateMask, "pscConfig") - } - if d.HasChange("initial_user") { updateMask = append(updateMask, "initialUser") } @@ -1183,10 +1073,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro updateMask = append(updateMask, "secondaryConfig") } - if d.HasChange("maintenance_update_policy") { - updateMask = append(updateMask, "maintenanceUpdatePolicy") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -1200,6 +1086,11 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro if err != nil { return err } + // Restrict modification of cluster_type from PRIMARY to SECONDARY as it is an invalid operation + if d.HasChange("cluster_type") && d.Get("cluster_type") == "SECONDARY" { + return fmt.Errorf("Can not convert a primary cluster to a secondary cluster.") + } + // Restrict setting secondary_config if cluster_type is PRIMARY if d.Get("cluster_type") == "PRIMARY" && !tpgresource.IsEmptyValue(reflect.ValueOf(d.Get("secondary_config"))) { return fmt.Errorf("Can not set secondary config for primary cluster.") @@ -1283,7 +1174,6 @@ func resourceAlloydbClusterUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1331,7 +1221,6 @@ func resourceAlloydbClusterDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) // Forcefully delete the secondary cluster and the dependent instances because deletion of secondary instance is not supported. if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "FORCE" { url = url + "?force=true" @@ -1346,7 +1235,6 @@ func resourceAlloydbClusterDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Cluster") @@ -1569,23 +1457,6 @@ func flattenAlloydbClusterDatabaseVersion(v interface{}, d *schema.ResourceData, return v } -func flattenAlloydbClusterPscConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["psc_enabled"] = - flattenAlloydbClusterPscConfigPscEnabled(original["pscEnabled"], d, config) - return []interface{}{transformed} -} -func flattenAlloydbClusterPscConfigPscEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenAlloydbClusterContinuousBackupConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1924,129 +1795,6 @@ func flattenAlloydbClusterSecondaryConfigPrimaryClusterName(v interface{}, d *sc return v } -func flattenAlloydbClusterMaintenanceUpdatePolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["maintenance_windows"] = - flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindows(original["maintenanceWindows"], d, config) - return []interface{}{transformed} -} -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindows(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "day": flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsDay(original["day"], d, config), - "start_time": flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTime(original["startTime"], d, config), - }) - } - return transformed -} -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsDay(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["hours"] = - flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeHours(original["hours"], d, config) - transformed["minutes"] = - flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeMinutes(original["minutes"], d, config) - transformed["seconds"] = - flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeSeconds(original["seconds"], d, config) - transformed["nanos"] = - flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeNanos(original["nanos"], d, config) - return []interface{}{transformed} -} -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeHours(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeMinutes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeSeconds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeNanos(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - func flattenAlloydbClusterTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -2143,29 +1891,6 @@ func expandAlloydbClusterDatabaseVersion(v interface{}, d tpgresource.TerraformR return v, nil } -func expandAlloydbClusterPscConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPscEnabled, err := expandAlloydbClusterPscConfigPscEnabled(original["psc_enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPscEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pscEnabled"] = transformedPscEnabled - } - - return transformed, nil -} - -func expandAlloydbClusterPscConfigPscEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandAlloydbClusterInitialUser(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2597,114 +2322,6 @@ func expandAlloydbClusterSecondaryConfigPrimaryClusterName(v interface{}, d tpgr return v, nil } -func expandAlloydbClusterMaintenanceUpdatePolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMaintenanceWindows, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindows(original["maintenance_windows"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMaintenanceWindows); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["maintenanceWindows"] = transformedMaintenanceWindows - } - - return transformed, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindows(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDay, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsDay(original["day"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDay); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["day"] = transformedDay - } - - transformedStartTime, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTime(original["start_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStartTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["startTime"] = transformedStartTime - } - - req = append(req, transformed) - } - return req, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsDay(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedHours, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeHours(original["hours"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedHours); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["hours"] = transformedHours - } - - transformedMinutes, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeMinutes(original["minutes"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinutes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minutes"] = transformedMinutes - } - - transformedSeconds, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeSeconds(original["seconds"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeconds); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["seconds"] = transformedSeconds - } - - transformedNanos, err := expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeNanos(original["nanos"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedNanos); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["nanos"] = transformedNanos - } - - return transformed, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeHours(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeMinutes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeSeconds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbClusterMaintenanceUpdatePolicyMaintenanceWindowsStartTimeNanos(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandAlloydbClusterEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster_sweeper.go index 28bedefbb83..c4fc1fb19c0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_cluster_sweeper.go @@ -4,7 +4,6 @@ package alloydb import ( "context" - "fmt" "log" "strings" "testing" @@ -50,8 +49,7 @@ func testSweepAlloydbCluster(region string) error { }, } - // manual patch: use aggregated list instead of sweeper-specific location. This will clear secondary clusters. - listTemplate := strings.Split("https://alloydb.googleapis.com/v1/projects/{{project}}/locations/-/clusters", "?")[0] + listTemplate := strings.Split("https://alloydb.googleapis.com/v1/projects/{{project}}/locations/{{location}}/clusters", "?")[0] listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -83,19 +81,29 @@ func testSweepAlloydbCluster(region string) error { nonPrefixCount := 0 for _, ri := range rl { obj := ri.(map[string]interface{}) - - // manual patch: use raw name for url instead of constructing it, so that resource locations are supplied through aggregated list - // manual patch: Using the force=true ensures that we delete instances as well. - name := obj["name"].(string) - shortname := tpgresource.GetResourceNameFromSelfLink(name) + var name string + // Id detected in the delete URL, attempt to use id. + if obj["id"] != nil { + name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) + } else if obj["name"] != nil { + name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) + } else { + log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) + return nil + } // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(shortname) { + if !sweeper.IsSweepableTestResource(name) { nonPrefixCount++ continue } - deleteTemplate := "https://alloydb.googleapis.com/v1/%s?force=true" - deleteUrl := fmt.Sprintf(deleteTemplate, name) + deleteTemplate := "https://alloydb.googleapis.com/v1/projects/{{project}}/locations/{{location}}/clusters/{{cluster_id}}" + deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) + return nil + } + deleteUrl = deleteUrl + name + "?force=true" // Don't wait on operations as we may have a lot to delete _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ @@ -108,7 +116,7 @@ func testSweepAlloydbCluster(region string) error { if err != nil { log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", name, shortname) + log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) } } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_instance.go index 4b07f532577..52e6a8ee1d4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_instance.go @@ -20,7 +20,6 @@ package alloydb import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -181,73 +180,6 @@ Please refer to the field 'effective_labels' for all of the labels present on th }, }, }, - "network_config": { - Type: schema.TypeList, - Optional: true, - Description: `Instance level network configuration.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "authorized_external_networks": { - Type: schema.TypeList, - Optional: true, - Description: `A list of external networks authorized to access this instance. This -field is only allowed to be set when 'enable_public_ip' is set to -true.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cidr_range": { - Type: schema.TypeString, - Optional: true, - Description: `CIDR range for one authorized network of the instance.`, - }, - }, - }, - RequiredWith: []string{"network_config.0.enable_public_ip"}, - }, - "enable_public_ip": { - Type: schema.TypeBool, - Optional: true, - Description: `Enabling public ip for the instance. If a user wishes to disable this, -please also clear the list of the authorized external networks set on -the same instance.`, - }, - }, - }, - }, - "psc_instance_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration for Private Service Connect (PSC) for the instance.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allowed_consumer_projects": { - Type: schema.TypeList, - Optional: true, - Description: `List of consumer projects that are allowed to create PSC endpoints to service-attachments to this instance. -These should be specified as project numbers only.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateRegexp(`^\d+$`), - }, - }, - "psc_dns_name": { - Type: schema.TypeString, - Computed: true, - Description: `The DNS name of the instance for PSC connectivity. -Name convention: ...alloydb-psc.goog`, - }, - "service_attachment_link": { - Type: schema.TypeString, - Computed: true, - Description: `The service attachment created when Private Service Connect (PSC) is enabled for the instance. -The name of the resource will be in the format of -'projects//regions//serviceAttachments/'`, - }, - }, - }, - }, "query_insights_config": { Type: schema.TypeList, Computed: true, @@ -321,13 +253,6 @@ The name of the resource will be in the format of Computed: true, Description: `The name of the instance resource.`, }, - "public_ip_address": { - Type: schema.TypeString, - Computed: true, - Description: `The public IP addresses for the Instance. This is available ONLY when -networkConfig.enablePublicIp is set to true. This is the connection -endpoint for an end-user application.`, - }, "reconciling": { Type: schema.TypeBool, Computed: true, @@ -423,18 +348,6 @@ func resourceAlloydbInstanceCreate(d *schema.ResourceData, meta interface{}) err } else if v, ok := d.GetOkExists("client_connection_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(clientConnectionConfigProp)) && (ok || !reflect.DeepEqual(v, clientConnectionConfigProp)) { obj["clientConnectionConfig"] = clientConnectionConfigProp } - pscInstanceConfigProp, err := expandAlloydbInstancePscInstanceConfig(d.Get("psc_instance_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("psc_instance_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(pscInstanceConfigProp)) && (ok || !reflect.DeepEqual(v, pscInstanceConfigProp)) { - obj["pscInstanceConfig"] = pscInstanceConfigProp - } - networkConfigProp, err := expandAlloydbInstanceNetworkConfig(d.Get("network_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkConfigProp)) && (ok || !reflect.DeepEqual(v, networkConfigProp)) { - obj["networkConfig"] = networkConfigProp - } labelsProp, err := expandAlloydbInstanceEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -461,7 +374,6 @@ func resourceAlloydbInstanceCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) // Read the config and call createsecondary api if instance_type is SECONDARY if instanceType := d.Get("instance_type"); instanceType == "SECONDARY" { @@ -475,7 +387,6 @@ func resourceAlloydbInstanceCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -522,14 +433,12 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AlloydbInstance %q", d.Id())) @@ -586,15 +495,6 @@ func resourceAlloydbInstanceRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("client_connection_config", flattenAlloydbInstanceClientConnectionConfig(res["clientConnectionConfig"], d, config)); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } - if err := d.Set("psc_instance_config", flattenAlloydbInstancePscInstanceConfig(res["pscInstanceConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Instance: %s", err) - } - if err := d.Set("network_config", flattenAlloydbInstanceNetworkConfig(res["networkConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Instance: %s", err) - } - if err := d.Set("public_ip_address", flattenAlloydbInstancePublicIpAddress(res["publicIpAddress"], d, config)); err != nil { - return fmt.Errorf("Error reading Instance: %s", err) - } if err := d.Set("terraform_labels", flattenAlloydbInstanceTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -667,18 +567,6 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err } else if v, ok := d.GetOkExists("client_connection_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, clientConnectionConfigProp)) { obj["clientConnectionConfig"] = clientConnectionConfigProp } - pscInstanceConfigProp, err := expandAlloydbInstancePscInstanceConfig(d.Get("psc_instance_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("psc_instance_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, pscInstanceConfigProp)) { - obj["pscInstanceConfig"] = pscInstanceConfigProp - } - networkConfigProp, err := expandAlloydbInstanceNetworkConfig(d.Get("network_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, networkConfigProp)) { - obj["networkConfig"] = networkConfigProp - } labelsProp, err := expandAlloydbInstanceEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -698,7 +586,6 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -733,14 +620,6 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err updateMask = append(updateMask, "clientConnectionConfig") } - if d.HasChange("psc_instance_config") { - updateMask = append(updateMask, "pscInstanceConfig") - } - - if d.HasChange("network_config") { - updateMask = append(updateMask, "networkConfig") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -770,7 +649,6 @@ func resourceAlloydbInstanceUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -813,7 +691,6 @@ func resourceAlloydbInstanceDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) // Read the config and avoid calling the delete API if the instance_type is SECONDARY and instead return nil // Returning nil is equivalent of returning a success message to the users // This is done because deletion of secondary instance is not supported @@ -842,7 +719,6 @@ func resourceAlloydbInstanceDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") @@ -1111,80 +987,6 @@ func flattenAlloydbInstanceClientConnectionConfigSslConfigSslMode(v interface{}, return v } -func flattenAlloydbInstancePscInstanceConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["service_attachment_link"] = - flattenAlloydbInstancePscInstanceConfigServiceAttachmentLink(original["serviceAttachmentLink"], d, config) - transformed["allowed_consumer_projects"] = - flattenAlloydbInstancePscInstanceConfigAllowedConsumerProjects(original["allowedConsumerProjects"], d, config) - transformed["psc_dns_name"] = - flattenAlloydbInstancePscInstanceConfigPscDnsName(original["pscDnsName"], d, config) - return []interface{}{transformed} -} -func flattenAlloydbInstancePscInstanceConfigServiceAttachmentLink(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAlloydbInstancePscInstanceConfigAllowedConsumerProjects(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAlloydbInstancePscInstanceConfigPscDnsName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAlloydbInstanceNetworkConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["authorized_external_networks"] = - flattenAlloydbInstanceNetworkConfigAuthorizedExternalNetworks(original["authorizedExternalNetworks"], d, config) - transformed["enable_public_ip"] = - flattenAlloydbInstanceNetworkConfigEnablePublicIp(original["enablePublicIp"], d, config) - return []interface{}{transformed} -} -func flattenAlloydbInstanceNetworkConfigAuthorizedExternalNetworks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "cidr_range": flattenAlloydbInstanceNetworkConfigAuthorizedExternalNetworksCidrRange(original["cidrRange"], d, config), - }) - } - return transformed -} -func flattenAlloydbInstanceNetworkConfigAuthorizedExternalNetworksCidrRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAlloydbInstanceNetworkConfigEnablePublicIp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAlloydbInstancePublicIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenAlloydbInstanceTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -1390,107 +1192,6 @@ func expandAlloydbInstanceClientConnectionConfigSslConfigSslMode(v interface{}, return v, nil } -func expandAlloydbInstancePscInstanceConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedServiceAttachmentLink, err := expandAlloydbInstancePscInstanceConfigServiceAttachmentLink(original["service_attachment_link"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAttachmentLink); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAttachmentLink"] = transformedServiceAttachmentLink - } - - transformedAllowedConsumerProjects, err := expandAlloydbInstancePscInstanceConfigAllowedConsumerProjects(original["allowed_consumer_projects"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAllowedConsumerProjects); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["allowedConsumerProjects"] = transformedAllowedConsumerProjects - } - - transformedPscDnsName, err := expandAlloydbInstancePscInstanceConfigPscDnsName(original["psc_dns_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPscDnsName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pscDnsName"] = transformedPscDnsName - } - - return transformed, nil -} - -func expandAlloydbInstancePscInstanceConfigServiceAttachmentLink(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbInstancePscInstanceConfigAllowedConsumerProjects(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbInstancePscInstanceConfigPscDnsName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbInstanceNetworkConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAuthorizedExternalNetworks, err := expandAlloydbInstanceNetworkConfigAuthorizedExternalNetworks(original["authorized_external_networks"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthorizedExternalNetworks); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authorizedExternalNetworks"] = transformedAuthorizedExternalNetworks - } - - transformedEnablePublicIp, err := expandAlloydbInstanceNetworkConfigEnablePublicIp(original["enable_public_ip"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnablePublicIp); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enablePublicIp"] = transformedEnablePublicIp - } - - return transformed, nil -} - -func expandAlloydbInstanceNetworkConfigAuthorizedExternalNetworks(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCidrRange, err := expandAlloydbInstanceNetworkConfigAuthorizedExternalNetworksCidrRange(original["cidr_range"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCidrRange); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["cidrRange"] = transformedCidrRange - } - - req = append(req, transformed) - } - return req, nil -} - -func expandAlloydbInstanceNetworkConfigAuthorizedExternalNetworksCidrRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAlloydbInstanceNetworkConfigEnablePublicIp(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandAlloydbInstanceEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_user.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_user.go index 79d8ec3a60b..1ec56a540fd 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_user.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/alloydb/resource_alloydb_user.go @@ -20,7 +20,6 @@ package alloydb import ( "fmt" "log" - "net/http" "reflect" "time" @@ -133,7 +132,6 @@ func resourceAlloydbUserCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -142,7 +140,6 @@ func resourceAlloydbUserCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating User: %s", err) @@ -182,14 +179,12 @@ func resourceAlloydbUserRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AlloydbUser %q", d.Id())) @@ -243,7 +238,6 @@ func resourceAlloydbUserUpdate(d *schema.ResourceData, meta interface{}) error { } log.Printf("[DEBUG] Updating User %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -258,7 +252,6 @@ func resourceAlloydbUserUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -291,8 +284,6 @@ func resourceAlloydbUserDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting User %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -302,7 +293,6 @@ func resourceAlloydbUserDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "User") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_addons_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_addons_config.go index 591c3600968..082a121dac3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_addons_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_addons_config.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -183,7 +182,6 @@ func resourceApigeeAddonsConfigCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -192,7 +190,6 @@ func resourceApigeeAddonsConfigCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AddonsConfig: %s", err) @@ -239,14 +236,12 @@ func resourceApigeeAddonsConfigRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeAddonsConfig %q", d.Id())) @@ -282,7 +277,6 @@ func resourceApigeeAddonsConfigUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating AddonsConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -297,7 +291,6 @@ func resourceApigeeAddonsConfigUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -338,8 +331,6 @@ func resourceApigeeAddonsConfigDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AddonsConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -349,7 +340,6 @@ func resourceApigeeAddonsConfigDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AddonsConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_endpoint_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_endpoint_attachment.go index 29118a81086..b26c0d3afb1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_endpoint_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_endpoint_attachment.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -127,7 +126,6 @@ func resourceApigeeEndpointAttachmentCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -136,7 +134,6 @@ func resourceApigeeEndpointAttachmentCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EndpointAttachment: %s", err) @@ -197,14 +194,12 @@ func resourceApigeeEndpointAttachmentRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeEndpointAttachment %q", d.Id())) @@ -250,8 +245,6 @@ func resourceApigeeEndpointAttachmentDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EndpointAttachment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -261,7 +254,6 @@ func resourceApigeeEndpointAttachmentDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EndpointAttachment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_keystore.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_keystore.go index d6e69e206c2..226da121036 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_keystore.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_keystore.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -100,7 +99,6 @@ func resourceApigeeEnvKeystoreCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -109,7 +107,6 @@ func resourceApigeeEnvKeystoreCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EnvKeystore: %s", err) @@ -146,14 +143,12 @@ func resourceApigeeEnvKeystoreRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeEnvKeystore %q", d.Id())) @@ -190,8 +185,6 @@ func resourceApigeeEnvKeystoreDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EnvKeystore %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -201,7 +194,6 @@ func resourceApigeeEnvKeystoreDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EnvKeystore") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_references.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_references.go index 7c6ee103f4d..360d3e5be63 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_references.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_env_references.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -128,7 +127,6 @@ func resourceApigeeEnvReferencesCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -137,7 +135,6 @@ func resourceApigeeEnvReferencesCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EnvReferences: %s", err) @@ -174,14 +171,12 @@ func resourceApigeeEnvReferencesRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeEnvReferences %q", d.Id())) @@ -224,8 +219,6 @@ func resourceApigeeEnvReferencesDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EnvReferences %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -235,7 +228,6 @@ func resourceApigeeEnvReferencesDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EnvReferences") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup.go index 9abc2f05bab..c4d1253afc3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -109,7 +108,6 @@ func resourceApigeeEnvgroupCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -118,7 +116,6 @@ func resourceApigeeEnvgroupCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Envgroup: %s", err) @@ -179,14 +176,12 @@ func resourceApigeeEnvgroupRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeEnvgroup %q", d.Id())) @@ -225,7 +220,6 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Envgroup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("hostnames") { @@ -253,7 +247,6 @@ func resourceApigeeEnvgroupUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -295,8 +288,6 @@ func resourceApigeeEnvgroupDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Envgroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -306,7 +297,6 @@ func resourceApigeeEnvgroupDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Envgroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup_attachment.go index aae2f9bee3b..ccc4a888b35 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_envgroup_attachment.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -97,7 +96,6 @@ func resourceApigeeEnvgroupAttachmentCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -106,7 +104,6 @@ func resourceApigeeEnvgroupAttachmentCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EnvgroupAttachment: %s", err) @@ -167,14 +164,12 @@ func resourceApigeeEnvgroupAttachmentRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeEnvgroupAttachment %q", d.Id())) @@ -211,8 +206,6 @@ func resourceApigeeEnvgroupAttachmentDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EnvgroupAttachment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -222,7 +215,6 @@ func resourceApigeeEnvgroupAttachmentDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EnvgroupAttachment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_environment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_environment.go index 5c46a0c1f22..870dca38413 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_environment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_environment.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -98,11 +97,6 @@ Creating, updating, or deleting target servers. Possible values: ["DEPLOYMENT_TY ForceNew: true, Description: `Display name of the environment.`, }, - "forward_proxy_uri": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. URI of the forward proxy to be applied to the runtime instances in this environment. Must be in the format of {scheme}://{hostname}:{port}. Note that the scheme must be one of "http" or "https", and the port must be supplied.`, - }, "node_config": { Type: schema.TypeList, Computed: true, @@ -199,12 +193,6 @@ func resourceApigeeEnvironmentCreate(d *schema.ResourceData, meta interface{}) e } else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) { obj["type"] = typeProp } - forwardProxyUriProp, err := expandApigeeEnvironmentForwardProxyUri(d.Get("forward_proxy_uri"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("forward_proxy_uri"); !tpgresource.IsEmptyValue(reflect.ValueOf(forwardProxyUriProp)) && (ok || !reflect.DeepEqual(v, forwardProxyUriProp)) { - obj["forwardProxyUri"] = forwardProxyUriProp - } url, err := tpgresource.ReplaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments") if err != nil { @@ -219,7 +207,6 @@ func resourceApigeeEnvironmentCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -228,7 +215,6 @@ func resourceApigeeEnvironmentCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Environment: %s", err) @@ -289,14 +275,12 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeEnvironment %q", d.Id())) @@ -323,9 +307,6 @@ func resourceApigeeEnvironmentRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("type", flattenApigeeEnvironmentType(res["type"], d, config)); err != nil { return fmt.Errorf("Error reading Environment: %s", err) } - if err := d.Set("forward_proxy_uri", flattenApigeeEnvironmentForwardProxyUri(res["forwardProxyUri"], d, config)); err != nil { - return fmt.Errorf("Error reading Environment: %s", err) - } return nil } @@ -352,12 +333,6 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e } else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, typeProp)) { obj["type"] = typeProp } - forwardProxyUriProp, err := expandApigeeEnvironmentForwardProxyUri(d.Get("forward_proxy_uri"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("forward_proxy_uri"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, forwardProxyUriProp)) { - obj["forwardProxyUri"] = forwardProxyUriProp - } url, err := tpgresource.ReplaceVars(d, config, "{{ApigeeBasePath}}{{org_id}}/environments/{{name}}") if err != nil { @@ -365,7 +340,6 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Environment %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("node_config") { @@ -375,10 +349,6 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e if d.HasChange("type") { updateMask = append(updateMask, "type") } - - if d.HasChange("forward_proxy_uri") { - updateMask = append(updateMask, "forwardProxyUri") - } // updateMask is a URL parameter but not present in the schema, so ReplaceVars // won't set it url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) @@ -401,7 +371,6 @@ func resourceApigeeEnvironmentUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -443,8 +412,6 @@ func resourceApigeeEnvironmentDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Environment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -454,7 +421,6 @@ func resourceApigeeEnvironmentDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Environment") @@ -570,10 +536,6 @@ func flattenApigeeEnvironmentType(v interface{}, d *schema.ResourceData, config return v } -func flattenApigeeEnvironmentForwardProxyUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandApigeeEnvironmentName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -642,7 +604,3 @@ func expandApigeeEnvironmentNodeConfigCurrentAggregateNodeCount(v interface{}, d func expandApigeeEnvironmentType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func expandApigeeEnvironmentForwardProxyUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance.go index 1b454440288..d591f2e9f1d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -243,7 +242,6 @@ func resourceApigeeInstanceCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -252,7 +250,6 @@ func resourceApigeeInstanceCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsApigeeRetryableError}, }) if err != nil { @@ -314,14 +311,12 @@ func resourceApigeeInstanceRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsApigeeRetryableError}, }) if err != nil { @@ -390,8 +385,6 @@ func resourceApigeeInstanceDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -401,7 +394,6 @@ func resourceApigeeInstanceDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsApigeeRetryableError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance_attachment.go index 18f93f0171c..b89687b9daa 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_instance_attachment.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -104,7 +103,6 @@ func resourceApigeeInstanceAttachmentCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -113,7 +111,6 @@ func resourceApigeeInstanceAttachmentCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating InstanceAttachment: %s", err) @@ -174,14 +171,12 @@ func resourceApigeeInstanceAttachmentRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeInstanceAttachment %q", d.Id())) @@ -225,8 +220,6 @@ func resourceApigeeInstanceAttachmentDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting InstanceAttachment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -236,7 +229,6 @@ func resourceApigeeInstanceAttachmentDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "InstanceAttachment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go index 64fa17c746b..2ca2cea7f1c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_keystores_aliases_self_signed_cert.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -305,7 +304,6 @@ func resourceApigeeKeystoresAliasesSelfSignedCertCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -314,7 +312,6 @@ func resourceApigeeKeystoresAliasesSelfSignedCertCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating KeystoresAliasesSelfSignedCert: %s", err) @@ -351,14 +348,12 @@ func resourceApigeeKeystoresAliasesSelfSignedCertRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeKeystoresAliasesSelfSignedCert %q", d.Id())) @@ -401,8 +396,6 @@ func resourceApigeeKeystoresAliasesSelfSignedCertDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting KeystoresAliasesSelfSignedCert %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -412,7 +405,6 @@ func resourceApigeeKeystoresAliasesSelfSignedCertDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "KeystoresAliasesSelfSignedCert") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_nat_address.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_nat_address.go index 4d2cd80b6cb..f8aba9137bf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_nat_address.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_nat_address.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -102,7 +101,6 @@ func resourceApigeeNatAddressCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -111,7 +109,6 @@ func resourceApigeeNatAddressCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NatAddress: %s", err) @@ -172,14 +169,12 @@ func resourceApigeeNatAddressRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeNatAddress %q", d.Id())) @@ -219,8 +214,6 @@ func resourceApigeeNatAddressDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NatAddress %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -230,7 +223,6 @@ func resourceApigeeNatAddressDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NatAddress") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_organization.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_organization.go index 79897d02ce2..adf3aadcc1a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_organization.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_organization.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -62,20 +61,6 @@ func ResourceApigeeOrganization() *schema.Resource { ForceNew: true, Description: `Primary GCP region for analytics data storage. For valid values, see [Create an Apigee organization](https://cloud.google.com/apigee/docs/api-platform/get-started/create-org).`, }, - "api_consumer_data_encryption_key_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Cloud KMS key name used for encrypting API consumer data.`, - }, - "api_consumer_data_location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `This field is needed only for customers using non-default data residency regions. -Apigee stores some control plane data only in single region. -This field determines which single region Apigee should use.`, - }, "authorized_network": { Type: schema.TypeString, Optional: true, @@ -90,13 +75,6 @@ Valid only when 'RuntimeType' is set to CLOUD. The value can be updated only whe ForceNew: true, Description: `Billing type of the Apigee organization. See [Apigee pricing](https://cloud.google.com/apigee/pricing).`, }, - "control_plane_encryption_key_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Cloud KMS key name used for encrypting control plane data that is stored in a multi region. -Only used for the data residency region "US" or "EU".`, - }, "description": { Type: schema.TypeString, Optional: true, @@ -226,24 +204,6 @@ func resourceApigeeOrganizationCreate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("analytics_region"); !tpgresource.IsEmptyValue(reflect.ValueOf(analyticsRegionProp)) && (ok || !reflect.DeepEqual(v, analyticsRegionProp)) { obj["analyticsRegion"] = analyticsRegionProp } - apiConsumerDataLocationProp, err := expandApigeeOrganizationApiConsumerDataLocation(d.Get("api_consumer_data_location"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("api_consumer_data_location"); !tpgresource.IsEmptyValue(reflect.ValueOf(apiConsumerDataLocationProp)) && (ok || !reflect.DeepEqual(v, apiConsumerDataLocationProp)) { - obj["apiConsumerDataLocation"] = apiConsumerDataLocationProp - } - apiConsumerDataEncryptionKeyNameProp, err := expandApigeeOrganizationApiConsumerDataEncryptionKeyName(d.Get("api_consumer_data_encryption_key_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("api_consumer_data_encryption_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(apiConsumerDataEncryptionKeyNameProp)) && (ok || !reflect.DeepEqual(v, apiConsumerDataEncryptionKeyNameProp)) { - obj["apiConsumerDataEncryptionKeyName"] = apiConsumerDataEncryptionKeyNameProp - } - controlPlaneEncryptionKeyNameProp, err := expandApigeeOrganizationControlPlaneEncryptionKeyName(d.Get("control_plane_encryption_key_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("control_plane_encryption_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(controlPlaneEncryptionKeyNameProp)) && (ok || !reflect.DeepEqual(v, controlPlaneEncryptionKeyNameProp)) { - obj["controlPlaneEncryptionKeyName"] = controlPlaneEncryptionKeyNameProp - } authorizedNetworkProp, err := expandApigeeOrganizationAuthorizedNetwork(d.Get("authorized_network"), d, config) if err != nil { return err @@ -299,7 +259,6 @@ func resourceApigeeOrganizationCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -308,7 +267,6 @@ func resourceApigeeOrganizationCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Organization: %s", err) @@ -369,14 +327,12 @@ func resourceApigeeOrganizationRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeOrganization %q", d.Id())) @@ -394,15 +350,6 @@ func resourceApigeeOrganizationRead(d *schema.ResourceData, meta interface{}) er if err := d.Set("analytics_region", flattenApigeeOrganizationAnalyticsRegion(res["analyticsRegion"], d, config)); err != nil { return fmt.Errorf("Error reading Organization: %s", err) } - if err := d.Set("api_consumer_data_location", flattenApigeeOrganizationApiConsumerDataLocation(res["apiConsumerDataLocation"], d, config)); err != nil { - return fmt.Errorf("Error reading Organization: %s", err) - } - if err := d.Set("api_consumer_data_encryption_key_name", flattenApigeeOrganizationApiConsumerDataEncryptionKeyName(res["apiConsumerDataEncryptionKeyName"], d, config)); err != nil { - return fmt.Errorf("Error reading Organization: %s", err) - } - if err := d.Set("control_plane_encryption_key_name", flattenApigeeOrganizationControlPlaneEncryptionKeyName(res["controlPlaneEncryptionKeyName"], d, config)); err != nil { - return fmt.Errorf("Error reading Organization: %s", err) - } if err := d.Set("authorized_network", flattenApigeeOrganizationAuthorizedNetwork(res["authorizedNetwork"], d, config)); err != nil { return fmt.Errorf("Error reading Organization: %s", err) } @@ -462,24 +409,6 @@ func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("analytics_region"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, analyticsRegionProp)) { obj["analyticsRegion"] = analyticsRegionProp } - apiConsumerDataLocationProp, err := expandApigeeOrganizationApiConsumerDataLocation(d.Get("api_consumer_data_location"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("api_consumer_data_location"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, apiConsumerDataLocationProp)) { - obj["apiConsumerDataLocation"] = apiConsumerDataLocationProp - } - apiConsumerDataEncryptionKeyNameProp, err := expandApigeeOrganizationApiConsumerDataEncryptionKeyName(d.Get("api_consumer_data_encryption_key_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("api_consumer_data_encryption_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, apiConsumerDataEncryptionKeyNameProp)) { - obj["apiConsumerDataEncryptionKeyName"] = apiConsumerDataEncryptionKeyNameProp - } - controlPlaneEncryptionKeyNameProp, err := expandApigeeOrganizationControlPlaneEncryptionKeyName(d.Get("control_plane_encryption_key_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("control_plane_encryption_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, controlPlaneEncryptionKeyNameProp)) { - obj["controlPlaneEncryptionKeyName"] = controlPlaneEncryptionKeyNameProp - } authorizedNetworkProp, err := expandApigeeOrganizationAuthorizedNetwork(d.Get("authorized_network"), d, config) if err != nil { return err @@ -528,7 +457,6 @@ func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Organization %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -543,7 +471,6 @@ func resourceApigeeOrganizationUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -584,8 +511,6 @@ func resourceApigeeOrganizationDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Organization %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -595,7 +520,6 @@ func resourceApigeeOrganizationDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Organization") @@ -664,18 +588,6 @@ func flattenApigeeOrganizationAnalyticsRegion(v interface{}, d *schema.ResourceD return v } -func flattenApigeeOrganizationApiConsumerDataLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenApigeeOrganizationApiConsumerDataEncryptionKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenApigeeOrganizationControlPlaneEncryptionKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenApigeeOrganizationAuthorizedNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -722,28 +634,26 @@ func flattenApigeeOrganizationPropertiesProperty(v interface{}, d *schema.Resour return v } l := v.([]interface{}) - apiData := make([]map[string]interface{}, 0, len(l)) + transformed := make([]interface{}, 0, len(l)) for _, raw := range l { original := raw.(map[string]interface{}) if len(original) < 1 { // Do not include empty json objects coming back from the api continue } - apiData = append(apiData, map[string]interface{}{ - "name": original["name"], - "value": original["value"], + transformed = append(transformed, map[string]interface{}{ + "name": flattenApigeeOrganizationPropertiesPropertyName(original["name"], d, config), + "value": flattenApigeeOrganizationPropertiesPropertyValue(original["value"], d, config), }) } - configData := []map[string]interface{}{} - for _, item := range d.Get("properties.0.property").([]interface{}) { - configData = append(configData, item.(map[string]interface{})) - } - sorted, err := tpgresource.SortMapsByConfigOrder(configData, apiData, "name") - if err != nil { - log.Printf("[ERROR] Could not support API response for properties.0.property: %s", err) - return apiData - } - return sorted + return transformed +} +func flattenApigeeOrganizationPropertiesPropertyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenApigeeOrganizationPropertiesPropertyValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v } func flattenApigeeOrganizationApigeeProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -762,18 +672,6 @@ func expandApigeeOrganizationAnalyticsRegion(v interface{}, d tpgresource.Terraf return v, nil } -func expandApigeeOrganizationApiConsumerDataLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandApigeeOrganizationApiConsumerDataEncryptionKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandApigeeOrganizationControlPlaneEncryptionKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandApigeeOrganizationAuthorizedNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_sync_authorization.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_sync_authorization.go index e4c046f8df4..12a36558855 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_sync_authorization.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_sync_authorization.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -113,7 +112,6 @@ func resourceApigeeSyncAuthorizationCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -122,7 +120,6 @@ func resourceApigeeSyncAuthorizationCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SyncAuthorization: %s", err) @@ -159,14 +156,12 @@ func resourceApigeeSyncAuthorizationRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeSyncAuthorization %q", d.Id())) @@ -211,7 +206,6 @@ func resourceApigeeSyncAuthorizationUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating SyncAuthorization %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -226,7 +220,6 @@ func resourceApigeeSyncAuthorizationUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_target_server.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_target_server.go index 3661abbe1f4..0915bbd3025 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_target_server.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apigee/resource_apigee_target_server.go @@ -20,7 +20,6 @@ package apigee import ( "fmt" "log" - "net/http" "reflect" "time" @@ -236,7 +235,6 @@ func resourceApigeeTargetServerCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -245,7 +243,6 @@ func resourceApigeeTargetServerCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetServer: %s", err) @@ -282,14 +279,12 @@ func resourceApigeeTargetServerRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApigeeTargetServer %q", d.Id())) @@ -379,7 +374,6 @@ func resourceApigeeTargetServerUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating TargetServer %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -394,7 +388,6 @@ func resourceApigeeTargetServerUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -427,8 +420,6 @@ func resourceApigeeTargetServerDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetServer %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -438,7 +429,6 @@ func resourceApigeeTargetServerDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetServer") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go index a6765db2eb7..75f1ce3018c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_application_url_dispatch_rules.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "time" @@ -133,7 +132,6 @@ func resourceAppEngineApplicationUrlDispatchRulesCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -142,7 +140,6 @@ func resourceAppEngineApplicationUrlDispatchRulesCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { @@ -196,14 +193,12 @@ func resourceAppEngineApplicationUrlDispatchRulesRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { @@ -257,7 +252,6 @@ func resourceAppEngineApplicationUrlDispatchRulesUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating ApplicationUrlDispatchRules %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -272,7 +266,6 @@ func resourceAppEngineApplicationUrlDispatchRulesUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) @@ -327,8 +320,6 @@ func resourceAppEngineApplicationUrlDispatchRulesDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ApplicationUrlDispatchRules %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -338,7 +329,6 @@ func resourceAppEngineApplicationUrlDispatchRulesDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_domain_mapping.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_domain_mapping.go index 89fb5dc1d5b..b1e0fca842c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_domain_mapping.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_domain_mapping.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -33,6 +32,20 @@ import ( "github.com/hashicorp/terraform-provider-google/google/verify" ) +func sslSettingsDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + // If certificate id is empty, and ssl management type is `MANUAL`, then + // ssl settings will not be configured, and ssl_settings block is not returned + + if k == "ssl_settings.#" && + old == "0" && new == "1" && + d.Get("ssl_settings.0.certificate_id") == "" && + d.Get("ssl_settings.0.ssl_management_type") == "MANUAL" { + return true + } + + return false +} + func ResourceAppEngineDomainMapping() *schema.Resource { return &schema.Resource{ Create: resourceAppEngineDomainMappingCreate, @@ -70,11 +83,11 @@ By default, overrides are rejected. Default value: "STRICT" Possible values: ["S Default: "STRICT", }, "ssl_settings": { - Type: schema.TypeList, - Computed: true, - Optional: true, - Description: `SSL configuration for this domain. If unconfigured, this domain will not serve with SSL.`, - MaxItems: 1, + Type: schema.TypeList, + Optional: true, + DiffSuppressFunc: sslSettingsDiffSuppress, + Description: `SSL configuration for this domain. If unconfigured, this domain will not serve with SSL.`, + MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "ssl_management_type": { @@ -196,7 +209,6 @@ func resourceAppEngineDomainMappingCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -205,7 +217,6 @@ func resourceAppEngineDomainMappingCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DomainMapping: %s", err) @@ -231,14 +242,6 @@ func resourceAppEngineDomainMappingCreate(d *schema.ResourceData, meta interface return fmt.Errorf("Error waiting to create DomainMapping: %s", err) } - opRes, err = resourceAppEngineDomainMappingDecoder(d, meta, opRes) - if err != nil { - return fmt.Errorf("Error decoding response from operation: %s", err) - } - if opRes == nil { - return fmt.Errorf("Error decoding response from operation, could not find object") - } - if err := d.Set("name", flattenAppEngineDomainMappingName(opRes["name"], d, config)); err != nil { return err } @@ -280,31 +283,17 @@ func resourceAppEngineDomainMappingRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AppEngineDomainMapping %q", d.Id())) } - res, err = resourceAppEngineDomainMappingDecoder(d, meta, res) - if err != nil { - return err - } - - if res == nil { - // Decoding the object has resulted in it being gone. It may be marked deleted - log.Printf("[DEBUG] Removing AppEngineDomainMapping because it no longer exists.") - d.SetId("") - return nil - } - if err := d.Set("project", project); err != nil { return fmt.Errorf("Error reading DomainMapping: %s", err) } @@ -361,7 +350,6 @@ func resourceAppEngineDomainMappingUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating DomainMapping %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("ssl_settings") { @@ -390,7 +378,6 @@ func resourceAppEngineDomainMappingUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -445,8 +432,6 @@ func resourceAppEngineDomainMappingDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DomainMapping %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -456,7 +441,6 @@ func resourceAppEngineDomainMappingDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DomainMapping") @@ -611,24 +595,3 @@ func expandAppEngineDomainMappingSslSettingsPendingManagedCertificateId(v interf func expandAppEngineDomainMappingDomainName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func resourceAppEngineDomainMappingDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - // sslManagementType does not get returned with the beta endpoint. Hence, if sslSettings is set - // and sslManagementType is set, we return that value. Otherwise, we carry over the old value - // from state by calling d.Get("ssl_settings.0.ssl_management_type") - if v, ok := res["sslSettings"]; ok { - original := v.(map[string]interface{}) - if _, ok := original["sslManagementType"]; !ok { - original["sslManagementType"] = d.Get("ssl_settings.0.ssl_management_type") - } - res["sslSettings"] = original - } else { - // If ssl_settings is not set, we call d.Get("ssl_settings.0.ssl_management_type"), create sslSettings, - // and store the retrieved value in sslManagementType - transformed := make(map[string]interface{}) - transformed["sslManagementType"] = d.Get("ssl_settings.0.ssl_management_type") - res["sslSettings"] = transformed - } - - return res, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_firewall_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_firewall_rule.go index 0fc1b45af66..ac7b120144c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_firewall_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_firewall_rule.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -151,7 +150,6 @@ func resourceAppEngineFirewallRuleCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -160,7 +158,6 @@ func resourceAppEngineFirewallRuleCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FirewallRule: %s", err) @@ -250,14 +247,12 @@ func resourceAppEngineFirewallRuleRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AppEngineFirewallRule %q", d.Id())) @@ -337,7 +332,6 @@ func resourceAppEngineFirewallRuleUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating FirewallRule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -377,7 +371,6 @@ func resourceAppEngineFirewallRuleUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -425,8 +418,6 @@ func resourceAppEngineFirewallRuleDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FirewallRule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -436,7 +427,6 @@ func resourceAppEngineFirewallRuleDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FirewallRule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_flexible_app_version.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_flexible_app_version.go index 5e408e25aed..10630fac89d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_flexible_app_version.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_flexible_app_version.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "time" @@ -546,26 +545,6 @@ the configuration ID. In this case, configId must be omitted.`, Description: `Environment variables available to the application. As these are not returned in the API request, Terraform will not detect any changes made outside of the Terraform config.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "flexible_runtime_settings": { - Type: schema.TypeList, - Optional: true, - Description: `Runtime settings for App Engine flexible environment.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "operating_system": { - Type: schema.TypeString, - Optional: true, - Description: `Operating System of the application runtime.`, - }, - "runtime_version": { - Type: schema.TypeString, - Optional: true, - Description: `The runtime version of an App Engine flexible application.`, - }, - }, - }, - }, "handlers": { Type: schema.TypeList, Computed: true, @@ -948,12 +927,6 @@ func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta inte } else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(runtimeChannelProp)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) { obj["runtimeChannel"] = runtimeChannelProp } - flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(flexibleRuntimeSettingsProp)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) { - obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp - } betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config) if err != nil { return err @@ -1094,7 +1067,6 @@ func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1103,7 +1075,6 @@ func resourceAppEngineFlexibleAppVersionCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { @@ -1157,14 +1128,12 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { @@ -1210,9 +1179,6 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf if err := d.Set("runtime_channel", flattenAppEngineFlexibleAppVersionRuntimeChannel(res["runtimeChannel"], d, config)); err != nil { return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) } - if err := d.Set("flexible_runtime_settings", flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(res["flexibleRuntimeSettings"], d, config)); err != nil { - return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) - } if err := d.Set("serving_status", flattenAppEngineFlexibleAppVersionServingStatus(res["servingStatus"], d, config)); err != nil { return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) } @@ -1243,6 +1209,9 @@ func resourceAppEngineFlexibleAppVersionRead(d *schema.ResourceData, meta interf if err := d.Set("nobuild_files_regex", flattenAppEngineFlexibleAppVersionNobuildFilesRegex(res["nobuildFilesRegex"], d, config)); err != nil { return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) } + if err := d.Set("deployment", flattenAppEngineFlexibleAppVersionDeployment(res["deployment"], d, config)); err != nil { + return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) + } if err := d.Set("endpoints_api_service", flattenAppEngineFlexibleAppVersionEndpointsApiService(res["endpointsApiService"], d, config)); err != nil { return fmt.Errorf("Error reading FlexibleAppVersion: %s", err) } @@ -1317,12 +1286,6 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte } else if v, ok := d.GetOkExists("runtime_channel"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, runtimeChannelProp)) { obj["runtimeChannel"] = runtimeChannelProp } - flexibleRuntimeSettingsProp, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(d.Get("flexible_runtime_settings"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("flexible_runtime_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, flexibleRuntimeSettingsProp)) { - obj["flexibleRuntimeSettings"] = flexibleRuntimeSettingsProp - } betaSettingsProp, err := expandAppEngineFlexibleAppVersionBetaSettings(d.Get("beta_settings"), d, config) if err != nil { return err @@ -1450,7 +1413,6 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating FlexibleAppVersion %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1465,7 +1427,6 @@ func resourceAppEngineFlexibleAppVersionUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) @@ -1770,29 +1731,6 @@ func flattenAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d *schema.R return v } -func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["operating_system"] = - flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operatingSystem"], d, config) - transformed["runtime_version"] = - flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtimeVersion"], d, config) - return []interface{}{transformed} -} -func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenAppEngineFlexibleAppVersionServingStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -2078,6 +2016,61 @@ func flattenAppEngineFlexibleAppVersionNobuildFilesRegex(v interface{}, d *schem return v } +func flattenAppEngineFlexibleAppVersionDeployment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + original := v.(map[string]interface{}) + transformed := make(map[string]interface{}) + transformed["zip"] = d.Get("deployment.0.zip") + transformed["files"] = d.Get("deployment.0.files") + transformed["container"] = + flattenAppEngineFlexibleAppVersionDeploymentContainer(original["container"], d, config) + transformed["cloud_build_options"] = + flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptions(original["cloudBuildOptions"], d, config) + + return []interface{}{transformed} +} + +func flattenAppEngineFlexibleAppVersionDeploymentContainer(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["image"] = + flattenAppEngineFlexibleAppVersionDeploymentContainerImage(original["image"], d, config) + return []interface{}{transformed} +} + +func flattenAppEngineFlexibleAppVersionDeploymentContainerImage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + if v == nil { + return nil + } + original := v.(map[string]interface{}) + if len(original) == 0 { + return nil + } + transformed := make(map[string]interface{}) + transformed["app_yaml_path"] = + flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsAppYamlPath(original["appYamlPath"], d, config) + transformed["cloud_build_timeout"] = + flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsCloudBuildTimeout(original["cloudBuildTimeout"], d, config) + return []interface{}{transformed} +} + +func flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsAppYamlPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenAppEngineFlexibleAppVersionDeploymentCloudBuildOptionsCloudBuildTimeout(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenAppEngineFlexibleAppVersionEndpointsApiService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -2700,40 +2693,6 @@ func expandAppEngineFlexibleAppVersionRuntimeChannel(v interface{}, d tpgresourc return v, nil } -func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedOperatingSystem, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(original["operating_system"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOperatingSystem); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["operatingSystem"] = transformedOperatingSystem - } - - transformedRuntimeVersion, err := expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(original["runtime_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRuntimeVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["runtimeVersion"] = transformedRuntimeVersion - } - - return transformed, nil -} - -func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsOperatingSystem(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandAppEngineFlexibleAppVersionFlexibleRuntimeSettingsRuntimeVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandAppEngineFlexibleAppVersionBetaSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_network_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_network_settings.go index 7a665592dca..d536f213a63 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_network_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_network_settings.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -135,7 +134,6 @@ func resourceAppEngineServiceNetworkSettingsCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -144,7 +142,6 @@ func resourceAppEngineServiceNetworkSettingsCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServiceNetworkSettings: %s", err) @@ -197,14 +194,12 @@ func resourceAppEngineServiceNetworkSettingsRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AppEngineServiceNetworkSettings %q", d.Id())) @@ -266,7 +261,6 @@ func resourceAppEngineServiceNetworkSettingsUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating ServiceNetworkSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("service") { @@ -298,7 +292,6 @@ func resourceAppEngineServiceNetworkSettingsUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_split_traffic.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_split_traffic.go index 67dc875953f..6d11e6e5a74 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_split_traffic.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_service_split_traffic.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -145,7 +144,6 @@ func resourceAppEngineServiceSplitTrafficCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -154,7 +152,6 @@ func resourceAppEngineServiceSplitTrafficCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServiceSplitTraffic: %s", err) @@ -207,14 +204,12 @@ func resourceAppEngineServiceSplitTrafficRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("AppEngineServiceSplitTraffic %q", d.Id())) @@ -273,7 +268,6 @@ func resourceAppEngineServiceSplitTrafficUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating ServiceSplitTraffic %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("service") { @@ -305,7 +299,6 @@ func resourceAppEngineServiceSplitTrafficUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_standard_app_version.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_standard_app_version.go index abf9de07c1c..7df4504dc4e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_standard_app_version.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/appengine/resource_app_engine_standard_app_version.go @@ -20,7 +20,6 @@ package appengine import ( "fmt" "log" - "net/http" "reflect" "time" @@ -614,7 +613,6 @@ func resourceAppEngineStandardAppVersionCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -623,7 +621,6 @@ func resourceAppEngineStandardAppVersionCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { @@ -677,14 +674,12 @@ func resourceAppEngineStandardAppVersionRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) if err != nil { @@ -884,7 +879,6 @@ func resourceAppEngineStandardAppVersionUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating StandardAppVersion %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -899,7 +893,6 @@ func resourceAppEngineStandardAppVersionUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsAppEngineRetryableError}, }) @@ -1254,35 +1247,6 @@ func flattenAppEngineStandardAppVersionAutomaticScaling(v interface{}, d *schema flattenAppEngineStandardAppVersionAutomaticScalingMinPendingLatency(original["minPendingLatency"], d, config) transformed["standard_scheduler_settings"] = flattenAppEngineStandardAppVersionAutomaticScalingStandardSchedulerSettings(original["standardSchedulerSettings"], d, config) - - // begin handwritten code (all other parts of this file are forked from generated code) - // solve for the following diff when no scaling settings are configured: - // - // - automatic_scaling { - // - max_concurrent_requests = 0 -> null - // - max_idle_instances = 0 -> null - // - min_idle_instances = 0 -> null - // } - // - // this happens because the field is returned as: - // - //"automaticScaling": { - // "standardSchedulerSettings": {} - // }, - // - // this is hacky but avoids marking the field as computed, since it's in a oneof - // if any new fields are added to the block or explicit defaults start getting - // returned, it will need to be updated - if transformed["max_concurrent_requests"] == nil && // even primitives are nil at this stage if they're not returned by the API - transformed["max_idle_instances"] == nil && - transformed["max_pending_latency"] == nil && - transformed["min_idle_instances"] == nil && - transformed["min_pending_latency"] == nil && - transformed["standard_scheduler_settings"] == nil { - return nil - } - // end handwritten code - return []interface{}{transformed} } func flattenAppEngineStandardAppVersionAutomaticScalingMaxConcurrentRequests(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/data_source_apphub_application.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/data_source_apphub_application.go deleted file mode 100644 index 58e0ebf27d2..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/data_source_apphub_application.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package apphub - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func DataSourceGoogleApphubApplication() *schema.Resource { - dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceApphubApplication().Schema) - tpgresource.AddRequiredFieldsToSchema(dsSchema, "project") - tpgresource.AddRequiredFieldsToSchema(dsSchema, "application_id") - tpgresource.AddRequiredFieldsToSchema(dsSchema, "location") - - return &schema.Resource{ - Read: dataSourceGoogleApphubApplicationRead, - Schema: dsSchema, - } -} - -func dataSourceGoogleApphubApplicationRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/applications/{{application_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - err = resourceApphubApplicationRead(d, meta) - if err != nil { - return err - } - - if err := tpgresource.SetDataSourceLabels(d); err != nil { - return err - } - - if d.Id() == "" { - return fmt.Errorf("%s not found", id) - } - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_application.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_application.go index f21392ed18a..a36c6d3b150 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_application.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_application.go @@ -20,7 +20,6 @@ package apphub import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -288,7 +287,6 @@ func resourceApphubApplicationCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -297,7 +295,6 @@ func resourceApphubApplicationCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Application: %s", err) @@ -364,14 +361,12 @@ func resourceApphubApplicationRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApphubApplication %q", d.Id())) @@ -459,7 +454,6 @@ func resourceApphubApplicationUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Application %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -499,7 +493,6 @@ func resourceApphubApplicationUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -547,8 +540,6 @@ func resourceApphubApplicationDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Application %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -558,7 +549,6 @@ func resourceApphubApplicationDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Application") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service.go index 0b3c3b63c64..506392daeac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service.go @@ -20,7 +20,6 @@ package apphub import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -318,7 +317,6 @@ func resourceApphubServiceCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -327,7 +325,6 @@ func resourceApphubServiceCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Service: %s", err) @@ -394,14 +391,12 @@ func resourceApphubServiceRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApphubService %q", d.Id())) @@ -489,7 +484,6 @@ func resourceApphubServiceUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Service %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -525,7 +519,6 @@ func resourceApphubServiceUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -573,8 +566,6 @@ func resourceApphubServiceDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Service %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -584,7 +575,6 @@ func resourceApphubServiceDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Service") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service_project_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service_project_attachment.go index a5ff29e84df..56393d1e2de 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service_project_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_service_project_attachment.go @@ -20,7 +20,6 @@ package apphub import ( "fmt" "log" - "net/http" "reflect" "time" @@ -136,7 +135,6 @@ func resourceApphubServiceProjectAttachmentCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -145,7 +143,6 @@ func resourceApphubServiceProjectAttachmentCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServiceProjectAttachment: %s", err) @@ -212,14 +209,12 @@ func resourceApphubServiceProjectAttachmentRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApphubServiceProjectAttachment %q", d.Id())) @@ -275,8 +270,6 @@ func resourceApphubServiceProjectAttachmentDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServiceProjectAttachment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -286,7 +279,6 @@ func resourceApphubServiceProjectAttachmentDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServiceProjectAttachment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_workload.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_workload.go index af1c1198a09..5e78a9b007b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_workload.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/apphub/resource_apphub_workload.go @@ -20,7 +20,6 @@ package apphub import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -315,7 +314,6 @@ func resourceApphubWorkloadCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -324,7 +322,6 @@ func resourceApphubWorkloadCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Workload: %s", err) @@ -391,14 +388,12 @@ func resourceApphubWorkloadRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ApphubWorkload %q", d.Id())) @@ -486,7 +481,6 @@ func resourceApphubWorkloadUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Workload %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -522,7 +516,6 @@ func resourceApphubWorkloadUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -570,8 +563,6 @@ func resourceApphubWorkloadDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Workload %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -581,7 +572,6 @@ func resourceApphubWorkloadDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Workload") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/data_source_artifact_registry_docker_image.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/data_source_artifact_registry_docker_image.go deleted file mode 100644 index f6eea2eb1f8..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/data_source_artifact_registry_docker_image.go +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package artifactregistry - -import ( - "fmt" - "net/url" - "strings" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -// https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.dockerImages#DockerImage -type DockerImage struct { - name string - uri string - tags []string - imageSizeBytes string - mediaType string - uploadTime string - buildTime string - updateTime string -} - -func DataSourceArtifactRegistryDockerImage() *schema.Resource { - - return &schema.Resource{ - Read: DataSourceArtifactRegistryDockerImageRead, - - Schema: map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Optional: true, - Description: `Project ID of the project.`, - }, - "location": { - Type: schema.TypeString, - Required: true, - Description: `The region of the artifact registry repository. For example, "us-west1".`, - }, - "repository_id": { - Type: schema.TypeString, - Required: true, - Description: `The last part of the repository name to fetch from.`, - }, - "image_name": { - Type: schema.TypeString, - Required: true, - Description: `The image name to fetch.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The fully qualified name of the fetched image.`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - Description: `The URI to access the image.`, - }, - "tags": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: `All tags associated with the image.`, - }, - "image_size_bytes": { - Type: schema.TypeString, - Computed: true, - Description: `Calculated size of the image in bytes.`, - }, - "media_type": { - Type: schema.TypeString, - Computed: true, - Description: `Media type of this image.`, - }, - "upload_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time, as a RFC 3339 string, the image was uploaded.`, - }, - "build_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time, as a RFC 3339 string, this image was built.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time, as a RFC 3339 string, this image was updated.`, - }, - }, - } -} - -func DataSourceArtifactRegistryDockerImageRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - var res DockerImage - - imageName, tag, digest := parseImage(d.Get("image_name").(string)) - - if digest != "" { - // fetch image by digest - // https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.dockerImages/get - imageUrlSafe := url.QueryEscape(imageName) - urlRequest, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("{{ArtifactRegistryBasePath}}projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/dockerImages/%s@%s", imageUrlSafe, digest)) - if err != nil { - return fmt.Errorf("Error setting api endpoint") - } - - resGet, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: urlRequest, - UserAgent: userAgent, - }) - if err != nil { - return err - } - - res = convertResponseToStruct(resGet) - } else { - // fetch the list of images, ordered by update time - // https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.dockerImages/list - urlRequest, err := tpgresource.ReplaceVars(d, config, "{{ArtifactRegistryBasePath}}projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/dockerImages") - if err != nil { - return fmt.Errorf("Error setting api endpoint") - } - - urlRequest, err = transport_tpg.AddQueryParams(urlRequest, map[string]string{"orderBy": "update_time desc"}) - if err != nil { - return err - } - - res, err = retrieveAndFilterImages(d, config, urlRequest, userAgent, imageName, tag) - if err != nil { - return err - } - } - - // set the schema data using the response - if err := d.Set("name", res.name); err != nil { - return fmt.Errorf("Error setting name: %s", err) - } - - if err := d.Set("self_link", res.uri); err != nil { - return fmt.Errorf("Error setting self_link: %s", err) - } - - if err := d.Set("tags", res.tags); err != nil { - return fmt.Errorf("Error setting tags: %s", err) - } - - if err := d.Set("image_size_bytes", res.imageSizeBytes); err != nil { - return fmt.Errorf("Error setting image_size_bytes: %s", err) - } - - if err := d.Set("media_type", res.mediaType); err != nil { - return fmt.Errorf("Error setting media_type: %s", err) - } - - if err := d.Set("upload_time", res.uploadTime); err != nil { - return fmt.Errorf("Error setting upload_time: %s", err) - } - - if err := d.Set("build_time", res.buildTime); err != nil { - return fmt.Errorf("Error setting build_time: %s", err) - } - - if err := d.Set("update_time", res.updateTime); err != nil { - return fmt.Errorf("Error setting update_time: %s", err) - } - - id, err := tpgresource.ReplaceVars(d, config, "{{ArtifactRegistryBasePath}}projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}/dockerImages/{{image_name}}") - if err != nil { - return fmt.Errorf("Error constructing the data source id: %s", err) - } - - d.SetId(id) - - return nil -} - -func parseImage(image string) (imageName string, tag string, digest string) { - splitByAt := strings.Split(image, "@") - splitByColon := strings.Split(image, ":") - - if len(splitByAt) == 2 { - imageName = splitByAt[0] - digest = splitByAt[1] - } else if len(splitByColon) == 2 { - imageName = splitByColon[0] - tag = splitByColon[1] - } else { - imageName = image - } - - return imageName, tag, digest -} - -func retrieveAndFilterImages(d *schema.ResourceData, config *transport_tpg.Config, urlRequest string, userAgent string, imageName string, tag string) (DockerImage, error) { - // Paging through the list method until either: - // if a tag was provided, the matching image name and tag pair - // otherwise, return the first matching image name - - for { - resListImages, token, err := retrieveListOfDockerImages(config, urlRequest, userAgent) - if err != nil { - return DockerImage{}, err - } - - var resFiltered []DockerImage - for _, image := range resListImages { - if strings.Contains(image.name, "/"+url.QueryEscape(imageName)+"@") { - resFiltered = append(resFiltered, image) - } - } - - if tag != "" { - for _, image := range resFiltered { - for _, iterTag := range image.tags { - if iterTag == tag { - return image, nil - } - } - } - } else if len(resFiltered) > 0 { - return resFiltered[0], nil - } - - if token == "" { - return DockerImage{}, fmt.Errorf("Requested image was not found.") - } - - urlRequest, err = transport_tpg.AddQueryParams(urlRequest, map[string]string{"pageToken": token}) - if err != nil { - return DockerImage{}, err - } - } -} - -func retrieveListOfDockerImages(config *transport_tpg.Config, urlRequest string, userAgent string) ([]DockerImage, string, error) { - resList, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: urlRequest, - UserAgent: userAgent, - }) - if err != nil { - return make([]DockerImage, 0), "", err - } - - if nextPageToken, ok := resList["nextPageToken"].(string); ok { - return flattenDataSourceListResponse(resList), nextPageToken, nil - } else { - return flattenDataSourceListResponse(resList), "", nil - } -} - -func flattenDataSourceListResponse(res map[string]interface{}) []DockerImage { - var dockerImages []DockerImage - - resDockerImages, _ := res["dockerImages"].([]interface{}) - - for _, resImage := range resDockerImages { - image, _ := resImage.(map[string]interface{}) - dockerImages = append(dockerImages, convertResponseToStruct(image)) - } - - return dockerImages -} - -func convertResponseToStruct(res map[string]interface{}) DockerImage { - var dockerImage DockerImage - - if name, ok := res["name"].(string); ok { - dockerImage.name = name - } - - if uri, ok := res["uri"].(string); ok { - dockerImage.uri = uri - } - - if tags, ok := res["tags"].([]interface{}); ok { - var stringTags []string - - for _, tag := range tags { - strTag := tag.(string) - stringTags = append(stringTags, strTag) - } - dockerImage.tags = stringTags - } - - if imageSizeBytes, ok := res["imageSizeBytes"].(string); ok { - dockerImage.imageSizeBytes = imageSizeBytes - } - - if mediaType, ok := res["mediaType"].(string); ok { - dockerImage.mediaType = mediaType - } - - if uploadTime, ok := res["uploadTime"].(string); ok { - dockerImage.uploadTime = uploadTime - } - - if buildTime, ok := res["buildTime"].(string); ok { - dockerImage.buildTime = buildTime - } - - if updateTime, ok := res["updateTime"].(string); ok { - dockerImage.updateTime = updateTime - } - - return dockerImage -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/resource_artifact_registry_repository.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/resource_artifact_registry_repository.go index b42e0ae29b8..a699e051dbc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/resource_artifact_registry_repository.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/artifactregistry/resource_artifact_registry_repository.go @@ -20,7 +20,6 @@ package artifactregistry import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -347,12 +346,6 @@ snapshot versions.`, ForceNew: true, Description: `The description of the remote source.`, }, - "disable_upstream_validation": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, the remote repository upstream and upstream credentials will -not be validated.`, - }, "docker_repository": { Type: schema.TypeList, Optional: true, @@ -361,32 +354,14 @@ not be validated.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "custom_repository": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Settings for a remote repository with a custom uri.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "uri": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Specific uri to the registry, e.g. '"https://registry-1.docker.io"'`, - }, - }, - }, - ConflictsWith: []string{"remote_repository_config.0.docker_repository.0.public_repository"}, - }, "public_repository": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"DOCKER_HUB", ""}), - Description: `Address of the remote repository. Default value: "DOCKER_HUB" Possible values: ["DOCKER_HUB"]`, - Default: "DOCKER_HUB", - ConflictsWith: []string{"remote_repository_config.0.docker_repository.0.custom_repository"}, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"DOCKER_HUB", ""}), + Description: `Address of the remote repository. Default value: "DOCKER_HUB" Possible values: ["DOCKER_HUB"]`, + Default: "DOCKER_HUB", + ExactlyOneOf: []string{"remote_repository_config.0.docker_repository.0.public_repository"}, }, }, }, @@ -400,32 +375,14 @@ not be validated.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "custom_repository": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Settings for a remote repository with a custom uri.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "uri": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Specific uri to the registry, e.g. '"https://repo.maven.apache.org/maven2"'`, - }, - }, - }, - ConflictsWith: []string{"remote_repository_config.0.maven_repository.0.public_repository"}, - }, "public_repository": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"MAVEN_CENTRAL", ""}), - Description: `Address of the remote repository. Default value: "MAVEN_CENTRAL" Possible values: ["MAVEN_CENTRAL"]`, - Default: "MAVEN_CENTRAL", - ConflictsWith: []string{"remote_repository_config.0.maven_repository.0.custom_repository"}, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"MAVEN_CENTRAL", ""}), + Description: `Address of the remote repository. Default value: "MAVEN_CENTRAL" Possible values: ["MAVEN_CENTRAL"]`, + Default: "MAVEN_CENTRAL", + ExactlyOneOf: []string{"remote_repository_config.0.maven_repository.0.public_repository"}, }, }, }, @@ -439,32 +396,14 @@ not be validated.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "custom_repository": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Settings for a remote repository with a custom uri.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "uri": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Specific uri to the registry, e.g. '"https://registry.npmjs.org"'`, - }, - }, - }, - ConflictsWith: []string{"remote_repository_config.0.npm_repository.0.public_repository"}, - }, "public_repository": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"NPMJS", ""}), - Description: `Address of the remote repository. Default value: "NPMJS" Possible values: ["NPMJS"]`, - Default: "NPMJS", - ConflictsWith: []string{"remote_repository_config.0.npm_repository.0.custom_repository"}, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"NPMJS", ""}), + Description: `Address of the remote repository. Default value: "NPMJS" Possible values: ["NPMJS"]`, + Default: "NPMJS", + ExactlyOneOf: []string{"remote_repository_config.0.npm_repository.0.public_repository"}, }, }, }, @@ -478,32 +417,14 @@ not be validated.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "custom_repository": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Settings for a remote repository with a custom uri.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "uri": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Specific uri to the registry, e.g. '"https://pypi.io"'`, - }, - }, - }, - ConflictsWith: []string{"remote_repository_config.0.python_repository.0.public_repository"}, - }, "public_repository": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"PYPI", ""}), - Description: `Address of the remote repository. Default value: "PYPI" Possible values: ["PYPI"]`, - Default: "PYPI", - ConflictsWith: []string{"remote_repository_config.0.python_repository.0.custom_repository"}, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"PYPI", ""}), + Description: `Address of the remote repository. Default value: "PYPI" Possible values: ["PYPI"]`, + Default: "PYPI", + ExactlyOneOf: []string{"remote_repository_config.0.python_repository.0.public_repository"}, }, }, }, @@ -572,7 +493,7 @@ remote repository. Must be in the format of Type: schema.TypeString, Required: true, ForceNew: true, - Description: `Specific repository from the base, e.g. '"pub/rocky/9/BaseOS/x86_64/os"'`, + Description: `Specific repository from the base, e.g. '"centos/8-stream/BaseOS/x86_64/os"'`, }, }, }, @@ -762,25 +683,6 @@ func resourceArtifactRegistryRepositoryCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - // This file should be deleted in the next major terraform release, alongside - // the default values for 'publicRepository'. - - // deletePublicRepoIfCustom deletes the publicRepository key for a given - // pkg type from the remote repository config if customRepository is set. - deletePublicRepoIfCustom := func(pkgType string) { - if _, ok := d.GetOk(fmt.Sprintf("remote_repository_config.0.%s_repository.0.custom_repository", pkgType)); ok { - rrcfg := obj["remoteRepositoryConfig"].(map[string]interface{}) - repo := rrcfg[fmt.Sprintf("%sRepository", pkgType)].(map[string]interface{}) - delete(repo, "publicRepository") - } - } - - // Call above func for all pkg types that support custom remote repos. - deletePublicRepoIfCustom("docker") - deletePublicRepoIfCustom("maven") - deletePublicRepoIfCustom("npm") - deletePublicRepoIfCustom("python") res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -789,7 +691,6 @@ func resourceArtifactRegistryRepositoryCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Repository: %s", err) @@ -856,14 +757,12 @@ func resourceArtifactRegistryRepositoryRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ArtifactRegistryRepository %q", d.Id())) @@ -995,7 +894,6 @@ func resourceArtifactRegistryRepositoryUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating Repository %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1047,7 +945,6 @@ func resourceArtifactRegistryRepositoryUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1088,8 +985,6 @@ func resourceArtifactRegistryRepositoryDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Repository %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1099,7 +994,6 @@ func resourceArtifactRegistryRepositoryDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Repository") @@ -1409,8 +1303,6 @@ func flattenArtifactRegistryRepositoryRemoteRepositoryConfig(v interface{}, d *s flattenArtifactRegistryRepositoryRemoteRepositoryConfigYumRepository(original["yumRepository"], d, config) transformed["upstream_credentials"] = flattenArtifactRegistryRepositoryRemoteRepositoryConfigUpstreamCredentials(original["upstreamCredentials"], d, config) - transformed["disable_upstream_validation"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigDisableUpstreamValidation(original["disableUpstreamValidation"], d, config) return []interface{}{transformed} } func flattenArtifactRegistryRepositoryRemoteRepositoryConfigDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1464,32 +1356,9 @@ func flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepository(v i transformed := make(map[string]interface{}) transformed["public_repository"] = flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryPublicRepository(original["publicRepository"], d, config) - transformed["custom_repository"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepository(original["customRepository"], d, config) return []interface{}{transformed} } func flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryPublicRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil || tpgresource.IsEmptyValue(reflect.ValueOf(v)) { - return "DOCKER_HUB" - } - - return v -} - -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["uri"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepositoryUri(original["uri"], d, config) - return []interface{}{transformed} -} -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepositoryUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1504,32 +1373,9 @@ func flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepository(v in transformed := make(map[string]interface{}) transformed["public_repository"] = flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryPublicRepository(original["publicRepository"], d, config) - transformed["custom_repository"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepository(original["customRepository"], d, config) return []interface{}{transformed} } func flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryPublicRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil || tpgresource.IsEmptyValue(reflect.ValueOf(v)) { - return "MAVEN_CENTRAL" - } - - return v -} - -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["uri"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepositoryUri(original["uri"], d, config) - return []interface{}{transformed} -} -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepositoryUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1544,32 +1390,9 @@ func flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepository(v inte transformed := make(map[string]interface{}) transformed["public_repository"] = flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryPublicRepository(original["publicRepository"], d, config) - transformed["custom_repository"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepository(original["customRepository"], d, config) return []interface{}{transformed} } func flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryPublicRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil || tpgresource.IsEmptyValue(reflect.ValueOf(v)) { - return "NPMJS" - } - - return v -} - -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["uri"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepositoryUri(original["uri"], d, config) - return []interface{}{transformed} -} -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepositoryUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1584,32 +1407,9 @@ func flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepository(v i transformed := make(map[string]interface{}) transformed["public_repository"] = flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryPublicRepository(original["publicRepository"], d, config) - transformed["custom_repository"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepository(original["customRepository"], d, config) return []interface{}{transformed} } func flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryPublicRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil || tpgresource.IsEmptyValue(reflect.ValueOf(v)) { - return "PYPI" - } - - return v -} - -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["uri"] = - flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepositoryUri(original["uri"], d, config) - return []interface{}{transformed} -} -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepositoryUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1685,10 +1485,6 @@ func flattenArtifactRegistryRepositoryRemoteRepositoryConfigUpstreamCredentialsU return v } -func flattenArtifactRegistryRepositoryRemoteRepositoryConfigDisableUpstreamValidation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return d.Get("remote_repository_config.0.disable_upstream_validation") -} - func flattenArtifactRegistryRepositoryCleanupPolicyDryRun(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -2082,13 +1878,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfig(v interface{}, d tpg transformed["upstreamCredentials"] = transformedUpstreamCredentials } - transformedDisableUpstreamValidation, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigDisableUpstreamValidation(original["disable_upstream_validation"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDisableUpstreamValidation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["disableUpstreamValidation"] = transformedDisableUpstreamValidation - } - return transformed, nil } @@ -2165,13 +1954,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepository(v in transformed["publicRepository"] = transformedPublicRepository } - transformedCustomRepository, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepository(original["custom_repository"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomRepository); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customRepository"] = transformedCustomRepository - } - return transformed, nil } @@ -2179,29 +1961,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryPubli return v, nil } -func expandArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUri, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepositoryUri(original["uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["uri"] = transformedUri - } - - return transformed, nil -} - -func expandArtifactRegistryRepositoryRemoteRepositoryConfigDockerRepositoryCustomRepositoryUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2218,13 +1977,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepository(v int transformed["publicRepository"] = transformedPublicRepository } - transformedCustomRepository, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepository(original["custom_repository"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomRepository); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customRepository"] = transformedCustomRepository - } - return transformed, nil } @@ -2232,29 +1984,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryPublic return v, nil } -func expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUri, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepositoryUri(original["uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["uri"] = transformedUri - } - - return transformed, nil -} - -func expandArtifactRegistryRepositoryRemoteRepositoryConfigMavenRepositoryCustomRepositoryUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2271,13 +2000,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepository(v inter transformed["publicRepository"] = transformedPublicRepository } - transformedCustomRepository, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepository(original["custom_repository"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomRepository); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customRepository"] = transformedCustomRepository - } - return transformed, nil } @@ -2285,29 +2007,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryPublicRe return v, nil } -func expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUri, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepositoryUri(original["uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["uri"] = transformedUri - } - - return transformed, nil -} - -func expandArtifactRegistryRepositoryRemoteRepositoryConfigNpmRepositoryCustomRepositoryUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2324,13 +2023,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepository(v in transformed["publicRepository"] = transformedPublicRepository } - transformedCustomRepository, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepository(original["custom_repository"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomRepository); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customRepository"] = transformedCustomRepository - } - return transformed, nil } @@ -2338,29 +2030,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryPubli return v, nil } -func expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUri, err := expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepositoryUri(original["uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["uri"] = transformedUri - } - - return transformed, nil -} - -func expandArtifactRegistryRepositoryRemoteRepositoryConfigPythonRepositoryCustomRepositoryUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandArtifactRegistryRepositoryRemoteRepositoryConfigYumRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2467,10 +2136,6 @@ func expandArtifactRegistryRepositoryRemoteRepositoryConfigUpstreamCredentialsUs return v, nil } -func expandArtifactRegistryRepositoryRemoteRepositoryConfigDisableUpstreamValidation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandArtifactRegistryRepositoryCleanupPolicyDryRun(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connection.go index fb0542265d2..7272e14c1ea 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connection.go @@ -20,7 +20,6 @@ package beyondcorp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -147,8 +146,8 @@ Please refer to the field 'effective_labels' for all of the labels present on th Type: schema.TypeString, Optional: true, ForceNew: true, - Description: `The type of network connectivity used by the AppConnection. Refer -to https://cloud.google.com/beyondcorp/docs/reference/rest/v1/projects.locations.appConnections#type + Description: `The type of network connectivity used by the AppConnection. Refer to +https://cloud.google.com/beyondcorp/docs/reference/rest/v1/projects.locations.appConnections#type for a list of possible values.`, }, "effective_labels": { @@ -239,7 +238,6 @@ func resourceBeyondcorpAppConnectionCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -248,7 +246,6 @@ func resourceBeyondcorpAppConnectionCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AppConnection: %s", err) @@ -311,14 +308,12 @@ func resourceBeyondcorpAppConnectionRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BeyondcorpAppConnection %q", d.Id())) @@ -409,7 +404,6 @@ func resourceBeyondcorpAppConnectionUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating AppConnection %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -453,7 +447,6 @@ func resourceBeyondcorpAppConnectionUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -501,8 +494,6 @@ func resourceBeyondcorpAppConnectionDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AppConnection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -512,7 +503,6 @@ func resourceBeyondcorpAppConnectionDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AppConnection") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connector.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connector.go index 85e392c4df3..d4ef08e0e8f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connector.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_connector.go @@ -20,7 +20,6 @@ package beyondcorp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -182,7 +181,6 @@ func resourceBeyondcorpAppConnectorCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -191,7 +189,6 @@ func resourceBeyondcorpAppConnectorCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AppConnector: %s", err) @@ -254,14 +251,12 @@ func resourceBeyondcorpAppConnectorRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BeyondcorpAppConnector %q", d.Id())) @@ -334,7 +329,6 @@ func resourceBeyondcorpAppConnectorUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating AppConnector %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -370,7 +364,6 @@ func resourceBeyondcorpAppConnectorUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -418,8 +411,6 @@ func resourceBeyondcorpAppConnectorDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AppConnector %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -429,7 +420,6 @@ func resourceBeyondcorpAppConnectorDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AppConnector") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_gateway.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_gateway.go index 4b0b570abec..f3b9dc4dbb1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_gateway.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/beyondcorp/resource_beyondcorp_app_gateway.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -215,7 +214,6 @@ func resourceBeyondcorpAppGatewayCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -224,7 +222,6 @@ func resourceBeyondcorpAppGatewayCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AppGateway: %s", err) @@ -287,14 +284,12 @@ func resourceBeyondcorpAppGatewayRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BeyondcorpAppGateway %q", d.Id())) @@ -367,8 +362,6 @@ func resourceBeyondcorpAppGatewayDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AppGateway %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -378,7 +371,6 @@ func resourceBeyondcorpAppGatewayDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AppGateway") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_catalog.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_catalog.go index 5c8c459c8e3..a4a04840f2d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_catalog.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_catalog.go @@ -20,7 +20,6 @@ package biglake import ( "fmt" "log" - "net/http" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -131,7 +130,6 @@ func resourceBiglakeCatalogCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -140,7 +138,6 @@ func resourceBiglakeCatalogCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Catalog: %s", err) @@ -183,14 +180,12 @@ func resourceBiglakeCatalogRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BiglakeCatalog %q", d.Id())) @@ -243,8 +238,6 @@ func resourceBiglakeCatalogDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Catalog %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -254,7 +247,6 @@ func resourceBiglakeCatalogDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Catalog") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_database.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_database.go index 41334da655e..6fe03d61373 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_database.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_database.go @@ -20,7 +20,6 @@ package biglake import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -160,7 +159,6 @@ func resourceBiglakeDatabaseCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -169,7 +167,6 @@ func resourceBiglakeDatabaseCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Database: %s", err) @@ -206,14 +203,12 @@ func resourceBiglakeDatabaseRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BiglakeDatabase %q", d.Id())) @@ -270,7 +265,6 @@ func resourceBiglakeDatabaseUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Database %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("type") { @@ -302,7 +296,6 @@ func resourceBiglakeDatabaseUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -337,8 +330,6 @@ func resourceBiglakeDatabaseDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Database %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -348,7 +339,6 @@ func resourceBiglakeDatabaseDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Database") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_table.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_table.go index 9e0c202d929..898d3c806f0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_table.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/biglake/resource_biglake_table.go @@ -20,7 +20,6 @@ package biglake import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -196,7 +195,6 @@ func resourceBiglakeTableCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -205,7 +203,6 @@ func resourceBiglakeTableCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Table: %s", err) @@ -242,14 +239,12 @@ func resourceBiglakeTableRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BiglakeTable %q", d.Id())) @@ -309,7 +304,6 @@ func resourceBiglakeTableUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Table %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("type") { @@ -341,7 +335,6 @@ func resourceBiglakeTableUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -376,8 +369,6 @@ func resourceBiglakeTableDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Table %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -387,7 +378,6 @@ func resourceBiglakeTableDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Table") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset.go index 25091dd07ea..04a5d0e723c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset.go @@ -20,7 +20,6 @@ package bigquery import ( "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -177,30 +176,6 @@ expiration time indicated by this property.`, Optional: true, Description: `A user-friendly description of the dataset`, }, - "external_dataset_reference": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Information about the external metadata storage where the dataset is defined.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "connection": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The connection id that is used to access the externalSource. -Format: projects/{projectId}/locations/{locationId}/connections/{connectionId}`, - }, - "external_source": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `External source that backs this dataset.`, - }, - }, - }, - }, "friendly_name": { Type: schema.TypeString, Optional: true, @@ -514,12 +489,6 @@ func resourceBigQueryDatasetCreate(d *schema.ResourceData, meta interface{}) err } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } - externalDatasetReferenceProp, err := expandBigQueryDatasetExternalDatasetReference(d.Get("external_dataset_reference"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("external_dataset_reference"); !tpgresource.IsEmptyValue(reflect.ValueOf(externalDatasetReferenceProp)) && (ok || !reflect.DeepEqual(v, externalDatasetReferenceProp)) { - obj["externalDatasetReference"] = externalDatasetReferenceProp - } friendlyNameProp, err := expandBigQueryDatasetFriendlyName(d.Get("friendly_name"), d, config) if err != nil { return err @@ -582,7 +551,6 @@ func resourceBigQueryDatasetCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -591,7 +559,6 @@ func resourceBigQueryDatasetCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Dataset: %s", err) @@ -634,14 +601,12 @@ func resourceBigQueryDatasetRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigQueryDataset %q", d.Id())) @@ -693,9 +658,6 @@ func resourceBigQueryDatasetRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("etag", flattenBigQueryDatasetEtag(res["etag"], d, config)); err != nil { return fmt.Errorf("Error reading Dataset: %s", err) } - if err := d.Set("external_dataset_reference", flattenBigQueryDatasetExternalDatasetReference(res["externalDatasetReference"], d, config)); err != nil { - return fmt.Errorf("Error reading Dataset: %s", err) - } if err := d.Set("friendly_name", flattenBigQueryDatasetFriendlyName(res["friendlyName"], d, config)); err != nil { return fmt.Errorf("Error reading Dataset: %s", err) } @@ -785,12 +747,6 @@ func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) err } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } - externalDatasetReferenceProp, err := expandBigQueryDatasetExternalDatasetReference(d.Get("external_dataset_reference"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("external_dataset_reference"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, externalDatasetReferenceProp)) { - obj["externalDatasetReference"] = externalDatasetReferenceProp - } friendlyNameProp, err := expandBigQueryDatasetFriendlyName(d.Get("friendly_name"), d, config) if err != nil { return err @@ -840,7 +796,6 @@ func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Dataset %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -855,7 +810,6 @@ func resourceBigQueryDatasetUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -894,8 +848,6 @@ func resourceBigQueryDatasetDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Dataset %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -905,7 +857,6 @@ func resourceBigQueryDatasetDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Dataset") @@ -1170,29 +1121,6 @@ func flattenBigQueryDatasetEtag(v interface{}, d *schema.ResourceData, config *t return v } -func flattenBigQueryDatasetExternalDatasetReference(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["external_source"] = - flattenBigQueryDatasetExternalDatasetReferenceExternalSource(original["externalSource"], d, config) - transformed["connection"] = - flattenBigQueryDatasetExternalDatasetReferenceConnection(original["connection"], d, config) - return []interface{}{transformed} -} -func flattenBigQueryDatasetExternalDatasetReferenceExternalSource(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenBigQueryDatasetExternalDatasetReferenceConnection(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenBigQueryDatasetFriendlyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1576,40 +1504,6 @@ func expandBigQueryDatasetDescription(v interface{}, d tpgresource.TerraformReso return v, nil } -func expandBigQueryDatasetExternalDatasetReference(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExternalSource, err := expandBigQueryDatasetExternalDatasetReferenceExternalSource(original["external_source"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExternalSource); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["externalSource"] = transformedExternalSource - } - - transformedConnection, err := expandBigQueryDatasetExternalDatasetReferenceConnection(original["connection"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConnection); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["connection"] = transformedConnection - } - - return transformed, nil -} - -func expandBigQueryDatasetExternalDatasetReferenceExternalSource(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandBigQueryDatasetExternalDatasetReferenceConnection(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandBigQueryDatasetFriendlyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset_access.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset_access.go index f1d0d08644c..509105cd604 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset_access.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_dataset_access.go @@ -20,7 +20,6 @@ package bigquery import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -471,7 +470,6 @@ func resourceBigQueryDatasetAccessCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -480,7 +478,6 @@ func resourceBigQueryDatasetAccessCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsBigqueryIAMQuotaError}, }) if err != nil { @@ -552,14 +549,12 @@ func resourceBigQueryDatasetAccessRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsBigqueryIAMQuotaError}, }) if err != nil { @@ -652,8 +647,6 @@ func resourceBigQueryDatasetAccessDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DatasetAccess %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -663,7 +656,6 @@ func resourceBigQueryDatasetAccessDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsBigqueryIAMQuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_job.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_job.go index 94c7c797367..4fc80cf8e36 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_job.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_job.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -1059,7 +1058,6 @@ func resourceBigQueryJobCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1068,7 +1066,6 @@ func resourceBigQueryJobCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Job: %s", err) @@ -1158,14 +1155,12 @@ func resourceBigQueryJobRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigQueryJob %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_routine.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_routine.go index 6ad9adc0ff2..e66a51d81bf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_routine.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_routine.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "time" @@ -125,12 +124,6 @@ the schema as returned by the API.`, }, }, }, - "data_governance_type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"DATA_MASKING", ""}), - Description: `If set to DATA_MASKING, the function is validated and made available as a masking function. For more information, see https://cloud.google.com/bigquery/docs/user-defined-functions#custom-mask Possible values: ["DATA_MASKING"]`, - }, "description": { Type: schema.TypeString, Optional: true, @@ -399,12 +392,6 @@ func resourceBigQueryRoutineCreate(d *schema.ResourceData, meta interface{}) err } else if v, ok := d.GetOkExists("determinism_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(determinismLevelProp)) && (ok || !reflect.DeepEqual(v, determinismLevelProp)) { obj["determinismLevel"] = determinismLevelProp } - dataGovernanceTypeProp, err := expandBigQueryRoutineDataGovernanceType(d.Get("data_governance_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("data_governance_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(dataGovernanceTypeProp)) && (ok || !reflect.DeepEqual(v, dataGovernanceTypeProp)) { - obj["dataGovernanceType"] = dataGovernanceTypeProp - } sparkOptionsProp, err := expandBigQueryRoutineSparkOptions(d.Get("spark_options"), d, config) if err != nil { return err @@ -437,7 +424,6 @@ func resourceBigQueryRoutineCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -446,7 +432,6 @@ func resourceBigQueryRoutineCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Routine: %s", err) @@ -489,14 +474,12 @@ func resourceBigQueryRoutineRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigQueryRoutine %q", d.Id())) @@ -554,9 +537,6 @@ func resourceBigQueryRoutineRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("determinism_level", flattenBigQueryRoutineDeterminismLevel(res["determinismLevel"], d, config)); err != nil { return fmt.Errorf("Error reading Routine: %s", err) } - if err := d.Set("data_governance_type", flattenBigQueryRoutineDataGovernanceType(res["dataGovernanceType"], d, config)); err != nil { - return fmt.Errorf("Error reading Routine: %s", err) - } if err := d.Set("spark_options", flattenBigQueryRoutineSparkOptions(res["sparkOptions"], d, config)); err != nil { return fmt.Errorf("Error reading Routine: %s", err) } @@ -643,12 +623,6 @@ func resourceBigQueryRoutineUpdate(d *schema.ResourceData, meta interface{}) err } else if v, ok := d.GetOkExists("determinism_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, determinismLevelProp)) { obj["determinismLevel"] = determinismLevelProp } - dataGovernanceTypeProp, err := expandBigQueryRoutineDataGovernanceType(d.Get("data_governance_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("data_governance_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dataGovernanceTypeProp)) { - obj["dataGovernanceType"] = dataGovernanceTypeProp - } sparkOptionsProp, err := expandBigQueryRoutineSparkOptions(d.Get("spark_options"), d, config) if err != nil { return err @@ -668,7 +642,6 @@ func resourceBigQueryRoutineUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Routine %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -683,7 +656,6 @@ func resourceBigQueryRoutineUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -722,8 +694,6 @@ func resourceBigQueryRoutineDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Routine %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -733,7 +703,6 @@ func resourceBigQueryRoutineDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Routine") @@ -913,10 +882,6 @@ func flattenBigQueryRoutineDeterminismLevel(v interface{}, d *schema.ResourceDat return v } -func flattenBigQueryRoutineDataGovernanceType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenBigQueryRoutineSparkOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1149,10 +1114,6 @@ func expandBigQueryRoutineDeterminismLevel(v interface{}, d tpgresource.Terrafor return v, nil } -func expandBigQueryRoutineDataGovernanceType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandBigQueryRoutineSparkOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_table.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_table.go index f046c4966ef..8ed2de978da 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_table.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquery/resource_bigquery_table.go @@ -258,17 +258,19 @@ func bigQueryTableNormalizePolicyTags(val interface{}) interface{} { // Compares two existing schema implementations and decides if // it is changeable.. pairs with a force new on not changeable -func resourceBigQueryTableSchemaIsChangeable(old, new interface{}, isExternalTable bool, topLevel bool) (bool, error) { +func resourceBigQueryTableSchemaIsChangeable(old, new interface{}) (bool, error) { switch old.(type) { case []interface{}: arrayOld := old.([]interface{}) arrayNew, ok := new.([]interface{}) - sameNameColumns := 0 - droppedColumns := 0 if !ok { // if not both arrays not changeable return false, nil } + if len(arrayOld) > len(arrayNew) { + // if not growing not changeable + return false, nil + } if err := bigQueryTablecheckNameExists(arrayOld); err != nil { return false, err } @@ -289,28 +291,16 @@ func resourceBigQueryTableSchemaIsChangeable(old, new interface{}, isExternalTab } } for key := range mapOld { - // dropping top level columns can happen in-place - // but this doesn't apply to external tables + // all old keys should be represented in the new config if _, ok := mapNew[key]; !ok { - if !topLevel || isExternalTable { - return false, nil - } - droppedColumns += 1 - continue + return false, nil } - - isChangable, err := resourceBigQueryTableSchemaIsChangeable(mapOld[key], mapNew[key], isExternalTable, false) - if err != nil || !isChangable { + if isChangable, err := + resourceBigQueryTableSchemaIsChangeable(mapOld[key], mapNew[key]); err != nil || !isChangable { return false, err - } else if isChangable && topLevel { - // top level column that exists in the new schema - sameNameColumns += 1 } } - // in-place column dropping alongside column additions is not allowed - // as of now because user intention can be ambiguous (e.g. column renaming) - newColumns := len(arrayNew) - sameNameColumns - return (droppedColumns == 0) || (newColumns == 0), nil + return true, nil case map[string]interface{}: objectOld := old.(map[string]interface{}) objectNew, ok := new.(map[string]interface{}) @@ -349,7 +339,7 @@ func resourceBigQueryTableSchemaIsChangeable(old, new interface{}, isExternalTab return false, nil } case "fields": - return resourceBigQueryTableSchemaIsChangeable(valOld, valNew, isExternalTable, false) + return resourceBigQueryTableSchemaIsChangeable(valOld, valNew) // other parameters: description, policyTags and // policyTags.names[] are changeable @@ -388,8 +378,7 @@ func resourceBigQueryTableSchemaCustomizeDiffFunc(d tpgresource.TerraformResourc // same as above log.Printf("[DEBUG] unable to unmarshal json customized diff - %v", err) } - _, isExternalTable := d.GetOk("external_data_configuration") - isChangeable, err := resourceBigQueryTableSchemaIsChangeable(old, new, isExternalTable, true) + isChangeable, err := resourceBigQueryTableSchemaIsChangeable(old, new) if err != nil { return err } @@ -515,7 +504,7 @@ func ResourceBigQueryTable() *schema.Resource { "source_format": { Type: schema.TypeString, Optional: true, - Description: `Please see sourceFormat under ExternalDataConfiguration in Bigquery's public API documentation (https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#externaldataconfiguration) for supported formats. To use "GOOGLE_SHEETS" the scopes must include "googleapis.com/auth/drive.readonly".`, + Description: ` Please see sourceFormat under ExternalDataConfiguration in Bigquery's public API documentation (https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#externaldataconfiguration) for supported formats. To use "GOOGLE_SHEETS" the scopes must include "googleapis.com/auth/drive.readonly".`, ValidateFunc: validation.StringInSlice([]string{ "CSV", "GOOGLE_SHEETS", "NEWLINE_DELIMITED_JSON", "AVRO", "ICEBERG", "DATASTORE_BACKUP", "PARQUET", "ORC", "BIGTABLE", }, false), @@ -621,7 +610,7 @@ func ResourceBigQueryTable() *schema.Resource { Type: schema.TypeList, Optional: true, MaxItems: 1, - Description: `Additional properties to set if sourceFormat is set to JSON.`, + Description: `Additional properties to set if sourceFormat is set to JSON."`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "encoding": { @@ -635,112 +624,11 @@ func ResourceBigQueryTable() *schema.Resource { }, }, - "json_extension": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{"GEOJSON"}, false), - Description: `Load option to be used together with sourceFormat newline-delimited JSON to indicate that a variant of JSON is being loaded. To load newline-delimited GeoJSON, specify GEOJSON (and sourceFormat must be set to NEWLINE_DELIMITED_JSON).`, - }, - - "bigtable_options": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Description: `Additional options if sourceFormat is set to BIGTABLE.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column_family": { - Type: schema.TypeList, - Optional: true, - Description: `A list of column families to expose in the table schema along with their types. This list restricts the column families that can be referenced in queries and specifies their value types. You can use this list to do type conversions - see the 'type' field for more details. If you leave this list empty, all column families are present in the table schema and their values are read as BYTES. During a query only the column families referenced in that query are read from Bigtable.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "column": { - Type: schema.TypeList, - Optional: true, - Description: `A List of columns that should be exposed as individual fields as opposed to a list of (column name, value) pairs. All columns whose qualifier matches a qualifier in this list can be accessed as Other columns can be accessed as a list through column field`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "qualifier_encoded": { - Type: schema.TypeString, - Optional: true, - Description: `Qualifier of the column. Columns in the parent column family that has this exact qualifier are exposed as . field. If the qualifier is valid UTF-8 string, it can be specified in the qualifierString field. Otherwise, a base-64 encoded value must be set to qualifierEncoded. The column field name is the same as the column qualifier. However, if the qualifier is not a valid BigQuery field identifier i.e. does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as fieldName.`, - }, - "qualifier_string": { - Type: schema.TypeString, - Optional: true, - Description: `Qualifier string.`, - }, - "field_name": { - Type: schema.TypeString, - Optional: true, - Description: `If the qualifier is not a valid BigQuery field identifier i.e. does not match [a-zA-Z][a-zA-Z0-9_]*, a valid identifier must be provided as the column field name and is used as field name in queries.`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: `The type to convert the value in cells of this column. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive): "BYTES", "STRING", "INTEGER", "FLOAT", "BOOLEAN", "JSON", Default type is "BYTES". 'type' can also be set at the column family level. However, the setting at this level takes precedence if 'type' is set at both levels.`, - }, - "encoding": { - Type: schema.TypeString, - Optional: true, - Description: `The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. 'encoding' can also be set at the column family level. However, the setting at this level takes precedence if 'encoding' is set at both levels.`, - }, - "only_read_latest": { - Type: schema.TypeBool, - Optional: true, - Description: `If this is set, only the latest version of value in this column are exposed. 'onlyReadLatest' can also be set at the column family level. However, the setting at this level takes precedence if 'onlyReadLatest' is set at both levels.`, - }, - }, - }, - }, - "family_id": { - Type: schema.TypeString, - Optional: true, - Description: `Identifier of the column family.`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: `The type to convert the value in cells of this column family. The values are expected to be encoded using HBase Bytes.toBytes function when using the BINARY encoding value. Following BigQuery types are allowed (case-sensitive): "BYTES", "STRING", "INTEGER", "FLOAT", "BOOLEAN", "JSON". Default type is BYTES. This can be overridden for a specific column by listing that column in 'columns' and specifying a type for it.`, - }, - "encoding": { - Type: schema.TypeString, - Optional: true, - Description: `The encoding of the values when the type is not STRING. Acceptable encoding values are: TEXT - indicates values are alphanumeric text strings. BINARY - indicates values are encoded using HBase Bytes.toBytes family of functions. This can be overridden for a specific column by listing that column in 'columns' and specifying an encoding for it.`, - }, - "only_read_latest": { - Type: schema.TypeBool, - Optional: true, - Description: `If this is set only the latest version of value are exposed for all columns in this column family. This can be overridden for a specific column by listing that column in 'columns' and specifying a different setting for that column.`, - }, - }, - }, - }, - "ignore_unspecified_column_families": { - Type: schema.TypeBool, - Optional: true, - Description: `If field is true, then the column families that are not specified in columnFamilies list are not exposed in the table schema. Otherwise, they are read with BYTES type values. The default value is false.`, - }, - "read_rowkey_as_string": { - Type: schema.TypeBool, - Optional: true, - Description: `If field is true, then the rowkey column families will be read and converted to string. Otherwise they are read with BYTES type values and users need to manually cast them with CAST if necessary. The default value is false.`, - }, - "output_column_families_as_json": { - Type: schema.TypeBool, - Optional: true, - Description: `If field is true, then each column family will be read as a single JSON column. Otherwise they are read as a repeated cell structure containing timestamp/value tuples. The default value is false.`, - }, - }, - }, - }, - "parquet_options": { Type: schema.TypeList, Optional: true, MaxItems: 1, - Description: `Additional properties to set if sourceFormat is set to PARQUET.`, + Description: `Additional properties to set if sourceFormat is set to PARQUET."`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enum_as_string": { @@ -769,7 +657,7 @@ func ResourceBigQueryTable() *schema.Resource { "range": { Type: schema.TypeString, Optional: true, - Description: `Range of a sheet to query from. Only used when non-empty. At least one of range or skip_leading_rows must be set. Typical format: "sheet_name!top_left_cell_id:bottom_right_cell_id" For example: "sheet1!A1:B20`, + Description: `Range of a sheet to query from. Only used when non-empty. At least one of range or skip_leading_rows must be set. Typical format: "sheet_name!top_left_cell_id:bottom_right_cell_id" For example: "sheet1!A1:B20"`, AtLeastOneOf: []string{ "external_data_configuration.0.google_sheets_options.0.skip_leading_rows", "external_data_configuration.0.google_sheets_options.0.range", @@ -1249,7 +1137,7 @@ func ResourceBigQueryTable() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: true, - Description: `Whether Terraform will be prevented from destroying the instance. When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the table will fail. When the field is set to false, deleting the table is allowed.`, + Description: `Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail.`, }, // TableConstraints: [Optional] Defines the primary key and foreign keys. @@ -1817,12 +1705,6 @@ func resourceBigQueryTableRead(d *schema.ResourceData, meta interface{}) error { return nil } -type TableReference struct { - project string - datasetID string - tableID string -} - func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -1845,16 +1727,6 @@ func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error datasetID := d.Get("dataset_id").(string) tableID := d.Get("table_id").(string) - tableReference := &TableReference{ - project: project, - datasetID: datasetID, - tableID: tableID, - } - - if err = resourceBigQueryTableColumnDrop(config, userAgent, table, tableReference); err != nil { - return err - } - if _, err = config.NewBigQueryClient(userAgent).Tables.Update(project, datasetID, tableID, table).Do(); err != nil { return err } @@ -1862,52 +1734,9 @@ func resourceBigQueryTableUpdate(d *schema.ResourceData, meta interface{}) error return resourceBigQueryTableRead(d, meta) } -func resourceBigQueryTableColumnDrop(config *transport_tpg.Config, userAgent string, table *bigquery.Table, tableReference *TableReference) error { - oldTable, err := config.NewBigQueryClient(userAgent).Tables.Get(tableReference.project, tableReference.datasetID, tableReference.tableID).Do() - if err != nil { - return err - } - - if table.Schema == nil { - return nil - } - - newTableFields := map[string]bool{} - for _, field := range table.Schema.Fields { - newTableFields[field.Name] = true - } - - droppedColumns := []string{} - for _, field := range oldTable.Schema.Fields { - if !newTableFields[field.Name] { - droppedColumns = append(droppedColumns, field.Name) - } - } - - if len(droppedColumns) > 0 { - droppedColumnsString := strings.Join(droppedColumns, ", DROP COLUMN ") - - dropColumnsDDL := fmt.Sprintf("ALTER TABLE `%s.%s.%s` DROP COLUMN %s", tableReference.project, tableReference.datasetID, tableReference.tableID, droppedColumnsString) - log.Printf("[INFO] Dropping columns in-place: %s", dropColumnsDDL) - - useLegacySQL := false - req := &bigquery.QueryRequest{ - Query: dropColumnsDDL, - UseLegacySql: &useLegacySQL, - } - - _, err = config.NewBigQueryClient(userAgent).Jobs.Query(tableReference.project, req).Do() - if err != nil { - return err - } - } - - return nil -} - func resourceBigQueryTableDelete(d *schema.ResourceData, meta interface{}) error { if d.Get("deletion_protection").(bool) { - return fmt.Errorf("cannot destroy table %v without setting deletion_protection=false and running `terraform apply`", d.Id()) + return fmt.Errorf("cannot destroy instance without setting deletion_protection=false and running `terraform apply`") } config := meta.(*transport_tpg.Config) userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -1957,19 +1786,12 @@ func expandExternalDataConfiguration(cfg interface{}) (*bigquery.ExternalDataCon edc.Compression = v.(string) } - if v, ok := raw["json_extension"]; ok { - edc.JsonExtension = v.(string) - } - if v, ok := raw["csv_options"]; ok { edc.CsvOptions = expandCsvOptions(v) } if v, ok := raw["json_options"]; ok { edc.JsonOptions = expandJsonOptions(v) } - if v, ok := raw["bigtable_options"]; ok { - edc.BigtableOptions = expandBigtableOptions(v) - } if v, ok := raw["google_sheets_options"]; ok { edc.GoogleSheetsOptions = expandGoogleSheetsOptions(v) } @@ -2031,10 +1853,6 @@ func flattenExternalDataConfiguration(edc *bigquery.ExternalDataConfiguration) ( result["compression"] = edc.Compression } - if edc.JsonExtension != "" { - result["json_extension"] = edc.JsonExtension - } - if edc.CsvOptions != nil { result["csv_options"] = flattenCsvOptions(edc.CsvOptions) } @@ -2059,10 +1877,6 @@ func flattenExternalDataConfiguration(edc *bigquery.ExternalDataConfiguration) ( result["json_options"] = flattenJsonOptions(edc.JsonOptions) } - if edc.BigtableOptions != nil { - result["bigtable_options"] = flattenBigtableOptions(edc.BigtableOptions) - } - if edc.IgnoreUnknownValues { result["ignore_unknown_values"] = edc.IgnoreUnknownValues } @@ -2293,164 +2107,6 @@ func flattenParquetOptions(opts *bigquery.ParquetOptions) []map[string]interface return []map[string]interface{}{result} } -func expandBigtableOptions(configured interface{}) *bigquery.BigtableOptions { - if len(configured.([]interface{})) == 0 { - return nil - } - - raw := configured.([]interface{})[0].(map[string]interface{}) - opts := &bigquery.BigtableOptions{} - - crs := []*bigquery.BigtableColumnFamily{} - if v, ok := raw["column_family"]; ok { - for _, columnFamily := range v.([]interface{}) { - crs = append(crs, expandBigtableColumnFamily(columnFamily)) - } - - if len(crs) > 0 { - opts.ColumnFamilies = crs - } - } - - if v, ok := raw["ignore_unspecified_column_families"]; ok { - opts.IgnoreUnspecifiedColumnFamilies = v.(bool) - } - - if v, ok := raw["read_rowkey_as_string"]; ok { - opts.ReadRowkeyAsString = v.(bool) - } - - if v, ok := raw["output_column_families_as_json"]; ok { - opts.OutputColumnFamiliesAsJson = v.(bool) - } - - return opts -} - -func flattenBigtableOptions(opts *bigquery.BigtableOptions) []map[string]interface{} { - result := map[string]interface{}{} - - if opts.ColumnFamilies != nil { - result["column_family"] = flattenBigtableColumnFamily(opts.ColumnFamilies) - } - - if opts.IgnoreUnspecifiedColumnFamilies { - result["ignore_unspecified_column_families"] = opts.IgnoreUnspecifiedColumnFamilies - } - - if opts.ReadRowkeyAsString { - result["read_rowkey_as_string"] = opts.ReadRowkeyAsString - } - - if opts.OutputColumnFamiliesAsJson { - result["output_column_families_as_json"] = opts.OutputColumnFamiliesAsJson - } - - return []map[string]interface{}{result} -} - -func expandBigtableColumnFamily(configured interface{}) *bigquery.BigtableColumnFamily { - raw := configured.(map[string]interface{}) - - opts := &bigquery.BigtableColumnFamily{} - - crs := []*bigquery.BigtableColumn{} - if v, ok := raw["column"]; ok { - for _, column := range v.([]interface{}) { - crs = append(crs, expandBigtableColumn(column)) - } - - if len(crs) > 0 { - opts.Columns = crs - } - } - - if v, ok := raw["family_id"]; ok { - opts.FamilyId = v.(string) - } - - if v, ok := raw["type"]; ok { - opts.Type = v.(string) - } - - if v, ok := raw["encoding"]; ok { - opts.Encoding = v.(string) - } - - if v, ok := raw["only_read_latest"]; ok { - opts.OnlyReadLatest = v.(bool) - } - - return opts -} - -func flattenBigtableColumnFamily(edc []*bigquery.BigtableColumnFamily) []map[string]interface{} { - results := []map[string]interface{}{} - - for _, fr := range edc { - result := map[string]interface{}{} - if fr.Columns != nil { - result["column"] = flattenBigtableColumn(fr.Columns) - } - result["family_id"] = fr.FamilyId - result["type"] = fr.Type - result["encoding"] = fr.Encoding - result["only_read_latest"] = fr.OnlyReadLatest - results = append(results, result) - } - - return results -} - -func expandBigtableColumn(configured interface{}) *bigquery.BigtableColumn { - raw := configured.(map[string]interface{}) - - opts := &bigquery.BigtableColumn{} - - if v, ok := raw["qualifier_encoded"]; ok { - opts.QualifierEncoded = v.(string) - } - - if v, ok := raw["qualifier_string"]; ok { - opts.QualifierString = v.(string) - } - - if v, ok := raw["field_name"]; ok { - opts.FieldName = v.(string) - } - - if v, ok := raw["type"]; ok { - opts.Type = v.(string) - } - - if v, ok := raw["encoding"]; ok { - opts.Encoding = v.(string) - } - - if v, ok := raw["only_read_latest"]; ok { - opts.OnlyReadLatest = v.(bool) - } - - return opts -} - -func flattenBigtableColumn(edc []*bigquery.BigtableColumn) []map[string]interface{} { - results := []map[string]interface{}{} - - for _, fr := range edc { - result := map[string]interface{}{} - result["qualifier_encoded"] = fr.QualifierEncoded - result["qualifier_string"] = fr.QualifierString - result["field_name"] = fr.FieldName - result["type"] = fr.Type - result["encoding"] = fr.Encoding - result["only_read_latest"] = fr.OnlyReadLatest - results = append(results, result) - } - - return results -} - func expandJsonOptions(configured interface{}) *bigquery.JsonOptions { if len(configured.([]interface{})) == 0 { return nil @@ -2686,11 +2342,6 @@ func expandPrimaryKey(configured interface{}) *bigquery.TableConstraintsPrimaryK columns := []string{} for _, rawColumn := range raw["columns"].([]interface{}) { - if rawColumn == nil { - // Terraform reads "" as nil, which ends up crashing when we cast below - // sending "" to the API triggers a 400, which is okay. - rawColumn = "" - } columns = append(columns, rawColumn.(string)) } if len(columns) > 0 { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go index c7403b2a37e..d1c8721a782 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_data_exchange.go @@ -20,7 +20,6 @@ package bigqueryanalyticshub import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -171,7 +170,6 @@ func resourceBigqueryAnalyticsHubDataExchangeCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -180,7 +178,6 @@ func resourceBigqueryAnalyticsHubDataExchangeCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DataExchange: %s", err) @@ -226,14 +223,12 @@ func resourceBigqueryAnalyticsHubDataExchangeRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryAnalyticsHubDataExchange %q", d.Id())) @@ -321,7 +316,6 @@ func resourceBigqueryAnalyticsHubDataExchangeUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating DataExchange %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -365,7 +359,6 @@ func resourceBigqueryAnalyticsHubDataExchangeUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -406,8 +399,6 @@ func resourceBigqueryAnalyticsHubDataExchangeDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DataExchange %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -417,7 +408,6 @@ func resourceBigqueryAnalyticsHubDataExchangeDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DataExchange") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go index 1b2584bbc25..e0f0b05c736 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryanalyticshub/resource_bigquery_analytics_hub_listing.go @@ -20,7 +20,6 @@ package bigqueryanalyticshub import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -296,7 +295,6 @@ func resourceBigqueryAnalyticsHubListingCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -305,7 +303,6 @@ func resourceBigqueryAnalyticsHubListingCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Listing: %s", err) @@ -351,14 +348,12 @@ func resourceBigqueryAnalyticsHubListingRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryAnalyticsHubListing %q", d.Id())) @@ -497,7 +492,6 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating Listing %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -565,7 +559,6 @@ func resourceBigqueryAnalyticsHubListingUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -606,8 +599,6 @@ func resourceBigqueryAnalyticsHubListingDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Listing %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -617,7 +608,6 @@ func resourceBigqueryAnalyticsHubListingDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Listing") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryconnection/resource_bigquery_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryconnection/resource_bigquery_connection.go index 9f5b877e3ee..cea7eb67aa6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryconnection/resource_bigquery_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryconnection/resource_bigquery_connection.go @@ -20,7 +20,6 @@ package bigqueryconnection import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -263,13 +262,6 @@ func ResourceBigqueryConnectionConnection() *schema.Resource { Optional: true, Description: `A descriptive name for the connection`, }, - "kms_key_name": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. The Cloud KMS key that is used for encryption. - -Example: projects/[kms_project_id]/locations/[region]/keyRings/[key_region]/cryptoKeys/[key]`, - }, "location": { Type: schema.TypeString, Optional: true, @@ -376,12 +368,6 @@ func resourceBigqueryConnectionConnectionCreate(d *schema.ResourceData, meta int } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } - kmsKeyNameProp, err := expandBigqueryConnectionConnectionKmsKeyName(d.Get("kms_key_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("kms_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(kmsKeyNameProp)) && (ok || !reflect.DeepEqual(v, kmsKeyNameProp)) { - obj["kmsKeyName"] = kmsKeyNameProp - } cloudSqlProp, err := expandBigqueryConnectionConnectionCloudSql(d.Get("cloud_sql"), d, config) if err != nil { return err @@ -443,7 +429,6 @@ func resourceBigqueryConnectionConnectionCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -452,7 +437,6 @@ func resourceBigqueryConnectionConnectionCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Connection: %s", err) @@ -513,14 +497,12 @@ func resourceBigqueryConnectionConnectionRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryConnectionConnection %q", d.Id())) @@ -545,9 +527,6 @@ func resourceBigqueryConnectionConnectionRead(d *schema.ResourceData, meta inter if err := d.Set("has_credential", flattenBigqueryConnectionConnectionHasCredential(res["hasCredential"], d, config)); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } - if err := d.Set("kms_key_name", flattenBigqueryConnectionConnectionKmsKeyName(res["kmsKeyName"], d, config)); err != nil { - return fmt.Errorf("Error reading Connection: %s", err) - } if err := d.Set("cloud_sql", flattenBigqueryConnectionConnectionCloudSql(res["cloudSql"], d, config)); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } @@ -598,12 +577,6 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } - kmsKeyNameProp, err := expandBigqueryConnectionConnectionKmsKeyName(d.Get("kms_key_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("kms_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, kmsKeyNameProp)) { - obj["kmsKeyName"] = kmsKeyNameProp - } cloudSqlProp, err := expandBigqueryConnectionConnectionCloudSql(d.Get("cloud_sql"), d, config) if err != nil { return err @@ -652,7 +625,6 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating Connection %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("friendly_name") { @@ -663,10 +635,6 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int updateMask = append(updateMask, "description") } - if d.HasChange("kms_key_name") { - updateMask = append(updateMask, "kmsKeyName") - } - if d.HasChange("cloud_sql") { updateMask = append(updateMask, "cloudSql") } @@ -713,7 +681,6 @@ func resourceBigqueryConnectionConnectionUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -754,8 +721,6 @@ func resourceBigqueryConnectionConnectionDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Connection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -765,7 +730,6 @@ func resourceBigqueryConnectionConnectionDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Connection") @@ -816,10 +780,6 @@ func flattenBigqueryConnectionConnectionHasCredential(v interface{}, d *schema.R return v } -func flattenBigqueryConnectionConnectionKmsKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenBigqueryConnectionConnectionCloudSql(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1099,10 +1059,6 @@ func expandBigqueryConnectionConnectionDescription(v interface{}, d tpgresource. return v, nil } -func expandBigqueryConnectionConnectionKmsKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandBigqueryConnectionConnectionCloudSql(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go index 788cc466033..15d6bfeaf78 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatapolicy/resource_bigquery_datapolicy_data_policy.go @@ -20,7 +20,6 @@ package bigquerydatapolicy import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -88,17 +87,9 @@ func ResourceBigqueryDatapolicyDataPolicy() *schema.Resource { Schema: map[string]*schema.Schema{ "predefined_expression": { Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE", "LAST_FOUR_CHARACTERS", "FIRST_FOUR_CHARACTERS", "EMAIL_MASK", "DATE_YEAR_MASK", ""}), + Required: true, + ValidateFunc: verify.ValidateEnum([]string{"SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE", "LAST_FOUR_CHARACTERS", "FIRST_FOUR_CHARACTERS", "EMAIL_MASK", "DATE_YEAR_MASK"}), Description: `The available masking rules. Learn more here: https://cloud.google.com/bigquery/docs/column-data-masking-intro#masking_options. Possible values: ["SHA256", "ALWAYS_NULL", "DEFAULT_MASKING_VALUE", "LAST_FOUR_CHARACTERS", "FIRST_FOUR_CHARACTERS", "EMAIL_MASK", "DATE_YEAR_MASK"]`, - ExactlyOneOf: []string{"data_masking_policy.0.predefined_expression", "data_masking_policy.0.routine"}, - }, - "routine": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `The name of the BigQuery routine that contains the custom masking routine, in the format of projects/{projectNumber}/datasets/{dataset_id}/routines/{routine_id}.`, - ExactlyOneOf: []string{"data_masking_policy.0.predefined_expression", "data_masking_policy.0.routine"}, }, }, }, @@ -171,7 +162,6 @@ func resourceBigqueryDatapolicyDataPolicyCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -180,7 +170,6 @@ func resourceBigqueryDatapolicyDataPolicyCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DataPolicy: %s", err) @@ -226,14 +215,12 @@ func resourceBigqueryDatapolicyDataPolicyRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryDatapolicyDataPolicy %q", d.Id())) @@ -303,7 +290,6 @@ func resourceBigqueryDatapolicyDataPolicyUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating DataPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("policy_tag") { @@ -339,7 +325,6 @@ func resourceBigqueryDatapolicyDataPolicyUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -380,8 +365,6 @@ func resourceBigqueryDatapolicyDataPolicyDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DataPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -391,7 +374,6 @@ func resourceBigqueryDatapolicyDataPolicyDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DataPolicy") @@ -448,18 +430,12 @@ func flattenBigqueryDatapolicyDataPolicyDataMaskingPolicy(v interface{}, d *sche transformed := make(map[string]interface{}) transformed["predefined_expression"] = flattenBigqueryDatapolicyDataPolicyDataMaskingPolicyPredefinedExpression(original["predefinedExpression"], d, config) - transformed["routine"] = - flattenBigqueryDatapolicyDataPolicyDataMaskingPolicyRoutine(original["routine"], d, config) return []interface{}{transformed} } func flattenBigqueryDatapolicyDataPolicyDataMaskingPolicyPredefinedExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenBigqueryDatapolicyDataPolicyDataMaskingPolicyRoutine(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandBigqueryDatapolicyDataPolicyDataPolicyId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -488,20 +464,9 @@ func expandBigqueryDatapolicyDataPolicyDataMaskingPolicy(v interface{}, d tpgres transformed["predefinedExpression"] = transformedPredefinedExpression } - transformedRoutine, err := expandBigqueryDatapolicyDataPolicyDataMaskingPolicyRoutine(original["routine"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRoutine); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["routine"] = transformedRoutine - } - return transformed, nil } func expandBigqueryDatapolicyDataPolicyDataMaskingPolicyPredefinedExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func expandBigqueryDatapolicyDataPolicyDataMaskingPolicyRoutine(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go index dbb72787078..5e3d2f0e012 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigquerydatatransfer/resource_bigquery_data_transfer_config.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -199,8 +198,7 @@ of valid format: 1st,3rd monday of month 15:30, every wed,fri of jan, jun 13:15, and first sunday of quarter 00:00. See more explanation about the format here: https://cloud.google.com/appengine/docs/flexible/python/scheduling-jobs-with-cron-yaml#the_schedule_format -NOTE: The minimum interval time between recurring transfers depends -on the data source; refer to the documentation for your data source.`, +NOTE: the granularity should be at least 8 hours, or less frequent.`, }, "schedule_options": { Type: schema.TypeList, @@ -384,7 +382,6 @@ func resourceBigqueryDataTransferConfigCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -393,7 +390,6 @@ func resourceBigqueryDataTransferConfigCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IamMemberMissing}, }) if err != nil { @@ -458,14 +454,12 @@ func resourceBigqueryDataTransferConfigRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IamMemberMissing}, }) if err != nil { @@ -607,7 +601,6 @@ func resourceBigqueryDataTransferConfigUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating Config %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if v, ok := d.GetOk("service_account_name"); ok { if v != nil && d.HasChange("service_account_name") { @@ -662,7 +655,6 @@ func resourceBigqueryDataTransferConfigUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IamMemberMissing}, }) @@ -702,8 +694,6 @@ func resourceBigqueryDataTransferConfigDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Config %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -713,7 +703,6 @@ func resourceBigqueryDataTransferConfigDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IamMemberMissing}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go index e21387f1b9b..60ce8daf5fc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_bi_reservation.go @@ -20,7 +20,6 @@ package bigqueryreservation import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -152,7 +151,6 @@ func resourceBigqueryReservationBiReservationCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) updateMask := []string{} if d.HasChange("size") { @@ -176,7 +174,6 @@ func resourceBigqueryReservationBiReservationCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BiReservation: %s", err) @@ -222,14 +219,12 @@ func resourceBigqueryReservationBiReservationRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryReservationBiReservation %q", d.Id())) @@ -290,7 +285,6 @@ func resourceBigqueryReservationBiReservationUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating BiReservation %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("size") { @@ -322,7 +316,6 @@ func resourceBigqueryReservationBiReservationUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go index d0ec6d43bcb..99146a77c4d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_capacity_commitment.go @@ -20,7 +20,6 @@ package bigqueryreservation import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -190,7 +189,6 @@ func resourceBigqueryReservationCapacityCommitmentCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -199,7 +197,6 @@ func resourceBigqueryReservationCapacityCommitmentCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CapacityCommitment: %s", err) @@ -245,14 +242,12 @@ func resourceBigqueryReservationCapacityCommitmentRead(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryReservationCapacityCommitment %q", d.Id())) @@ -325,7 +320,6 @@ func resourceBigqueryReservationCapacityCommitmentUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating CapacityCommitment %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("plan") { @@ -357,7 +351,6 @@ func resourceBigqueryReservationCapacityCommitmentUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -398,8 +391,6 @@ func resourceBigqueryReservationCapacityCommitmentDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CapacityCommitment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -409,7 +400,6 @@ func resourceBigqueryReservationCapacityCommitmentDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CapacityCommitment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation.go index 4aef47f680a..123eb747a84 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation.go @@ -20,7 +20,6 @@ package bigqueryreservation import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -196,7 +195,6 @@ func resourceBigqueryReservationReservationCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -205,7 +203,6 @@ func resourceBigqueryReservationReservationCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Reservation: %s", err) @@ -248,14 +245,12 @@ func resourceBigqueryReservationReservationRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryReservationReservation %q", d.Id())) @@ -340,7 +335,6 @@ func resourceBigqueryReservationReservationUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating Reservation %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("slot_capacity") { @@ -384,7 +378,6 @@ func resourceBigqueryReservationReservationUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -425,8 +418,6 @@ func resourceBigqueryReservationReservationDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Reservation %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -436,7 +427,6 @@ func resourceBigqueryReservationReservationDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Reservation") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go index 16d7113bb4a..2e38f072c29 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment.go @@ -3,51 +3,52 @@ // ---------------------------------------------------------------------------- // -// *** AUTO GENERATED CODE *** Type: MMv1 *** +// *** AUTO GENERATED CODE *** Type: DCL *** // // ---------------------------------------------------------------------------- // -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. +// This file is managed by Magic Modules (https://github.com/GoogleCloudPlatform/magic-modules) +// and is based on the DCL (https://github.com/GoogleCloudPlatform/declarative-resource-client-library). +// Changes will need to be made to the DCL or Magic Modules instead of here. // -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. +// We are not currently able to accept contributions to this file. If changes +// are required, please file an issue at https://github.com/hashicorp/terraform-provider-google/issues/new/choose // // ---------------------------------------------------------------------------- package bigqueryreservation import ( + "context" "fmt" "log" - "net/http" - "reflect" - "regexp" - "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + bigqueryreservation "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation" + + "github.com/hashicorp/terraform-provider-google/google/tpgdclresource" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" ) -func ResourceBigqueryReservationReservationAssignment() *schema.Resource { +func ResourceBigqueryReservationAssignment() *schema.Resource { return &schema.Resource{ - Create: resourceBigqueryReservationReservationAssignmentCreate, - Read: resourceBigqueryReservationReservationAssignmentRead, - Delete: resourceBigqueryReservationReservationAssignmentDelete, + Create: resourceBigqueryReservationAssignmentCreate, + Read: resourceBigqueryReservationAssignmentRead, + Delete: resourceBigqueryReservationAssignmentDelete, Importer: &schema.ResourceImporter{ - State: resourceBigqueryReservationReservationAssignmentImport, + State: resourceBigqueryReservationAssignmentImport, }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), }, - CustomizeDiff: customdiff.All( tpgresource.DefaultProviderProject, ), @@ -58,264 +59,230 @@ func ResourceBigqueryReservationReservationAssignment() *schema.Resource { Required: true, ForceNew: true, DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The resource which will use the reservation. E.g. projects/myproject, folders/123, organizations/456.`, + Description: "The resource which will use the reservation. E.g. projects/myproject, folders/123, organizations/456.", }, + "job_type": { Type: schema.TypeString, Required: true, ForceNew: true, - Description: `Types of job, which could be specified when using the reservation. Possible values: JOB_TYPE_UNSPECIFIED, PIPELINE, QUERY`, + Description: "Types of job, which could be specified when using the reservation. Possible values: JOB_TYPE_UNSPECIFIED, PIPELINE, QUERY", }, + "reservation": { Type: schema.TypeString, Required: true, ForceNew: true, DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The reservation for the resource`, + Description: "The reservation for the resource", }, + "location": { Type: schema.TypeString, Computed: true, Optional: true, ForceNew: true, - Description: `The location for the resource`, + Description: "The location for the resource", + }, + + "project": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + Description: "The project for the resource", }, + "name": { Type: schema.TypeString, Computed: true, - Description: `Output only. The resource name of the assignment.`, + Description: "Output only. The resource name of the assignment.", }, + "state": { - Type: schema.TypeString, - Computed: true, - Description: `Assignment will remain in PENDING state if no active capacity commitment is present. It will become ACTIVE when some capacity commitment becomes active. -Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, + Type: schema.TypeString, + Computed: true, + Description: "Assignment will remain in PENDING state if no active capacity commitment is present. It will become ACTIVE when some capacity commitment becomes active. Possible values: STATE_UNSPECIFIED, PENDING, ACTIVE", }, }, - UseJSONNumber: true, } } -func resourceBigqueryReservationReservationAssignmentCreate(d *schema.ResourceData, meta interface{}) error { +func resourceBigqueryReservationAssignmentCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + project, err := tpgresource.GetProject(d, config) if err != nil { return err } - obj := make(map[string]interface{}) - assigneeProp, err := expandNestedBigqueryReservationReservationAssignmentAssignee(d.Get("assignee"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("assignee"); !tpgresource.IsEmptyValue(reflect.ValueOf(assigneeProp)) && (ok || !reflect.DeepEqual(v, assigneeProp)) { - obj["assignee"] = assigneeProp - } - jobTypeProp, err := expandNestedBigqueryReservationReservationAssignmentJobType(d.Get("job_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("job_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(jobTypeProp)) && (ok || !reflect.DeepEqual(v, jobTypeProp)) { - obj["jobType"] = jobTypeProp + obj := &bigqueryreservation.Assignment{ + Assignee: dcl.String(d.Get("assignee").(string)), + JobType: bigqueryreservation.AssignmentJobTypeEnumRef(d.Get("job_type").(string)), + Reservation: dcl.String(d.Get("reservation").(string)), + Location: dcl.StringOrNil(d.Get("location").(string)), + Project: dcl.String(project), } - url, err := tpgresource.ReplaceVarsForId(d, config, "{{BigqueryReservationBasePath}}projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments") + id, err := obj.ID() if err != nil { - return err + return fmt.Errorf("error constructing id: %s", err) } - - log.Printf("[DEBUG] Creating new ReservationAssignment: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) + d.SetId(id) + directive := tpgdclresource.CreateDirective + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { - return fmt.Errorf("Error fetching project for ReservationAssignment: %s", err) + return err } - billingProject = strings.TrimPrefix(project, "projects/") - + billingProject := project // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - if _, ok := d.GetOkExists("location"); !ok { - // Extract location from parent reservation. - reservation := d.Get("reservation").(string) - - tableRef := regexp.MustCompile("projects/(.+)/locations/(.+)/reservations/(.+)") - if parts := tableRef.FindStringSubmatch(reservation); parts != nil { - err := d.Set("location", parts[2]) - if err != nil { - return err - } - } - - if strings.Contains(url, "locations//") { - // re-compute url now that location must be set - url = strings.ReplaceAll(url, "/locations//", "/locations/"+d.Get("location").(string)+"/") - if err != nil { - return err - } - } + client := transport_tpg.NewDCLBigqueryReservationClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutCreate)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ReservationAssignment: %s", err) + res, err := client.ApplyAssignment(context.Background(), obj, directive...) + + if _, ok := err.(dcl.DiffAfterApplyError); ok { + log.Printf("[DEBUG] Diff after apply returned from the DCL: %s", err) + } else if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error creating Assignment: %s", err) } - if err := d.Set("name", flattenNestedBigqueryReservationReservationAssignmentName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) + + if err = d.Set("name", res.Name); err != nil { + return fmt.Errorf("error setting name in state: %s", err) } + // ID has a server-generated value, set again after creation. - // Store the ID now - id, err := tpgresource.ReplaceVarsForId(d, config, "projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}") + id, err = res.ID() if err != nil { - return fmt.Errorf("Error constructing id: %s", err) + return fmt.Errorf("error constructing id: %s", err) } d.SetId(id) - log.Printf("[DEBUG] Finished creating ReservationAssignment %q: %#v", d.Id(), res) + log.Printf("[DEBUG] Finished creating Assignment %q: %#v", d.Id(), res) - return resourceBigqueryReservationReservationAssignmentRead(d, meta) + return resourceBigqueryReservationAssignmentRead(d, meta) } -func resourceBigqueryReservationReservationAssignmentRead(d *schema.ResourceData, meta interface{}) error { +func resourceBigqueryReservationAssignmentRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + project, err := tpgresource.GetProject(d, config) if err != nil { return err } - url, err := tpgresource.ReplaceVarsForId(d, config, "{{BigqueryReservationBasePath}}projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments") - if err != nil { - return err + obj := &bigqueryreservation.Assignment{ + Assignee: dcl.String(d.Get("assignee").(string)), + JobType: bigqueryreservation.AssignmentJobTypeEnumRef(d.Get("job_type").(string)), + Reservation: dcl.String(d.Get("reservation").(string)), + Location: dcl.StringOrNil(d.Get("location").(string)), + Project: dcl.String(project), + Name: dcl.StringOrNil(d.Get("name").(string)), } - billingProject := "" - - project, err := tpgresource.GetProject(d, config) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { - return fmt.Errorf("Error fetching project for ReservationAssignment: %s", err) + return err } - billingProject = strings.TrimPrefix(project, "projects/") - + billingProject := project // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigqueryReservationReservationAssignment %q", d.Id())) + client := transport_tpg.NewDCLBigqueryReservationClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutRead)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } - - res, err = flattenNestedBigqueryReservationReservationAssignment(d, meta, res) + res, err := client.GetAssignment(context.Background(), obj) if err != nil { - return err + resourceName := fmt.Sprintf("BigqueryReservationAssignment %q", d.Id()) + return tpgdclresource.HandleNotFoundDCLError(err, d, resourceName) } - if res == nil { - // Object isn't there any more - remove it from the state. - log.Printf("[DEBUG] Removing BigqueryReservationReservationAssignment because it couldn't be matched.") - d.SetId("") - return nil + if err = d.Set("assignee", res.Assignee); err != nil { + return fmt.Errorf("error setting assignee in state: %s", err) } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading ReservationAssignment: %s", err) + if err = d.Set("job_type", res.JobType); err != nil { + return fmt.Errorf("error setting job_type in state: %s", err) } - - if err := d.Set("name", flattenNestedBigqueryReservationReservationAssignmentName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading ReservationAssignment: %s", err) + if err = d.Set("reservation", res.Reservation); err != nil { + return fmt.Errorf("error setting reservation in state: %s", err) + } + if err = d.Set("location", res.Location); err != nil { + return fmt.Errorf("error setting location in state: %s", err) } - if err := d.Set("assignee", flattenNestedBigqueryReservationReservationAssignmentAssignee(res["assignee"], d, config)); err != nil { - return fmt.Errorf("Error reading ReservationAssignment: %s", err) + if err = d.Set("project", res.Project); err != nil { + return fmt.Errorf("error setting project in state: %s", err) } - if err := d.Set("job_type", flattenNestedBigqueryReservationReservationAssignmentJobType(res["jobType"], d, config)); err != nil { - return fmt.Errorf("Error reading ReservationAssignment: %s", err) + if err = d.Set("name", res.Name); err != nil { + return fmt.Errorf("error setting name in state: %s", err) } - if err := d.Set("state", flattenNestedBigqueryReservationReservationAssignmentState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading ReservationAssignment: %s", err) + if err = d.Set("state", res.State); err != nil { + return fmt.Errorf("error setting state in state: %s", err) } return nil } -func resourceBigqueryReservationReservationAssignmentDelete(d *schema.ResourceData, meta interface{}) error { +func resourceBigqueryReservationAssignmentDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + project, err := tpgresource.GetProject(d, config) if err != nil { return err } - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ReservationAssignment: %s", err) + obj := &bigqueryreservation.Assignment{ + Assignee: dcl.String(d.Get("assignee").(string)), + JobType: bigqueryreservation.AssignmentJobTypeEnumRef(d.Get("job_type").(string)), + Reservation: dcl.String(d.Get("reservation").(string)), + Location: dcl.StringOrNil(d.Get("location").(string)), + Project: dcl.String(project), + Name: dcl.StringOrNil(d.Get("name").(string)), } - billingProject = strings.TrimPrefix(project, "projects/") - url, err := tpgresource.ReplaceVarsForId(d, config, "{{BigqueryReservationBasePath}}projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}") + log.Printf("[DEBUG] Deleting Assignment %q", d.Id()) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err } - - var obj map[string]interface{} - + billingProject := project // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting ReservationAssignment %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ReservationAssignment") + client := transport_tpg.NewDCLBigqueryReservationClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutDelete)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp + } + if err := client.DeleteAssignment(context.Background(), obj); err != nil { + return fmt.Errorf("Error deleting Assignment: %s", err) } - log.Printf("[DEBUG] Finished deleting ReservationAssignment %q: %#v", d.Id(), res) + log.Printf("[DEBUG] Finished deleting Assignment %q", d.Id()) return nil } -func resourceBigqueryReservationReservationAssignmentImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourceBigqueryReservationAssignmentImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { config := meta.(*transport_tpg.Config) + if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/reservations/(?P[^/]+)/assignments/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", + "projects/(?P[^/]+)/locations/(?P[^/]+)/reservations/(?P[^/]+)/assignments/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", }, d, config); err != nil { return nil, err } @@ -329,79 +296,3 @@ func resourceBigqueryReservationReservationAssignmentImport(d *schema.ResourceDa return []*schema.ResourceData{d}, nil } - -func flattenNestedBigqueryReservationReservationAssignmentName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenNestedBigqueryReservationReservationAssignmentAssignee(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNestedBigqueryReservationReservationAssignmentJobType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNestedBigqueryReservationReservationAssignmentState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNestedBigqueryReservationReservationAssignmentAssignee(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNestedBigqueryReservationReservationAssignmentJobType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func flattenNestedBigqueryReservationReservationAssignment(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - var v interface{} - var ok bool - - v, ok = res["assignments"] - if !ok || v == nil { - return nil, nil - } - - switch v.(type) { - case []interface{}: - break - case map[string]interface{}: - // Construct list out of single nested resource - v = []interface{}{v} - default: - return nil, fmt.Errorf("expected list or map for value assignments. Actual value: %v", v) - } - - _, item, err := resourceBigqueryReservationReservationAssignmentFindNestedObjectInList(d, meta, v.([]interface{})) - if err != nil { - return nil, err - } - return item, nil -} - -func resourceBigqueryReservationReservationAssignmentFindNestedObjectInList(d *schema.ResourceData, meta interface{}, items []interface{}) (index int, item map[string]interface{}, err error) { - expectedName := d.Get("name") - expectedFlattenedName := flattenNestedBigqueryReservationReservationAssignmentName(expectedName, d, meta.(*transport_tpg.Config)) - - // Search list for this resource. - for idx, itemRaw := range items { - if itemRaw == nil { - continue - } - item := itemRaw.(map[string]interface{}) - - itemName := flattenNestedBigqueryReservationReservationAssignmentName(item["name"], d, meta.(*transport_tpg.Config)) - // IsEmptyValue check so that if one is nil and the other is "", that's considered a match - if !(tpgresource.IsEmptyValue(reflect.ValueOf(itemName)) && tpgresource.IsEmptyValue(reflect.ValueOf(expectedFlattenedName))) && !reflect.DeepEqual(itemName, expectedFlattenedName) { - log.Printf("[DEBUG] Skipping item with name= %#v, looking for %#v)", itemName, expectedFlattenedName) - continue - } - log.Printf("[DEBUG] Found item for resource %q: %#v)", d.Id(), item) - return idx, item, nil - } - return -1, nil, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_sweeper.go deleted file mode 100644 index 2b6c223605c..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigqueryreservation/resource_bigquery_reservation_assignment_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package bigqueryreservation - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("BigqueryReservationReservationAssignment", testSweepBigqueryReservationReservationAssignment) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepBigqueryReservationReservationAssignment(region string) error { - resourceName := "BigqueryReservationReservationAssignment" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://bigqueryreservation.googleapis.com/v1/projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["assignments"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://bigqueryreservation.googleapis.com/v1/projects/{{project}}/locations/{{location}}/reservations/{{reservation}}/assignments/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_app_profile.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_app_profile.go index 6cf3dfd41e8..621aa9691d6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_app_profile.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_app_profile.go @@ -20,7 +20,6 @@ package bigtable import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -209,7 +208,6 @@ func resourceBigtableAppProfileCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -218,7 +216,6 @@ func resourceBigtableAppProfileCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AppProfile: %s", err) @@ -264,14 +261,12 @@ func resourceBigtableAppProfileRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BigtableAppProfile %q", d.Id())) @@ -352,7 +347,6 @@ func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating AppProfile %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -418,7 +412,6 @@ func resourceBigtableAppProfileUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -459,8 +452,6 @@ func resourceBigtableAppProfileDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AppProfile %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -470,7 +461,6 @@ func resourceBigtableAppProfileDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AppProfile") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_authorized_view.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_authorized_view.go deleted file mode 100644 index 77b8950554b..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_authorized_view.go +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package bigtable - -import ( - "context" - "encoding/base64" - "fmt" - "log" - "reflect" - "time" - - "cloud.google.com/go/bigtable" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -var familySubsetSchemaElem *schema.Resource = &schema.Resource{ - Schema: map[string]*schema.Schema{ - "family_name": { - Type: schema.TypeString, - Required: true, - Description: `Name of the column family to be included in the authorized view.`, - }, - "qualifiers": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: `Base64-encoded individual exact column qualifiers of the column family to be included in the authorized view.`, - }, - "qualifier_prefixes": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: `Base64-encoded prefixes for qualifiers of the column family to be included in the authorized view. Every qualifier starting with one of these prefixes is included in the authorized view. To provide access to all qualifiers, include the empty string as a prefix ("").`, - }, - }, -} - -func ResourceBigtableAuthorizedView() *schema.Resource { - return &schema.Resource{ - Create: resourceBigtableAuthorizedViewCreate, - Read: resourceBigtableAuthorizedViewRead, - Update: resourceBigtableAuthorizedViewUpdate, - Delete: resourceBigtableAuthorizedViewDestroy, - - Importer: &schema.ResourceImporter{ - State: resourceBigtableAuthorizedViewImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the authorized view. Must be 1-50 characters and must only contain hyphens, underscores, periods, letters and numbers.`, - }, - - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, - }, - - "instance_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareResourceNames, - Description: `The name of the Bigtable instance in which the authorized view belongs.`, - }, - - "table_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareResourceNames, - Description: `The name of the Bigtable table in which the authorized view belongs.`, - }, - - "deletion_protection": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: validation.StringInSlice([]string{"PROTECTED", "UNPROTECTED"}, false), - Description: `A field to make the authorized view protected against data loss i.e. when set to PROTECTED, deleting the authorized view, the table containing the authorized view, and the instance containing the authorized view would be prohibited. -If not provided, currently deletion protection will be set to UNPROTECTED as it is the API default value. Note this field configs the deletion protection provided by the API in the backend, and should not be confused with Terraform-side deletion protection.`, - }, - - "subset_view": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Description: `An AuthorizedView permitting access to an explicit subset of a Table.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "row_prefixes": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: `Base64-encoded row prefixes to be included in the authorized view. To provide access to all rows, include the empty string as a prefix ("").`, - }, - "family_subsets": { - Type: schema.TypeSet, - Optional: true, - Description: `Subsets of column families to be included in the authorized view.`, - Elem: familySubsetSchemaElem, - }, - }, - }, - }, - }, - UseJSONNumber: true, - } -} - -func resourceBigtableAuthorizedViewCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - ctx := context.Background() - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - - instanceName := tpgresource.GetResourceNameFromSelfLink(d.Get("instance_name").(string)) - c, err := config.BigTableClientFactory(userAgent).NewAdminClient(project, instanceName) - if err != nil { - return fmt.Errorf("Error starting admin client. %s", err) - } - if err := d.Set("instance_name", instanceName); err != nil { - return fmt.Errorf("Error setting instance_name: %s", err) - } - - defer c.Close() - - authorizedViewId := d.Get("name").(string) - tableId := d.Get("table_name").(string) - authorizedViewConf := bigtable.AuthorizedViewConf{ - AuthorizedViewID: authorizedViewId, - TableID: tableId, - } - - // Check if deletion protection is given - // If not given, currently tblConf.DeletionProtection will be set to false in the API - deletionProtection := d.Get("deletion_protection") - if deletionProtection == "PROTECTED" { - authorizedViewConf.DeletionProtection = bigtable.Protected - } else if deletionProtection == "UNPROTECTED" { - authorizedViewConf.DeletionProtection = bigtable.Unprotected - } - - subsetView, ok := d.GetOk("subset_view") - if !ok || len(subsetView.([]interface{})) != 1 { - return fmt.Errorf("subset_view must be specified for authorized view %s", authorizedViewId) - } - subsetViewConf, err := generateSubsetViewConfig(subsetView.([]interface{})) - if err != nil { - return err - } - authorizedViewConf.AuthorizedView = subsetViewConf - - ctxWithTimeout, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutCreate)) - defer cancel() // Always call cancel. - err = c.CreateAuthorizedView(ctxWithTimeout, &authorizedViewConf) - if err != nil { - return fmt.Errorf("Error creating authorized view. %s", err) - } - - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/instances/{{instance_name}}/tables/{{table_name}}/authorizedViews/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return resourceBigtableAuthorizedViewRead(d, meta) -} - -func resourceBigtableAuthorizedViewRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - ctx := context.Background() - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - - instanceName := tpgresource.GetResourceNameFromSelfLink(d.Get("instance_name").(string)) - c, err := config.BigTableClientFactory(userAgent).NewAdminClient(project, instanceName) - if err != nil { - return fmt.Errorf("Error starting admin client. %s", err) - } - - defer c.Close() - - authorizedViewId := d.Get("name").(string) - tableId := d.Get("table_name").(string) - authorizedViewInfo, err := c.AuthorizedViewInfo(ctx, tableId, authorizedViewId) - if err != nil { - if tpgresource.IsNotFoundGrpcError(err) { - log.Printf("[WARN] Removing %s because it's gone", authorizedViewId) - d.SetId("") - return nil - } - return err - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error setting project: %s", err) - } - - deletionProtection := authorizedViewInfo.DeletionProtection - if deletionProtection == bigtable.Protected { - if err := d.Set("deletion_protection", "PROTECTED"); err != nil { - return fmt.Errorf("Error setting deletion_protection: %s", err) - } - } else if deletionProtection == bigtable.Unprotected { - if err := d.Set("deletion_protection", "UNPROTECTED"); err != nil { - return fmt.Errorf("Error setting deletion_protection: %s", err) - } - } else { - return fmt.Errorf("Error setting deletion_protection, it should be either PROTECTED or UNPROTECTED") - } - - if sv, ok := authorizedViewInfo.AuthorizedView.(*bigtable.SubsetViewInfo); ok { - subsetView := flattenSubsetViewInfo(sv) - if err := d.Set("subset_view", subsetView); err != nil { - return fmt.Errorf("Error setting subset_view: %s", err) - } - } else { - return fmt.Errorf("Error parsing server returned subset_view since it's empty") - } - - return nil -} - -func resourceBigtableAuthorizedViewUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - ctx := context.Background() - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - - instanceName := tpgresource.GetResourceNameFromSelfLink(d.Get("instance_name").(string)) - c, err := config.BigTableClientFactory(userAgent).NewAdminClient(project, instanceName) - if err != nil { - return fmt.Errorf("Error starting admin client. %s", err) - } - defer c.Close() - - authorizedViewId := d.Get("name").(string) - tableId := d.Get("table_name").(string) - authorizedViewConf := bigtable.AuthorizedViewConf{ - AuthorizedViewID: authorizedViewId, - TableID: tableId, - } - - if d.HasChange("subset_view") { - subsetView := d.Get("subset_view") - if len(subsetView.([]interface{})) != 1 { - return fmt.Errorf("subset_view must be specified for authorized view %s", authorizedViewId) - } - subsetViewConf, err := generateSubsetViewConfig(subsetView.([]interface{})) - if err != nil { - return err - } - authorizedViewConf.AuthorizedView = subsetViewConf - } - - if d.HasChange("deletion_protection") { - deletionProtection := d.Get("deletion_protection") - if deletionProtection == "PROTECTED" { - authorizedViewConf.DeletionProtection = bigtable.Protected - } else if deletionProtection == "UNPROTECTED" { - authorizedViewConf.DeletionProtection = bigtable.Unprotected - } - } - - updateAuthorizedViewConf := bigtable.UpdateAuthorizedViewConf{ - AuthorizedViewConf: authorizedViewConf, - IgnoreWarnings: true, - } - - ctxWithTimeout, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutUpdate)) - defer cancel() // Always call cancel. - err = c.UpdateAuthorizedView(ctxWithTimeout, updateAuthorizedViewConf) - if err != nil { - return fmt.Errorf("Error updating authorized view. %s", err) - } - - return resourceBigtableAuthorizedViewRead(d, meta) -} - -func resourceBigtableAuthorizedViewDestroy(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - ctx := context.Background() - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - - instanceName := tpgresource.GetResourceNameFromSelfLink(d.Get("instance_name").(string)) - c, err := config.BigTableClientFactory(userAgent).NewAdminClient(project, instanceName) - if err != nil { - return fmt.Errorf("Error starting admin client. %s", err) - } - - defer c.Close() - - authorizedViewId := d.Get("name").(string) - tableId := d.Get("table_name").(string) - err = c.DeleteAuthorizedView(ctx, tableId, authorizedViewId) - if err != nil { - return fmt.Errorf("Error deleting authorized view. %s", err) - } - - d.SetId("") - - return nil -} - -func resourceBigtableAuthorizedViewImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "projects/(?P[^/]+)/instances/(?P[^/]+)/tables/(?P[^/]+)/authorizedViews/(?P[^/]+)", - "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", - "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/instances/{{instance_name}}/tables/{{table_name}}/authorizedViews/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func generateSubsetViewConfig(subsetView []interface{}) (*bigtable.SubsetViewConf, error) { - subsetViewConf := bigtable.SubsetViewConf{} - - if len(subsetView) == 0 { - return nil, fmt.Errorf("Error constructing SubsetViewConfig; empty subset_view list") - } - if subsetView[0] == nil { - return &subsetViewConf, nil - } - sv, ok := subsetView[0].(map[string]interface{}) - if !ok { - return nil, fmt.Errorf("Error constructing SubsetViewConfig; element in subset_view list has wrong type: %s", reflect.TypeOf(subsetView[0])) - } - if rowPrefixes, ok := sv["row_prefixes"]; ok { - for _, rowPrefix := range rowPrefixes.(*schema.Set).List() { - decodedRowPrefix, err := base64.StdEncoding.DecodeString(rowPrefix.(string)) - if err != nil { - return nil, err - } - subsetViewConf.AddRowPrefix(decodedRowPrefix) - } - } - if familySubsets, ok := sv["family_subsets"]; ok { - for _, familySubset := range familySubsets.(*schema.Set).List() { - familySubsetElement := familySubset.(map[string]interface{}) - familyName := familySubsetElement["family_name"].(string) - if qualifiers, ok := familySubsetElement["qualifiers"]; ok { - for _, qualifier := range qualifiers.(*schema.Set).List() { - decodedQualifier, err := base64.StdEncoding.DecodeString(qualifier.(string)) - if err != nil { - return nil, err - } - subsetViewConf.AddFamilySubsetQualifier(familyName, decodedQualifier) - } - } - if qualifierPrefixes, ok := familySubsetElement["qualifier_prefixes"]; ok { - for _, qualifierPrefix := range qualifierPrefixes.(*schema.Set).List() { - decodedQualifierPrefix, err := base64.StdEncoding.DecodeString(qualifierPrefix.(string)) - if err != nil { - return nil, err - } - subsetViewConf.AddFamilySubsetQualifierPrefix(familyName, decodedQualifierPrefix) - } - } - } - } - return &subsetViewConf, nil -} - -func flattenSubsetViewInfo(subsetViewInfo *bigtable.SubsetViewInfo) []map[string]interface{} { - subsetView := make([]map[string]interface{}, 1) - - rowPrefixes := []string{} - for _, prefix := range subsetViewInfo.RowPrefixes { - encodedRowPrefix := base64.StdEncoding.EncodeToString(prefix) - rowPrefixes = append(rowPrefixes, encodedRowPrefix) - } - familySubsets := []map[string]interface{}{} - for k, v := range subsetViewInfo.FamilySubsets { - familySubsetElement := make(map[string]interface{}) - familySubsetElement["family_name"] = k - qualifiers := []string{} - for _, qualifier := range v.Qualifiers { - encodedQualifier := base64.StdEncoding.EncodeToString(qualifier) - qualifiers = append(qualifiers, encodedQualifier) - } - if len(qualifiers) > 0 { - familySubsetElement["qualifiers"] = qualifiers - } - qualifierPrefixes := []string{} - for _, qualifierPrefix := range v.QualifierPrefixes { - encodedQualifierPrefix := base64.StdEncoding.EncodeToString(qualifierPrefix) - qualifierPrefixes = append(qualifierPrefixes, encodedQualifierPrefix) - } - if len(qualifierPrefixes) > 0 { - familySubsetElement["qualifier_prefixes"] = qualifierPrefixes - } - familySubsets = append(familySubsets, familySubsetElement) - } - subsetView[0] = make(map[string]interface{}) - if len(rowPrefixes) > 0 { - subsetView[0]["row_prefixes"] = rowPrefixes - } - if len(familySubsets) > 0 { - subsetView[0]["family_subsets"] = familySubsets - } - - return subsetView -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_gc_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_gc_policy.go index 3ae29ca4eb6..2590bbd70ac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_gc_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_gc_policy.go @@ -218,16 +218,6 @@ func ResourceBigtableGCPolicy() *schema.Resource { in a replicated instance. Possible values are: "ABANDON".`, ValidateFunc: validation.StringInSlice([]string{"ABANDON", ""}, false), }, - - "ignore_warnings": { - Type: schema.TypeBool, - Optional: true, - Description: `Allows ignoring warnings when updating the GC policy. This can be used - to increase the gc policy on replicated clusters. Doing this may make clusters be - inconsistent for a longer period of time, before using this make sure you understand - the risks listed at https://cloud.google.com/bigtable/docs/garbage-collection#increasing`, - Default: false, - }, }, UseJSONNumber: true, } @@ -265,14 +255,9 @@ func resourceBigtableGCPolicyUpsert(d *schema.ResourceData, meta interface{}) er tableName := d.Get("table").(string) columnFamily := d.Get("column_family").(string) - ignoreWarnings := d.Get("ignore_warnings").(bool) - updateOpts := []bigtable.GCPolicyOption{} - if ignoreWarnings { - updateOpts = append(updateOpts, bigtable.IgnoreWarnings()) - } retryFunc := func() error { - reqErr := c.SetGCPolicyWithOptions(ctx, tableName, columnFamily, gcPolicy, updateOpts...) + reqErr := c.SetGCPolicy(ctx, tableName, columnFamily, gcPolicy) return reqErr } // The default create timeout is 20 minutes. diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_instance.go index 4f6311d3456..3a049760ceb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_instance.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "google.golang.org/api/iterator" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" @@ -20,23 +19,6 @@ import ( "cloud.google.com/go/bigtable" ) -// resourceBigtableInstanceVirtualUpdate identifies if an update to the resource includes only virtual field updates -func resourceBigtableInstanceVirtualUpdate(d *schema.ResourceData, resourceSchema map[string]*schema.Schema) bool { - // force_destroy is the only virtual field - if d.HasChange("force_destroy") { - for field := range resourceSchema { - if field == "force_destroy" { - continue - } - if d.HasChange(field) { - return false - } - } - return true - } - return false -} - func ResourceBigtableInstance() *schema.Resource { return &schema.Resource{ Create: resourceBigtableInstanceCreate, @@ -173,18 +155,11 @@ func ResourceBigtableInstance() *schema.Resource { Deprecated: `It is recommended to leave this field unspecified since the distinction between "DEVELOPMENT" and "PRODUCTION" instances is going away, and all instances will become "PRODUCTION" instances. This means that new and existing "DEVELOPMENT" instances will be converted to "PRODUCTION" instances. It is recommended for users to use "PRODUCTION" instances in any case, since a 1-node "PRODUCTION" instance is functionally identical to a "DEVELOPMENT" instance, but without the accompanying restrictions.`, }, - "force_destroy": { - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: `When deleting a BigTable instance, this boolean option will delete all backups within the instance.`, - }, - "deletion_protection": { Type: schema.TypeBool, Optional: true, Default: true, - Description: ` When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the instance will fail. When the field is set to false, deleting the instance is allowed.`, + Description: `Whether or not to allow Terraform to destroy the instance. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the instance will fail.`, }, "labels": { @@ -368,13 +343,6 @@ func resourceBigtableInstanceRead(d *schema.ResourceData, meta interface{}) erro // Don't set instance_type: we don't want to detect drift on it because it can // change under-the-hood. - // Explicitly set virtual fields to default values if unset - if _, ok := d.GetOkExists("force_destroy"); !ok { - if err := d.Set("force_destroy", false); err != nil { - return fmt.Errorf("Error setting force_destroy: %s", err) - } - } - return nil } @@ -423,18 +391,6 @@ func resourceBigtableInstanceUpdate(d *schema.ResourceData, meta interface{}) er return err } - log.Printf("[DEBUG] Updating BigTable instance %q: %#v", d.Id(), conf) - - // Handle scenario where the update includes only updating force_destroy - if resourceBigtableInstanceVirtualUpdate(d, ResourceBigtableInstance().Schema) { - if d.Get("force_destroy") != nil { - if err := d.Set("force_destroy", d.Get("force_destroy")); err != nil { - return fmt.Errorf("error reading Instance: %s", err) - } - } - return nil - } - ctxWithTimeout, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutUpdate)) defer cancel() if _, err := bigtable.UpdateInstanceAndSyncClusters(ctxWithTimeout, c, conf); err != nil { @@ -445,7 +401,6 @@ func resourceBigtableInstanceUpdate(d *schema.ResourceData, meta interface{}) er } func resourceBigtableInstanceDestroy(d *schema.ResourceData, meta interface{}) error { - log.Printf("[DEBUG] Deleting BigTable instance %q", d.Id()) if d.Get("deletion_protection").(bool) { return fmt.Errorf("cannot destroy instance without setting deletion_protection=false and running `terraform apply`") } @@ -470,40 +425,6 @@ func resourceBigtableInstanceDestroy(d *schema.ResourceData, meta interface{}) e defer c.Close() name := d.Get("name").(string) - - // If force_destroy is set, delete all backups and unblock deletion of the instance - if d.Get("force_destroy").(bool) { - adminClient, err := config.BigTableClientFactory(userAgent).NewAdminClient(project, name) - if err != nil { - return fmt.Errorf("error starting admin client. %s", err) - } - - // Iterate over clusters to get all backups - // Need to get backup data per cluster because when you delete a backup the name must be provided. - // If we get all backups in an instance at once the information about the cluster a backup belongs to isn't present. - clusters, err := c.Clusters(ctx, name) - if err != nil { - return fmt.Errorf("error retrieving cluster data for instance %s: %s", name, err) - } - for _, cluster := range clusters { - it := adminClient.Backups(ctx, cluster.Name) - for { - backup, err := it.Next() - if err == iterator.Done { - break - } - if err != nil { - return fmt.Errorf("error iterating over backups in cluster %s: %s", cluster.Name, err) - } - log.Printf("[DEBUG] Deleting backup %s from cluster %s", backup.Name, cluster.Name) - err = adminClient.DeleteBackup(ctx, cluster.Name, backup.Name) - if err != nil { - return fmt.Errorf("error backup %s from cluster %s: %s", backup.Name, cluster.Name, err) - } - } - } - } - err = c.DeleteInstance(ctx, name) if err != nil { return fmt.Errorf("Error deleting instance. %s", err) @@ -814,10 +735,5 @@ func resourceBigtableInstanceImport(d *schema.ResourceData, meta interface{}) ([ } d.SetId(id) - // Explicitly set virtual fields to default values on import - if err := d.Set("force_destroy", false); err != nil { - return nil, fmt.Errorf("error setting force_destroy: %s", err) - } - return []*schema.ResourceData{d}, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_table.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_table.go index fd5a5d94069..8a933bd4ea9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_table.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/bigtable/resource_bigtable_table.go @@ -105,31 +105,6 @@ func ResourceBigtableTable() *schema.Resource { ValidateFunc: verify.ValidateDuration(), Description: `Duration to retain change stream data for the table. Set to 0 to disable. Must be between 1 and 7 days.`, }, - - "automated_backup_policy": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "retention_period": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidateDuration(), - Description: `How long the automated backups should be retained.`, - }, - "frequency": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ValidateFunc: verify.ValidateDuration(), - Description: `How frequently automated backups should occur.`, - }, - }, - }, - Description: `Defines an automated backup policy for a table, specified by Retention Period and Frequency. To disable, set both Retention Period and Frequency to 0.`, - }, }, UseJSONNumber: true, } @@ -179,35 +154,6 @@ func resourceBigtableTableCreate(d *schema.ResourceData, meta interface{}) error } } - if automatedBackupPolicyField, ok := d.GetOk("automated_backup_policy"); ok { - automatedBackupPolicyElements := automatedBackupPolicyField.(*schema.Set).List() - if len(automatedBackupPolicyElements) == 0 { - return fmt.Errorf("Incomplete automated_backup_policy") - } else { - automatedBackupPolicy := automatedBackupPolicyElements[0].(map[string]interface{}) - abpRetentionPeriodField, retentionPeriodExists := automatedBackupPolicy["retention_period"] - if !retentionPeriodExists { - return fmt.Errorf("Automated backup policy retention period must be specified") - } - abpFrequencyField, frequencyExists := automatedBackupPolicy["frequency"] - if !frequencyExists { - return fmt.Errorf("Automated backup policy frequency must be specified") - } - abpRetentionPeriod, err := ParseDuration(abpRetentionPeriodField.(string)) - if err != nil { - return fmt.Errorf("Error parsing automated backup policy retention period: %s", err) - } - abpFrequency, err := ParseDuration(abpFrequencyField.(string)) - if err != nil { - return fmt.Errorf("Error parsing automated backup policy frequency: %s", err) - } - tblConf.AutomatedBackupConfig = &bigtable.TableAutomatedBackupPolicy{ - RetentionPeriod: abpRetentionPeriod, - Frequency: abpFrequency, - } - } - } - // Set the split keys if given. if v, ok := d.GetOk("split_keys"); ok { tblConf.SplitKeys = tpgresource.ConvertStringArr(v.([]interface{})) @@ -307,26 +253,6 @@ func resourceBigtableTableRead(d *schema.ResourceData, meta interface{}) error { } } - if table.AutomatedBackupConfig != nil { - switch automatedBackupConfig := table.AutomatedBackupConfig.(type) { - case *bigtable.TableAutomatedBackupPolicy: - var tableAbp bigtable.TableAutomatedBackupPolicy = *automatedBackupConfig - abpRetentionPeriod := tableAbp.RetentionPeriod.(time.Duration).String() - abpFrequency := tableAbp.Frequency.(time.Duration).String() - abp := []interface{}{ - map[string]interface{}{ - "retention_period": abpRetentionPeriod, - "frequency": abpFrequency, - }, - } - if err := d.Set("automated_backup_policy", abp); err != nil { - return fmt.Errorf("Error setting automated_backup_policy: %s", err) - } - default: - return fmt.Errorf("error: Unknown type of automated backup configuration") - } - } - return nil } @@ -411,46 +337,6 @@ func resourceBigtableTableUpdate(d *schema.ResourceData, meta interface{}) error } } - if d.HasChange("automated_backup_policy") { - automatedBackupPolicyField := d.Get("automated_backup_policy").(*schema.Set) - automatedBackupPolicyElements := automatedBackupPolicyField.List() - if len(automatedBackupPolicyElements) == 0 { - return fmt.Errorf("Incomplete automated_backup_policy") - } - automatedBackupPolicy := automatedBackupPolicyElements[0].(map[string]interface{}) - abp := bigtable.TableAutomatedBackupPolicy{} - - abpRetentionPeriodField, retentionPeriodExists := automatedBackupPolicy["retention_period"] - if retentionPeriodExists && abpRetentionPeriodField != "" { - abpRetentionPeriod, err := ParseDuration(abpRetentionPeriodField.(string)) - if err != nil { - return fmt.Errorf("Error parsing automated backup policy retention period: %s", err) - } - abp.RetentionPeriod = abpRetentionPeriod - } - - abpFrequencyField, frequencyExists := automatedBackupPolicy["frequency"] - if frequencyExists && abpFrequencyField != "" { - abpFrequency, err := ParseDuration(abpFrequencyField.(string)) - if err != nil { - return fmt.Errorf("Error parsing automated backup policy frequency: %s", err) - } - abp.Frequency = abpFrequency - } - - if abp.RetentionPeriod != nil && abp.RetentionPeriod.(time.Duration) == 0 && abp.Frequency != nil && abp.Frequency.(time.Duration) == 0 { - // Disable Automated Backups - if err := c.UpdateTableDisableAutomatedBackupPolicy(ctxWithTimeout, name); err != nil { - return fmt.Errorf("Error disabling automated backup configuration on table %v: %s", name, err) - } - } else { - // Update Automated Backups config - if err := c.UpdateTableWithAutomatedBackupPolicy(ctxWithTimeout, name, abp); err != nil { - return fmt.Errorf("Error updating automated backup configuration on table %v: %s", name, err) - } - } - } - return resourceBigtableTableRead(d, meta) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/billing/resource_billing_budget.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/billing/resource_billing_budget.go index 987f72c7bea..53a000956ec 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/billing/resource_billing_budget.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/billing/resource_billing_budget.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -152,16 +151,6 @@ those with Billing Account Administrators and Billing Account Users IAM roles for the target account.`, Default: false, }, - "enable_project_level_recipients": { - Type: schema.TypeBool, - Optional: true, - Description: `When set to true, and when the budget has a single project configured, -notifications will be sent to project level recipients of that project. -This field will be ignored if the budget has multiple or no project configured. - -Currently, project level recipients are the users with Owner role on a cloud project.`, - Default: false, - }, "monitoring_notification_channels": { Type: schema.TypeList, Optional: true, @@ -386,13 +375,6 @@ account and all subaccounts, if they exist. Optional: true, Description: `User data for display name in UI. Must be <= 60 chars.`, }, - "ownership_scope": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"OWNERSHIP_SCOPE_UNSPECIFIED", "ALL_USERS", "BILLING_ACCOUNT", ""}), - Description: `The ownership scope of the budget. The ownership scope and users' -IAM permissions determine who has full access to the budget's data. Possible values: ["OWNERSHIP_SCOPE_UNSPECIFIED", "ALL_USERS", "BILLING_ACCOUNT"]`, - }, "threshold_rules": { Type: schema.TypeList, Optional: true, @@ -468,12 +450,6 @@ func resourceBillingBudgetCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("all_updates_rule"); !tpgresource.IsEmptyValue(reflect.ValueOf(notificationsRuleProp)) && (ok || !reflect.DeepEqual(v, notificationsRuleProp)) { obj["notificationsRule"] = notificationsRuleProp } - ownershipScopeProp, err := expandBillingBudgetOwnershipScope(d.Get("ownership_scope"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ownership_scope"); !tpgresource.IsEmptyValue(reflect.ValueOf(ownershipScopeProp)) && (ok || !reflect.DeepEqual(v, ownershipScopeProp)) { - obj["ownershipScope"] = ownershipScopeProp - } url, err := tpgresource.ReplaceVars(d, config, "{{BillingBasePath}}billingAccounts/{{billing_account}}/budgets") if err != nil { @@ -488,7 +464,6 @@ func resourceBillingBudgetCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -497,7 +472,6 @@ func resourceBillingBudgetCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Budget: %s", err) @@ -537,14 +511,12 @@ func resourceBillingBudgetRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BillingBudget %q", d.Id())) @@ -568,9 +540,6 @@ func resourceBillingBudgetRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("all_updates_rule", flattenBillingBudgetAllUpdatesRule(res["notificationsRule"], d, config)); err != nil { return fmt.Errorf("Error reading Budget: %s", err) } - if err := d.Set("ownership_scope", flattenBillingBudgetOwnershipScope(res["ownershipScope"], d, config)); err != nil { - return fmt.Errorf("Error reading Budget: %s", err) - } return nil } @@ -615,12 +584,6 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("all_updates_rule"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, notificationsRuleProp)) { obj["notificationsRule"] = notificationsRuleProp } - ownershipScopeProp, err := expandBillingBudgetOwnershipScope(d.Get("ownership_scope"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ownership_scope"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, ownershipScopeProp)) { - obj["ownershipScope"] = ownershipScopeProp - } url, err := tpgresource.ReplaceVars(d, config, "{{BillingBasePath}}billingAccounts/{{billing_account}}/budgets/{{name}}") if err != nil { @@ -628,7 +591,6 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Budget %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -661,12 +623,7 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error updateMask = append(updateMask, "notificationsRule.pubsubTopic", "notificationsRule.schemaVersion", "notificationsRule.monitoringNotificationChannels", - "notificationsRule.disableDefaultIamRecipients", - "notificationsRule.enableProjectLevelRecipients") - } - - if d.HasChange("ownership_scope") { - updateMask = append(updateMask, "ownershipScope") + "notificationsRule.disableDefaultIamRecipients") } // updateMask is a URL parameter but not present in the schema, so ReplaceVars // won't set it @@ -690,7 +647,6 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -725,8 +681,6 @@ func resourceBillingBudgetDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Budget %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -736,7 +690,6 @@ func resourceBillingBudgetDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Budget") @@ -1121,8 +1074,6 @@ func flattenBillingBudgetAllUpdatesRule(v interface{}, d *schema.ResourceData, c flattenBillingBudgetAllUpdatesRuleMonitoringNotificationChannels(original["monitoringNotificationChannels"], d, config) transformed["disable_default_iam_recipients"] = flattenBillingBudgetAllUpdatesRuleDisableDefaultIamRecipients(original["disableDefaultIamRecipients"], d, config) - transformed["enable_project_level_recipients"] = - flattenBillingBudgetAllUpdatesRuleEnableProjectLevelRecipients(original["enableProjectLevelRecipients"], d, config) return []interface{}{transformed} } func flattenBillingBudgetAllUpdatesRulePubsubTopic(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1145,14 +1096,6 @@ func flattenBillingBudgetAllUpdatesRuleDisableDefaultIamRecipients(v interface{} return v } -func flattenBillingBudgetAllUpdatesRuleEnableProjectLevelRecipients(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenBillingBudgetOwnershipScope(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandBillingBudgetDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1542,13 +1485,6 @@ func expandBillingBudgetAllUpdatesRule(v interface{}, d tpgresource.TerraformRes transformed["disableDefaultIamRecipients"] = transformedDisableDefaultIamRecipients } - transformedEnableProjectLevelRecipients, err := expandBillingBudgetAllUpdatesRuleEnableProjectLevelRecipients(original["enable_project_level_recipients"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnableProjectLevelRecipients); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enableProjectLevelRecipients"] = transformedEnableProjectLevelRecipients - } - return transformed, nil } @@ -1568,14 +1504,6 @@ func expandBillingBudgetAllUpdatesRuleDisableDefaultIamRecipients(v interface{}, return v, nil } -func expandBillingBudgetAllUpdatesRuleEnableProjectLevelRecipients(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandBillingBudgetOwnershipScope(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func resourceBillingBudgetResourceV0() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_attestor.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_attestor.go index 1696655efb1..4dcf3b05629 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_attestor.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_attestor.go @@ -20,7 +20,6 @@ package binaryauthorization import ( "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -262,7 +261,6 @@ func resourceBinaryAuthorizationAttestorCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -271,7 +269,6 @@ func resourceBinaryAuthorizationAttestorCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Attestor: %s", err) @@ -314,14 +311,12 @@ func resourceBinaryAuthorizationAttestorRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BinaryAuthorizationAttestor %q", d.Id())) @@ -385,7 +380,6 @@ func resourceBinaryAuthorizationAttestorUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating Attestor %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -400,7 +394,6 @@ func resourceBinaryAuthorizationAttestorUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -439,8 +432,6 @@ func resourceBinaryAuthorizationAttestorDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Attestor %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -450,7 +441,6 @@ func resourceBinaryAuthorizationAttestorDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Attestor") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_policy.go index 19670a1d77a..022ded7176f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/binaryauthorization/resource_binary_authorization_policy.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -289,7 +288,6 @@ func resourceBinaryAuthorizationPolicyCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PUT", @@ -298,7 +296,6 @@ func resourceBinaryAuthorizationPolicyCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Policy: %s", err) @@ -341,14 +338,12 @@ func resourceBinaryAuthorizationPolicyRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BinaryAuthorizationPolicy %q", d.Id())) @@ -430,7 +425,6 @@ func resourceBinaryAuthorizationPolicyUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating Policy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -445,7 +439,6 @@ func resourceBinaryAuthorizationPolicyUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -484,7 +477,6 @@ func resourceBinaryAuthorizationPolicyDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) obj = DefaultBinaryAuthorizationPolicy(d.Get("project").(string)) log.Printf("[DEBUG] Deleting Policy %q", d.Id()) @@ -496,7 +488,6 @@ func resourceBinaryAuthorizationPolicyDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Policy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go index 784816ba6b0..74373bdc628 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/blockchainnodeengine/resource_blockchain_node_engine_blockchain_nodes.go @@ -20,7 +20,6 @@ package blockchainnodeengine import ( "fmt" "log" - "net/http" "reflect" "time" @@ -310,7 +309,6 @@ func resourceBlockchainNodeEngineBlockchainNodesCreate(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -319,7 +317,6 @@ func resourceBlockchainNodeEngineBlockchainNodesCreate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BlockchainNodes: %s", err) @@ -386,14 +383,12 @@ func resourceBlockchainNodeEngineBlockchainNodesRead(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("BlockchainNodeEngineBlockchainNodes %q", d.Id())) @@ -475,7 +470,6 @@ func resourceBlockchainNodeEngineBlockchainNodesUpdate(d *schema.ResourceData, m } log.Printf("[DEBUG] Updating BlockchainNodes %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -490,7 +484,6 @@ func resourceBlockchainNodeEngineBlockchainNodesUpdate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -537,8 +530,6 @@ func resourceBlockchainNodeEngineBlockchainNodesDelete(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BlockchainNodes %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -548,7 +539,6 @@ func resourceBlockchainNodeEngineBlockchainNodesDelete(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BlockchainNodes") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate.go index a6f6aaa1fe1..459b61bc4ae 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -352,7 +351,6 @@ func resourceCertificateManagerCertificateCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -361,7 +359,6 @@ func resourceCertificateManagerCertificateCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Certificate: %s", err) @@ -414,14 +411,12 @@ func resourceCertificateManagerCertificateRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CertificateManagerCertificate %q", d.Id())) @@ -488,7 +483,6 @@ func resourceCertificateManagerCertificateUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating Certificate %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -520,7 +514,6 @@ func resourceCertificateManagerCertificateUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -568,8 +561,6 @@ func resourceCertificateManagerCertificateDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Certificate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -579,7 +570,6 @@ func resourceCertificateManagerCertificateDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Certificate") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go index 068efb31f94..0deefbd5b53 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_issuance_config.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -253,7 +252,6 @@ func resourceCertificateManagerCertificateIssuanceConfigCreate(d *schema.Resourc billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -262,7 +260,6 @@ func resourceCertificateManagerCertificateIssuanceConfigCreate(d *schema.Resourc UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CertificateIssuanceConfig: %s", err) @@ -315,14 +312,12 @@ func resourceCertificateManagerCertificateIssuanceConfigRead(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CertificateManagerCertificateIssuanceConfig %q", d.Id())) @@ -398,8 +393,6 @@ func resourceCertificateManagerCertificateIssuanceConfigDelete(d *schema.Resourc billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CertificateIssuanceConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -409,7 +402,6 @@ func resourceCertificateManagerCertificateIssuanceConfigDelete(d *schema.Resourc UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CertificateIssuanceConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map.go index 6cd925f1bff..06d1f3d8558 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map.go @@ -20,7 +20,6 @@ package certificatemanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -200,7 +199,6 @@ func resourceCertificateManagerCertificateMapCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -209,7 +207,6 @@ func resourceCertificateManagerCertificateMapCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CertificateMap: %s", err) @@ -262,14 +259,12 @@ func resourceCertificateManagerCertificateMapRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CertificateManagerCertificateMap %q", d.Id())) @@ -339,7 +334,6 @@ func resourceCertificateManagerCertificateMapUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating CertificateMap %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -371,7 +365,6 @@ func resourceCertificateManagerCertificateMapUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -419,8 +412,6 @@ func resourceCertificateManagerCertificateMapDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CertificateMap %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -430,7 +421,6 @@ func resourceCertificateManagerCertificateMapDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CertificateMap") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go index 6b6a560415e..fb210806b50 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_certificate_map_entry.go @@ -20,7 +20,6 @@ package certificatemanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -221,7 +220,6 @@ func resourceCertificateManagerCertificateMapEntryCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -230,7 +228,6 @@ func resourceCertificateManagerCertificateMapEntryCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CertificateMapEntry: %s", err) @@ -283,14 +280,12 @@ func resourceCertificateManagerCertificateMapEntryRead(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CertificateManagerCertificateMapEntry %q", d.Id())) @@ -378,7 +373,6 @@ func resourceCertificateManagerCertificateMapEntryUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating CertificateMapEntry %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -414,7 +408,6 @@ func resourceCertificateManagerCertificateMapEntryUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -462,8 +455,6 @@ func resourceCertificateManagerCertificateMapEntryDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CertificateMapEntry %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -473,7 +464,6 @@ func resourceCertificateManagerCertificateMapEntryDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CertificateMapEntry") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go index 14d2b1f881c..006034f5fa9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_dns_authorization.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -221,7 +220,6 @@ func resourceCertificateManagerDnsAuthorizationCreate(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -230,7 +228,6 @@ func resourceCertificateManagerDnsAuthorizationCreate(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DnsAuthorization: %s", err) @@ -283,14 +280,12 @@ func resourceCertificateManagerDnsAuthorizationRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CertificateManagerDnsAuthorization %q", d.Id())) @@ -360,7 +355,6 @@ func resourceCertificateManagerDnsAuthorizationUpdate(d *schema.ResourceData, me } log.Printf("[DEBUG] Updating DnsAuthorization %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -392,7 +386,6 @@ func resourceCertificateManagerDnsAuthorizationUpdate(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -440,8 +433,6 @@ func resourceCertificateManagerDnsAuthorizationDelete(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DnsAuthorization %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -451,7 +442,6 @@ func resourceCertificateManagerDnsAuthorizationDelete(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DnsAuthorization") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_trust_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_trust_config.go index 85701e9e7fe..a56d245b710 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_trust_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/certificatemanager/resource_certificate_manager_trust_config.go @@ -20,7 +20,6 @@ package certificatemanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -66,21 +65,6 @@ func ResourceCertificateManagerTrustConfig() *schema.Resource { ForceNew: true, Description: `A user-defined name of the trust config. Trust config names must be unique globally.`, }, - "allowlisted_certificates": { - Type: schema.TypeList, - Optional: true, - Description: `Allowlisted PEM-encoded certificates. A certificate matching an allowlisted certificate is always considered valid as long as -the certificate is parseable, proof of private key possession is established, and constraints on the certificate's SAN field are met.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pem_certificate": { - Type: schema.TypeString, - Required: true, - Description: `PEM certificate that is allowlisted. The certificate can be up to 5k bytes, and must be a parseable X.509 certificate.`, - }, - }, - }, - }, "description": { Type: schema.TypeString, Optional: true, @@ -149,6 +133,7 @@ Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".`, "effective_labels": { Type: schema.TypeMap, Computed: true, + ForceNew: true, Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, Elem: &schema.Schema{Type: schema.TypeString}, }, @@ -198,12 +183,6 @@ func resourceCertificateManagerTrustConfigCreate(d *schema.ResourceData, meta in } else if v, ok := d.GetOkExists("trust_stores"); !tpgresource.IsEmptyValue(reflect.ValueOf(trustStoresProp)) && (ok || !reflect.DeepEqual(v, trustStoresProp)) { obj["trustStores"] = trustStoresProp } - allowlistedCertificatesProp, err := expandCertificateManagerTrustConfigAllowlistedCertificates(d.Get("allowlisted_certificates"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("allowlisted_certificates"); !tpgresource.IsEmptyValue(reflect.ValueOf(allowlistedCertificatesProp)) && (ok || !reflect.DeepEqual(v, allowlistedCertificatesProp)) { - obj["allowlistedCertificates"] = allowlistedCertificatesProp - } labelsProp, err := expandCertificateManagerTrustConfigEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -230,7 +209,6 @@ func resourceCertificateManagerTrustConfigCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -239,7 +217,6 @@ func resourceCertificateManagerTrustConfigCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TrustConfig: %s", err) @@ -292,14 +269,12 @@ func resourceCertificateManagerTrustConfigRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CertificateManagerTrustConfig %q", d.Id())) @@ -324,9 +299,6 @@ func resourceCertificateManagerTrustConfigRead(d *schema.ResourceData, meta inte if err := d.Set("trust_stores", flattenCertificateManagerTrustConfigTrustStores(res["trustStores"], d, config)); err != nil { return fmt.Errorf("Error reading TrustConfig: %s", err) } - if err := d.Set("allowlisted_certificates", flattenCertificateManagerTrustConfigAllowlistedCertificates(res["allowlistedCertificates"], d, config)); err != nil { - return fmt.Errorf("Error reading TrustConfig: %s", err) - } if err := d.Set("terraform_labels", flattenCertificateManagerTrustConfigTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading TrustConfig: %s", err) } @@ -365,18 +337,6 @@ func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta in } else if v, ok := d.GetOkExists("trust_stores"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, trustStoresProp)) { obj["trustStores"] = trustStoresProp } - allowlistedCertificatesProp, err := expandCertificateManagerTrustConfigAllowlistedCertificates(d.Get("allowlisted_certificates"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("allowlisted_certificates"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, allowlistedCertificatesProp)) { - obj["allowlistedCertificates"] = allowlistedCertificatesProp - } - labelsProp, err := expandCertificateManagerTrustConfigEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } url, err := tpgresource.ReplaceVars(d, config, "{{CertificateManagerBasePath}}projects/{{project}}/locations/{{location}}/trustConfigs/{{name}}") if err != nil { @@ -384,7 +344,10 @@ func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating TrustConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": "*"}) + if err != nil { + return err + } // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -399,7 +362,6 @@ func resourceCertificateManagerTrustConfigUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -446,8 +408,6 @@ func resourceCertificateManagerTrustConfigDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TrustConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -457,7 +417,6 @@ func resourceCertificateManagerTrustConfigDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TrustConfig") @@ -585,28 +544,6 @@ func flattenCertificateManagerTrustConfigTrustStoresIntermediateCasPemCertificat return v } -func flattenCertificateManagerTrustConfigAllowlistedCertificates(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "pem_certificate": flattenCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate(original["pemCertificate"], d, config), - }) - } - return transformed -} -func flattenCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenCertificateManagerTrustConfigTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -711,32 +648,6 @@ func expandCertificateManagerTrustConfigTrustStoresIntermediateCasPemCertificate return v, nil } -func expandCertificateManagerTrustConfigAllowlistedCertificates(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPemCertificate, err := expandCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate(original["pem_certificate"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPemCertificate); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pemCertificate"] = transformedPemCertificate - } - - req = append(req, transformed) - } - return req, nil -} - -func expandCertificateManagerTrustConfigAllowlistedCertificatesPemCertificate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandCertificateManagerTrustConfigEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/data_source_google_cloud_asset_search_all_resources.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/data_source_google_cloud_asset_search_all_resources.go deleted file mode 100644 index c5243df1dd3..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/data_source_google_cloud_asset_search_all_resources.go +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package cloudasset - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleCloudAssetSearchAllResources() *schema.Resource { - return &schema.Resource{ - Read: datasourceGoogleCloudAssetSearchAllResourcesRead, - Schema: map[string]*schema.Schema{ - "scope": { - Type: schema.TypeString, - Required: true, - }, - "query": { - Type: schema.TypeString, - Optional: true, - }, - "asset_types": { - Type: schema.TypeList, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - Optional: true, - }, - "results": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Computed: true, - }, - "asset_type": { - Type: schema.TypeString, - Computed: true, - }, - "project": { - Type: schema.TypeString, - Computed: true, - }, - "folders": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "organization": { - Type: schema.TypeString, - Computed: true, - }, - "display_name": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "location": { - Type: schema.TypeString, - Computed: true, - }, - "labels": { - Type: schema.TypeMap, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "network_tags": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "kms_keys": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - }, - "state": { - Type: schema.TypeString, - Computed: true, - }, - "parent_full_resource_name": { - Type: schema.TypeString, - Computed: true, - }, - "parent_asset_type": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func datasourceGoogleCloudAssetSearchAllResourcesRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - params := make(map[string]string) - results := make([]map[string]interface{}, 0) - - scope := d.Get("scope").(string) - query := d.Get("query").(string) - assetTypes := d.Get("asset_types").([]interface{}) - - url := fmt.Sprintf("https://cloudasset.googleapis.com/v1/%s:searchAllResources", scope) - params["query"] = query - - url, err = transport_tpg.AddArrayQueryParams(url, "asset_types", assetTypes) - if err != nil { - return fmt.Errorf("Error setting asset_types: %s", err) - } - - for { - url, err := transport_tpg.AddQueryParams(url, params) - if err != nil { - return err - } - - var project string - if config.UserProjectOverride && config.BillingProject != "" { - project = config.BillingProject - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Project: project, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return fmt.Errorf("Error searching resources: %s", err) - } - - pageResults := flattenDatasourceGoogleCloudAssetSearchAllResources(res["results"]) - results = append(results, pageResults...) - - pToken, ok := res["nextPageToken"] - if ok && pToken != nil && pToken.(string) != "" { - params["pageToken"] = pToken.(string) - } else { - break - } - } - - if err := d.Set("results", results); err != nil { - return fmt.Errorf("Error searching resources: %s", err) - } - - if err := d.Set("query", query); err != nil { - return fmt.Errorf("Error setting query: %s", err) - } - - if err := d.Set("asset_types", assetTypes); err != nil { - return fmt.Errorf("Error setting asset_types: %s", err) - } - - d.SetId(scope) - - return nil -} - -func flattenDatasourceGoogleCloudAssetSearchAllResources(v interface{}) []map[string]interface{} { - if v == nil { - return make([]map[string]interface{}, 0) - } - - ls := v.([]interface{}) - results := make([]map[string]interface{}, 0, len(ls)) - for _, raw := range ls { - p := raw.(map[string]interface{}) - - var mName, mAssetType, mProject, mFolders, mOrganization, mDisplayName, mDescription, mLocation, mLabels, mNetworkTags, mKmsKeys, mCreateTime, mUpdateTime, mState, mParentFullResourceName, mParentAssetType interface{} - if pName, ok := p["name"]; ok { - mName = pName - } - if pAssetType, ok := p["assetType"]; ok { - mAssetType = pAssetType - } - if pProject, ok := p["project"]; ok { - mProject = pProject - } - if pFolders, ok := p["folders"]; ok { - mFolders = pFolders - } - if pOrganization, ok := p["organization"]; ok { - mOrganization = pOrganization - } - if pDisplayName, ok := p["displayName"]; ok { - mDisplayName = pDisplayName - } - if pDescription, ok := p["description"]; ok { - mDescription = pDescription - } - if pLocation, ok := p["location"]; ok { - mLocation = pLocation - } - if pLabels, ok := p["labels"]; ok { - mLabels = pLabels - } - if pNetworkTags, ok := p["networkTags"]; ok { - mNetworkTags = pNetworkTags - } - if pKmsKeys, ok := p["kmsKeys"]; ok { - mKmsKeys = pKmsKeys - } - if pCreateTime, ok := p["createTime"]; ok { - mCreateTime = pCreateTime - } - if pUpdateTime, ok := p["updateTime"]; ok { - mUpdateTime = pUpdateTime - } - if pState, ok := p["state"]; ok { - mState = pState - } - if pParentFullResourceName, ok := p["parentFullResourceName"]; ok { - mParentFullResourceName = pParentFullResourceName - } - if pParentAssetType, ok := p["parentAssetType"]; ok { - mParentAssetType = pParentAssetType - } - results = append(results, map[string]interface{}{ - "name": mName, - "asset_type": mAssetType, - "project": mProject, - "folders": mFolders, - "organization": mOrganization, - "display_name": mDisplayName, - "description": mDescription, - "location": mLocation, - "labels": mLabels, - "network_tags": mNetworkTags, - "kms_keys": mKmsKeys, - "create_time": mCreateTime, - "update_time": mUpdateTime, - "state": mState, - "parent_full_resource_name": mParentFullResourceName, - "parent_asset_type": mParentAssetType, - }) - } - - return results -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_folder_feed.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_folder_feed.go index cd531afec04..8cf6cfbce87 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_folder_feed.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_folder_feed.go @@ -20,7 +20,6 @@ package cloudasset import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -239,8 +238,6 @@ func resourceCloudAssetFolderFeedCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - // Send the project ID in the X-Goog-User-Project header. origUserProjectOverride := config.UserProjectOverride config.UserProjectOverride = true @@ -252,7 +249,6 @@ func resourceCloudAssetFolderFeedCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FolderFeed: %s", err) @@ -299,14 +295,12 @@ func resourceCloudAssetFolderFeedRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudAssetFolderFeed %q", d.Id())) @@ -389,7 +383,6 @@ func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating FolderFeed %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("asset_names") { @@ -436,7 +429,6 @@ func resourceCloudAssetFolderFeedUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -474,8 +466,6 @@ func resourceCloudAssetFolderFeedDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FolderFeed %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -485,7 +475,6 @@ func resourceCloudAssetFolderFeedDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FolderFeed") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_organization_feed.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_organization_feed.go index 470e1a825e9..a20d22d88b7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_organization_feed.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_organization_feed.go @@ -20,7 +20,6 @@ package cloudasset import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -233,8 +232,6 @@ func resourceCloudAssetOrganizationFeedCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - // Send the project ID in the X-Goog-User-Project header. origUserProjectOverride := config.UserProjectOverride config.UserProjectOverride = true @@ -246,7 +243,6 @@ func resourceCloudAssetOrganizationFeedCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating OrganizationFeed: %s", err) @@ -293,14 +289,12 @@ func resourceCloudAssetOrganizationFeedRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudAssetOrganizationFeed %q", d.Id())) @@ -380,7 +374,6 @@ func resourceCloudAssetOrganizationFeedUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating OrganizationFeed %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("asset_names") { @@ -427,7 +420,6 @@ func resourceCloudAssetOrganizationFeedUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -465,8 +457,6 @@ func resourceCloudAssetOrganizationFeedDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting OrganizationFeed %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -476,7 +466,6 @@ func resourceCloudAssetOrganizationFeedDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "OrganizationFeed") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_project_feed.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_project_feed.go index 7adb9c8c361..3ca2a03681e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_project_feed.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudasset/resource_cloud_asset_project_feed.go @@ -20,7 +20,6 @@ package cloudasset import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -240,8 +239,6 @@ func resourceCloudAssetProjectFeedCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - // Send the project ID in the X-Goog-User-Project header. origUserProjectOverride := config.UserProjectOverride config.UserProjectOverride = true @@ -253,7 +250,6 @@ func resourceCloudAssetProjectFeedCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ProjectFeed: %s", err) @@ -302,14 +298,12 @@ func resourceCloudAssetProjectFeedRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudAssetProjectFeed %q", d.Id())) @@ -399,7 +393,6 @@ func resourceCloudAssetProjectFeedUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating ProjectFeed %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("asset_names") { @@ -443,7 +436,6 @@ func resourceCloudAssetProjectFeedUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -484,8 +476,6 @@ func resourceCloudAssetProjectFeedDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ProjectFeed %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -495,7 +485,6 @@ func resourceCloudAssetProjectFeedDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ProjectFeed") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go index f24da30ec71..d727040139f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_bitbucket_server_config.go @@ -20,7 +20,6 @@ package cloudbuild import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -244,7 +243,6 @@ func resourceCloudBuildBitbucketServerConfigCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -253,7 +251,6 @@ func resourceCloudBuildBitbucketServerConfigCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BitbucketServerConfig: %s", err) @@ -371,14 +368,12 @@ func resourceCloudBuildBitbucketServerConfigRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudBuildBitbucketServerConfig %q", d.Id())) @@ -483,7 +478,6 @@ func resourceCloudBuildBitbucketServerConfigUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating BitbucketServerConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("host_uri") { @@ -547,7 +541,6 @@ func resourceCloudBuildBitbucketServerConfigUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -681,8 +674,6 @@ func resourceCloudBuildBitbucketServerConfigDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BitbucketServerConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -692,7 +683,6 @@ func resourceCloudBuildBitbucketServerConfigDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BitbucketServerConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_trigger.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_trigger.go index 3d3f01f4e5f..920b9c5e85e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_trigger.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuild/resource_cloudbuild_trigger.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -1582,7 +1581,6 @@ func resourceCloudBuildTriggerCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1591,7 +1589,6 @@ func resourceCloudBuildTriggerCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Trigger: %s", err) @@ -1653,7 +1650,6 @@ func resourceCloudBuildTriggerRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) // To support import with the legacy id format. url = strings.ReplaceAll(url, "/locations//", "/locations/global/") res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ @@ -1662,7 +1658,6 @@ func resourceCloudBuildTriggerRead(d *schema.ResourceData, meta interface{}) err Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudBuildTrigger %q", d.Id())) @@ -1894,7 +1889,6 @@ func resourceCloudBuildTriggerUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Trigger %q: %#v", d.Id(), obj) - headers := make(http.Header) obj["id"] = d.Get("trigger_id") // err == nil indicates that the billing_project value was found @@ -1910,7 +1904,6 @@ func resourceCloudBuildTriggerUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1949,8 +1942,6 @@ func resourceCloudBuildTriggerDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Trigger %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1960,7 +1951,6 @@ func resourceCloudBuildTriggerDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Trigger") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go index aca07c9711d..cb5ade3af41 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_connection.go @@ -20,7 +20,6 @@ package cloudbuildv2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -76,162 +75,6 @@ func ResourceCloudbuildv2Connection() *schema.Resource { Please refer to the field 'effective_annotations' for all of the annotations present on the resource.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "bitbucket_cloud_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration for connections to Bitbucket Cloud.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "authorizer_credential": { - Type: schema.TypeList, - Required: true, - Description: `Required. An access token with the 'webhook', 'repository', 'repository:admin' and 'pullrequest' scope access. It can be either a workspace, project or repository access token. It's recommended to use a system account to generate these credentials.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "user_token_secret_version": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: 'projects/*/secrets/*/versions/*'.`, - }, - "username": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The username associated to this token.`, - }, - }, - }, - }, - "read_authorizer_credential": { - Type: schema.TypeList, - Required: true, - Description: `Required. An access token with the 'repository' access. It can be either a workspace, project or repository access token. It's recommended to use a system account to generate the credentials.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "user_token_secret_version": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: 'projects/*/secrets/*/versions/*'.`, - }, - "username": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The username associated to this token.`, - }, - }, - }, - }, - "webhook_secret_secret_version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. Immutable. SecretManager resource containing the webhook secret used to verify webhook events, formatted as 'projects/*/secrets/*/versions/*'.`, - }, - "workspace": { - Type: schema.TypeString, - Required: true, - Description: `The Bitbucket Cloud Workspace ID to be connected to Google Cloud Platform.`, - }, - }, - }, - ConflictsWith: []string{"github_config", "github_enterprise_config", "gitlab_config", "bitbucket_data_center_config"}, - }, - "bitbucket_data_center_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration for connections to Bitbucket Data Center.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "authorizer_credential": { - Type: schema.TypeList, - Required: true, - Description: `Required. A http access token with the 'REPO_ADMIN' scope access.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "user_token_secret_version": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: 'projects/*/secrets/*/versions/*'.`, - }, - "username": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The username associated to this token.`, - }, - }, - }, - }, - "host_uri": { - Type: schema.TypeString, - Required: true, - Description: `The URI of the Bitbucket Data Center host this connection is for.`, - }, - "read_authorizer_credential": { - Type: schema.TypeList, - Required: true, - Description: `Required. A http access token with the 'REPO_READ' access.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "user_token_secret_version": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. A SecretManager resource containing the user token that authorizes the Cloud Build connection. Format: 'projects/*/secrets/*/versions/*'.`, - }, - "username": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The username associated to this token.`, - }, - }, - }, - }, - "webhook_secret_secret_version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. Immutable. SecretManager resource containing the webhook secret used to verify webhook events, formatted as 'projects/*/secrets/*/versions/*'.`, - }, - "service_directory_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configuration for using Service Directory to privately connect to a Bitbucket Data Center. This should only be set if the Bitbucket Data Center is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the Bitbucket Data Center will be made over the public internet.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "service": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Required. The Service Directory service name. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.`, - }, - }, - }, - }, - "ssl_ca": { - Type: schema.TypeString, - Optional: true, - Description: `SSL certificate to use for requests to the Bitbucket Data Center.`, - }, - "server_version": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. Version of the Bitbucket Data Center running on the 'host_uri'.`, - }, - }, - }, - ConflictsWith: []string{"github_config", "github_enterprise_config", "bitbucket_cloud_config", "gitlab_config"}, - }, "disabled": { Type: schema.TypeBool, Optional: true, @@ -272,7 +115,7 @@ Please refer to the field 'effective_annotations' for all of the annotations pre }, }, }, - ConflictsWith: []string{"github_enterprise_config", "gitlab_config", "bitbucket_cloud_config", "bitbucket_data_center_config"}, + ConflictsWith: []string{"github_enterprise_config", "gitlab_config"}, }, "github_enterprise_config": { Type: schema.TypeList, @@ -336,7 +179,7 @@ Please refer to the field 'effective_annotations' for all of the annotations pre }, }, }, - ConflictsWith: []string{"github_config", "gitlab_config", "bitbucket_cloud_config", "bitbucket_data_center_config"}, + ConflictsWith: []string{"github_config", "gitlab_config"}, }, "gitlab_config": { Type: schema.TypeList, @@ -428,7 +271,7 @@ Please refer to the field 'effective_annotations' for all of the annotations pre }, }, }, - ConflictsWith: []string{"github_config", "github_enterprise_config", "bitbucket_cloud_config", "bitbucket_data_center_config"}, + ConflictsWith: []string{"github_config", "github_enterprise_config"}, }, "create_time": { Type: schema.TypeString, @@ -517,18 +360,6 @@ func resourceCloudbuildv2ConnectionCreate(d *schema.ResourceData, meta interface } else if v, ok := d.GetOkExists("gitlab_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(gitlabConfigProp)) && (ok || !reflect.DeepEqual(v, gitlabConfigProp)) { obj["gitlabConfig"] = gitlabConfigProp } - bitbucketDataCenterConfigProp, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfig(d.Get("bitbucket_data_center_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("bitbucket_data_center_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(bitbucketDataCenterConfigProp)) && (ok || !reflect.DeepEqual(v, bitbucketDataCenterConfigProp)) { - obj["bitbucketDataCenterConfig"] = bitbucketDataCenterConfigProp - } - bitbucketCloudConfigProp, err := expandCloudbuildv2ConnectionBitbucketCloudConfig(d.Get("bitbucket_cloud_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("bitbucket_cloud_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(bitbucketCloudConfigProp)) && (ok || !reflect.DeepEqual(v, bitbucketCloudConfigProp)) { - obj["bitbucketCloudConfig"] = bitbucketCloudConfigProp - } disabledProp, err := expandCloudbuildv2ConnectionDisabled(d.Get("disabled"), d, config) if err != nil { return err @@ -567,7 +398,6 @@ func resourceCloudbuildv2ConnectionCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -576,7 +406,6 @@ func resourceCloudbuildv2ConnectionCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Connection: %s", err) @@ -629,14 +458,12 @@ func resourceCloudbuildv2ConnectionRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Cloudbuildv2Connection %q", d.Id())) @@ -661,12 +488,6 @@ func resourceCloudbuildv2ConnectionRead(d *schema.ResourceData, meta interface{} if err := d.Set("gitlab_config", flattenCloudbuildv2ConnectionGitlabConfig(res["gitlabConfig"], d, config)); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } - if err := d.Set("bitbucket_data_center_config", flattenCloudbuildv2ConnectionBitbucketDataCenterConfig(res["bitbucketDataCenterConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Connection: %s", err) - } - if err := d.Set("bitbucket_cloud_config", flattenCloudbuildv2ConnectionBitbucketCloudConfig(res["bitbucketCloudConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Connection: %s", err) - } if err := d.Set("installation_state", flattenCloudbuildv2ConnectionInstallationState(res["installationState"], d, config)); err != nil { return fmt.Errorf("Error reading Connection: %s", err) } @@ -723,18 +544,6 @@ func resourceCloudbuildv2ConnectionUpdate(d *schema.ResourceData, meta interface } else if v, ok := d.GetOkExists("gitlab_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, gitlabConfigProp)) { obj["gitlabConfig"] = gitlabConfigProp } - bitbucketDataCenterConfigProp, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfig(d.Get("bitbucket_data_center_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("bitbucket_data_center_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, bitbucketDataCenterConfigProp)) { - obj["bitbucketDataCenterConfig"] = bitbucketDataCenterConfigProp - } - bitbucketCloudConfigProp, err := expandCloudbuildv2ConnectionBitbucketCloudConfig(d.Get("bitbucket_cloud_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("bitbucket_cloud_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, bitbucketCloudConfigProp)) { - obj["bitbucketCloudConfig"] = bitbucketCloudConfigProp - } disabledProp, err := expandCloudbuildv2ConnectionDisabled(d.Get("disabled"), d, config) if err != nil { return err @@ -760,7 +569,6 @@ func resourceCloudbuildv2ConnectionUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating Connection %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -775,7 +583,6 @@ func resourceCloudbuildv2ConnectionUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -822,8 +629,6 @@ func resourceCloudbuildv2ConnectionDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Connection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -833,7 +638,6 @@ func resourceCloudbuildv2ConnectionDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Connection") @@ -1137,7 +941,7 @@ func flattenCloudbuildv2ConnectionGitlabConfigServerVersion(v interface{}, d *sc return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionInstallationState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil } @@ -1146,255 +950,78 @@ func flattenCloudbuildv2ConnectionBitbucketDataCenterConfig(v interface{}, d *sc return nil } transformed := make(map[string]interface{}) - transformed["host_uri"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigHostUri(original["hostUri"], d, config) - transformed["webhook_secret_secret_version"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigWebhookSecretSecretVersion(original["webhookSecretSecretVersion"], d, config) - transformed["read_authorizer_credential"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredential(original["readAuthorizerCredential"], d, config) - transformed["authorizer_credential"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredential(original["authorizerCredential"], d, config) - transformed["service_directory_config"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfig(original["serviceDirectoryConfig"], d, config) - transformed["ssl_ca"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigSslCa(original["sslCa"], d, config) - transformed["server_version"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigServerVersion(original["serverVersion"], d, config) + transformed["stage"] = + flattenCloudbuildv2ConnectionInstallationStateStage(original["stage"], d, config) + transformed["message"] = + flattenCloudbuildv2ConnectionInstallationStateMessage(original["message"], d, config) + transformed["action_uri"] = + flattenCloudbuildv2ConnectionInstallationStateActionUri(original["actionUri"], d, config) return []interface{}{transformed} } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigHostUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigWebhookSecretSecretVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionInstallationStateStage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredential(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["user_token_secret_version"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUserTokenSecretVersion(original["userTokenSecretVersion"], d, config) - transformed["username"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUsername(original["username"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUserTokenSecretVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionInstallationStateMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUsername(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionInstallationStateActionUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredential(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["user_token_secret_version"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUserTokenSecretVersion(original["userTokenSecretVersion"], d, config) - transformed["username"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUsername(original["username"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUserTokenSecretVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionDisabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUsername(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionReconciling(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + return v } + transformed := make(map[string]interface{}) - transformed["service"] = - flattenCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfigService(original["service"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfigService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + if l, ok := d.GetOkExists("annotations"); ok { + for k := range l.(map[string]interface{}) { + transformed[k] = v.(map[string]interface{})[k] + } + } + + return transformed } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigSslCa(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketDataCenterConfigServerVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { +func flattenCloudbuildv2ConnectionEffectiveAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenCloudbuildv2ConnectionBitbucketCloudConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil +func expandCloudbuildv2ConnectionGithubConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + l := v.([]interface{}) + if len(l) == 0 || l[0] == nil { + return nil, nil } + raw := l[0] + original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) - transformed["workspace"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigWorkspace(original["workspace"], d, config) - transformed["webhook_secret_secret_version"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigWebhookSecretSecretVersion(original["webhookSecretSecretVersion"], d, config) - transformed["read_authorizer_credential"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredential(original["readAuthorizerCredential"], d, config) - transformed["authorizer_credential"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredential(original["authorizerCredential"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionBitbucketCloudConfigWorkspace(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenCloudbuildv2ConnectionBitbucketCloudConfigWebhookSecretSecretVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + transformedAuthorizerCredential, err := expandCloudbuildv2ConnectionGithubConfigAuthorizerCredential(original["authorizer_credential"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAuthorizerCredential); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["authorizerCredential"] = transformedAuthorizerCredential + } -func flattenCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredential(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["user_token_secret_version"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUserTokenSecretVersion(original["userTokenSecretVersion"], d, config) - transformed["username"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUsername(original["username"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUserTokenSecretVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUsername(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredential(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["user_token_secret_version"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUserTokenSecretVersion(original["userTokenSecretVersion"], d, config) - transformed["username"] = - flattenCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUsername(original["username"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUserTokenSecretVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUsername(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionInstallationState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["stage"] = - flattenCloudbuildv2ConnectionInstallationStateStage(original["stage"], d, config) - transformed["message"] = - flattenCloudbuildv2ConnectionInstallationStateMessage(original["message"], d, config) - transformed["action_uri"] = - flattenCloudbuildv2ConnectionInstallationStateActionUri(original["actionUri"], d, config) - return []interface{}{transformed} -} -func flattenCloudbuildv2ConnectionInstallationStateStage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionInstallationStateMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionInstallationStateActionUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionDisabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionReconciling(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("annotations"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenCloudbuildv2ConnectionEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudbuildv2ConnectionEffectiveAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandCloudbuildv2ConnectionGithubConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAuthorizerCredential, err := expandCloudbuildv2ConnectionGithubConfigAuthorizerCredential(original["authorizer_credential"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthorizerCredential); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authorizerCredential"] = transformedAuthorizerCredential - } - - transformedAppInstallationId, err := expandCloudbuildv2ConnectionGithubConfigAppInstallationId(original["app_installation_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAppInstallationId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["appInstallationId"] = transformedAppInstallationId + transformedAppInstallationId, err := expandCloudbuildv2ConnectionGithubConfigAppInstallationId(original["app_installation_id"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedAppInstallationId); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["appInstallationId"] = transformedAppInstallationId } return transformed, nil @@ -1725,290 +1352,6 @@ func expandCloudbuildv2ConnectionGitlabConfigServerVersion(v interface{}, d tpgr return v, nil } -func expandCloudbuildv2ConnectionBitbucketDataCenterConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedHostUri, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigHostUri(original["host_uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedHostUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["hostUri"] = transformedHostUri - } - - transformedWebhookSecretSecretVersion, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigWebhookSecretSecretVersion(original["webhook_secret_secret_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedWebhookSecretSecretVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["webhookSecretSecretVersion"] = transformedWebhookSecretSecretVersion - } - - transformedReadAuthorizerCredential, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredential(original["read_authorizer_credential"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedReadAuthorizerCredential); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["readAuthorizerCredential"] = transformedReadAuthorizerCredential - } - - transformedAuthorizerCredential, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredential(original["authorizer_credential"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthorizerCredential); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authorizerCredential"] = transformedAuthorizerCredential - } - - transformedServiceDirectoryConfig, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfig(original["service_directory_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceDirectoryConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceDirectoryConfig"] = transformedServiceDirectoryConfig - } - - transformedSslCa, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigSslCa(original["ssl_ca"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSslCa); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sslCa"] = transformedSslCa - } - - transformedServerVersion, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigServerVersion(original["server_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServerVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serverVersion"] = transformedServerVersion - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigHostUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigWebhookSecretSecretVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredential(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUserTokenSecretVersion, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUserTokenSecretVersion(original["user_token_secret_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUserTokenSecretVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["userTokenSecretVersion"] = transformedUserTokenSecretVersion - } - - transformedUsername, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUsername(original["username"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["username"] = transformedUsername - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUserTokenSecretVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigReadAuthorizerCredentialUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredential(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUserTokenSecretVersion, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUserTokenSecretVersion(original["user_token_secret_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUserTokenSecretVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["userTokenSecretVersion"] = transformedUserTokenSecretVersion - } - - transformedUsername, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUsername(original["username"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["username"] = transformedUsername - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUserTokenSecretVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigAuthorizerCredentialUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedService, err := expandCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfigService(original["service"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedService); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["service"] = transformedService - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigServiceDirectoryConfigService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigSslCa(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketDataCenterConfigServerVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedWorkspace, err := expandCloudbuildv2ConnectionBitbucketCloudConfigWorkspace(original["workspace"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedWorkspace); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["workspace"] = transformedWorkspace - } - - transformedWebhookSecretSecretVersion, err := expandCloudbuildv2ConnectionBitbucketCloudConfigWebhookSecretSecretVersion(original["webhook_secret_secret_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedWebhookSecretSecretVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["webhookSecretSecretVersion"] = transformedWebhookSecretSecretVersion - } - - transformedReadAuthorizerCredential, err := expandCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredential(original["read_authorizer_credential"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedReadAuthorizerCredential); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["readAuthorizerCredential"] = transformedReadAuthorizerCredential - } - - transformedAuthorizerCredential, err := expandCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredential(original["authorizer_credential"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthorizerCredential); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authorizerCredential"] = transformedAuthorizerCredential - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigWorkspace(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigWebhookSecretSecretVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredential(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUserTokenSecretVersion, err := expandCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUserTokenSecretVersion(original["user_token_secret_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUserTokenSecretVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["userTokenSecretVersion"] = transformedUserTokenSecretVersion - } - - transformedUsername, err := expandCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUsername(original["username"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["username"] = transformedUsername - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUserTokenSecretVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigReadAuthorizerCredentialUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredential(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUserTokenSecretVersion, err := expandCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUserTokenSecretVersion(original["user_token_secret_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUserTokenSecretVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["userTokenSecretVersion"] = transformedUserTokenSecretVersion - } - - transformedUsername, err := expandCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUsername(original["username"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["username"] = transformedUsername - } - - return transformed, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUserTokenSecretVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudbuildv2ConnectionBitbucketCloudConfigAuthorizerCredentialUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandCloudbuildv2ConnectionDisabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go index 75bc2b34038..dc66fd4ef11 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudbuildv2/resource_cloudbuildv2_repository.go @@ -20,7 +20,6 @@ package cloudbuildv2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -173,7 +172,6 @@ func resourceCloudbuildv2RepositoryCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -182,7 +180,6 @@ func resourceCloudbuildv2RepositoryCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Repository: %s", err) @@ -235,14 +232,12 @@ func resourceCloudbuildv2RepositoryRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Cloudbuildv2Repository %q", d.Id())) @@ -301,8 +296,6 @@ func resourceCloudbuildv2RepositoryDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Repository %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -312,7 +305,6 @@ func resourceCloudbuildv2RepositoryDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Repository") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_automation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_automation.go index 5697c31063d..ceca99eae6e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_automation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_automation.go @@ -20,7 +20,6 @@ package clouddeploy import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -325,7 +324,6 @@ func resourceClouddeployAutomationCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -334,7 +332,6 @@ func resourceClouddeployAutomationCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Automation: %s", err) @@ -387,14 +384,12 @@ func resourceClouddeployAutomationRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ClouddeployAutomation %q", d.Id())) @@ -515,7 +510,6 @@ func resourceClouddeployAutomationUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating Automation %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -567,7 +561,6 @@ func resourceClouddeployAutomationUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -615,8 +608,6 @@ func resourceClouddeployAutomationDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Automation %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -626,7 +617,6 @@ func resourceClouddeployAutomationDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Automation") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go index 263fe0c418a..a268989b856 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_custom_target_type.go @@ -20,7 +20,6 @@ package clouddeploy import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -129,32 +128,6 @@ Please refer to the field 'effective_annotations' for all of the annotations pre }, ExactlyOneOf: []string{}, }, - "google_cloud_build_repo": { - Type: schema.TypeList, - Optional: true, - Description: `Cloud Build 2nd gen repository containing the Skaffold Config modules.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "repository": { - Type: schema.TypeString, - Required: true, - Description: `Cloud Build 2nd gen repository in the format of 'projects//locations//connections//repositories/'.`, - }, - "path": { - Type: schema.TypeString, - Optional: true, - Description: `Relative path from the repository root to the Skaffold file.`, - }, - "ref": { - Type: schema.TypeString, - Optional: true, - Description: `Branch or tag to use when cloning the repository.`, - }, - }, - }, - ExactlyOneOf: []string{}, - }, "google_cloud_storage": { Type: schema.TypeList, Optional: true, @@ -308,7 +281,6 @@ func resourceClouddeployCustomTargetTypeCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -317,7 +289,6 @@ func resourceClouddeployCustomTargetTypeCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CustomTargetType: %s", err) @@ -370,14 +341,12 @@ func resourceClouddeployCustomTargetTypeRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ClouddeployCustomTargetType %q", d.Id())) @@ -474,7 +443,6 @@ func resourceClouddeployCustomTargetTypeUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating CustomTargetType %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -514,7 +482,6 @@ func resourceClouddeployCustomTargetTypeUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -562,8 +529,6 @@ func resourceClouddeployCustomTargetTypeDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CustomTargetType %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -573,7 +538,6 @@ func resourceClouddeployCustomTargetTypeDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CustomTargetType") @@ -703,10 +667,9 @@ func flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModules(v int continue } transformed = append(transformed, map[string]interface{}{ - "configs": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesConfigs(original["configs"], d, config), - "git": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGit(original["git"], d, config), - "google_cloud_storage": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudStorage(original["googleCloudStorage"], d, config), - "google_cloud_build_repo": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepo(original["googleCloudBuildRepo"], d, config), + "configs": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesConfigs(original["configs"], d, config), + "git": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGit(original["git"], d, config), + "google_cloud_storage": flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudStorage(original["googleCloudStorage"], d, config), }) } return transformed @@ -767,35 +730,6 @@ func flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogle return v } -func flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepo(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["repository"] = - flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRepository(original["repository"], d, config) - transformed["path"] = - flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoPath(original["path"], d, config) - transformed["ref"] = - flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRef(original["ref"], d, config) - return []interface{}{transformed} -} -func flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRepository(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRef(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenClouddeployCustomTargetTypeEffectiveAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -895,13 +829,6 @@ func expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModules(v inte transformed["googleCloudStorage"] = transformedGoogleCloudStorage } - transformedGoogleCloudBuildRepo, err := expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepo(original["google_cloud_build_repo"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedGoogleCloudBuildRepo); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["googleCloudBuildRepo"] = transformedGoogleCloudBuildRepo - } - req = append(req, transformed) } return req, nil @@ -990,51 +917,6 @@ func expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleC return v, nil } -func expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepo(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedRepository, err := expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRepository(original["repository"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRepository); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["repository"] = transformedRepository - } - - transformedPath, err := expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoPath(original["path"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["path"] = transformedPath - } - - transformedRef, err := expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRef(original["ref"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRef); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["ref"] = transformedRef - } - - return transformed, nil -} - -func expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRepository(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandClouddeployCustomTargetTypeCustomActionsIncludeSkaffoldModulesGoogleCloudBuildRepoRef(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandClouddeployCustomTargetTypeEffectiveAnnotations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go index 45e558609aa..650935df152 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_delivery_pipeline.go @@ -69,7 +69,7 @@ func ResourceClouddeployDeliveryPipeline() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.", + Description: "Name of the `DeliveryPipeline`. Format is [a-z][a-z0-9\\-]{0,62}.", }, "description": { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_target.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_target.go index 5f42cd84bd3..33ea93b3d6d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_target.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddeploy/resource_clouddeploy_target.go @@ -69,7 +69,7 @@ func ResourceClouddeployTarget() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.", + Description: "Name of the `Target`. Format is [a-z][a-z0-9\\-]{0,62}.", }, "anthos_cluster": { @@ -78,16 +78,7 @@ func ResourceClouddeployTarget() *schema.Resource { Description: "Information specifying an Anthos Cluster.", MaxItems: 1, Elem: ClouddeployTargetAnthosClusterSchema(), - ConflictsWith: []string{"gke", "run", "multi_target", "custom_target"}, - }, - - "custom_target": { - Type: schema.TypeList, - Optional: true, - Description: "Optional. Information specifying a Custom Target.", - MaxItems: 1, - Elem: ClouddeployTargetCustomTargetSchema(), - ConflictsWith: []string{"gke", "anthos_cluster", "run", "multi_target"}, + ConflictsWith: []string{"gke", "run", "multi_target"}, }, "deploy_parameters": { @@ -129,7 +120,7 @@ func ResourceClouddeployTarget() *schema.Resource { Description: "Information specifying a GKE Cluster.", MaxItems: 1, Elem: ClouddeployTargetGkeSchema(), - ConflictsWith: []string{"anthos_cluster", "run", "multi_target", "custom_target"}, + ConflictsWith: []string{"anthos_cluster", "run", "multi_target"}, }, "multi_target": { @@ -138,7 +129,7 @@ func ResourceClouddeployTarget() *schema.Resource { Description: "Information specifying a multiTarget.", MaxItems: 1, Elem: ClouddeployTargetMultiTargetSchema(), - ConflictsWith: []string{"gke", "anthos_cluster", "run", "custom_target"}, + ConflictsWith: []string{"gke", "anthos_cluster", "run"}, }, "project": { @@ -162,7 +153,7 @@ func ResourceClouddeployTarget() *schema.Resource { Description: "Information specifying a Cloud Run deployment target.", MaxItems: 1, Elem: ClouddeployTargetRunSchema(), - ConflictsWith: []string{"gke", "anthos_cluster", "multi_target", "custom_target"}, + ConflictsWith: []string{"gke", "anthos_cluster", "multi_target"}, }, "annotations": { @@ -231,19 +222,6 @@ func ClouddeployTargetAnthosClusterSchema() *schema.Resource { } } -func ClouddeployTargetCustomTargetSchema() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "custom_target_type": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: "Required. The name of the CustomTargetType. Format must be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.", - }, - }, - } -} - func ClouddeployTargetExecutionConfigsSchema() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -275,12 +253,6 @@ func ClouddeployTargetExecutionConfigsSchema() *schema.Resource { Description: "Optional. Google service account to use for execution. If unspecified, the project execution service account (-compute@developer.gserviceaccount.com) is used.", }, - "verbose": { - Type: schema.TypeBool, - Optional: true, - Description: "Optional. If true, additional logging will be enabled when running builds in this execution environment.", - }, - "worker_pool": { Type: schema.TypeString, Optional: true, @@ -346,7 +318,6 @@ func resourceClouddeployTargetCreate(d *schema.ResourceData, meta interface{}) e Location: dcl.String(d.Get("location").(string)), Name: dcl.String(d.Get("name").(string)), AnthosCluster: expandClouddeployTargetAnthosCluster(d.Get("anthos_cluster")), - CustomTarget: expandClouddeployTargetCustomTarget(d.Get("custom_target")), DeployParameters: tpgresource.CheckStringMap(d.Get("deploy_parameters")), Description: dcl.String(d.Get("description").(string)), Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")), @@ -407,7 +378,6 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err Location: dcl.String(d.Get("location").(string)), Name: dcl.String(d.Get("name").(string)), AnthosCluster: expandClouddeployTargetAnthosCluster(d.Get("anthos_cluster")), - CustomTarget: expandClouddeployTargetCustomTarget(d.Get("custom_target")), DeployParameters: tpgresource.CheckStringMap(d.Get("deploy_parameters")), Description: dcl.String(d.Get("description").(string)), Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")), @@ -451,9 +421,6 @@ func resourceClouddeployTargetRead(d *schema.ResourceData, meta interface{}) err if err = d.Set("anthos_cluster", flattenClouddeployTargetAnthosCluster(res.AnthosCluster)); err != nil { return fmt.Errorf("error setting anthos_cluster in state: %s", err) } - if err = d.Set("custom_target", flattenClouddeployTargetCustomTarget(res.CustomTarget)); err != nil { - return fmt.Errorf("error setting custom_target in state: %s", err) - } if err = d.Set("deploy_parameters", res.DeployParameters); err != nil { return fmt.Errorf("error setting deploy_parameters in state: %s", err) } @@ -522,7 +489,6 @@ func resourceClouddeployTargetUpdate(d *schema.ResourceData, meta interface{}) e Location: dcl.String(d.Get("location").(string)), Name: dcl.String(d.Get("name").(string)), AnthosCluster: expandClouddeployTargetAnthosCluster(d.Get("anthos_cluster")), - CustomTarget: expandClouddeployTargetCustomTarget(d.Get("custom_target")), DeployParameters: tpgresource.CheckStringMap(d.Get("deploy_parameters")), Description: dcl.String(d.Get("description").(string)), Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")), @@ -578,7 +544,6 @@ func resourceClouddeployTargetDelete(d *schema.ResourceData, meta interface{}) e Location: dcl.String(d.Get("location").(string)), Name: dcl.String(d.Get("name").(string)), AnthosCluster: expandClouddeployTargetAnthosCluster(d.Get("anthos_cluster")), - CustomTarget: expandClouddeployTargetCustomTarget(d.Get("custom_target")), DeployParameters: tpgresource.CheckStringMap(d.Get("deploy_parameters")), Description: dcl.String(d.Get("description").(string)), Annotations: tpgresource.CheckStringMap(d.Get("effective_annotations")), @@ -661,32 +626,6 @@ func flattenClouddeployTargetAnthosCluster(obj *clouddeploy.TargetAnthosCluster) return []interface{}{transformed} -} - -func expandClouddeployTargetCustomTarget(o interface{}) *clouddeploy.TargetCustomTarget { - if o == nil { - return clouddeploy.EmptyTargetCustomTarget - } - objArr := o.([]interface{}) - if len(objArr) == 0 || objArr[0] == nil { - return clouddeploy.EmptyTargetCustomTarget - } - obj := objArr[0].(map[string]interface{}) - return &clouddeploy.TargetCustomTarget{ - CustomTargetType: dcl.String(obj["custom_target_type"].(string)), - } -} - -func flattenClouddeployTargetCustomTarget(obj *clouddeploy.TargetCustomTarget) interface{} { - if obj == nil || obj.Empty() { - return nil - } - transformed := map[string]interface{}{ - "custom_target_type": obj.CustomTargetType, - } - - return []interface{}{transformed} - } func expandClouddeployTargetExecutionConfigsArray(o interface{}) []clouddeploy.TargetExecutionConfigs { if o == nil { @@ -718,7 +657,6 @@ func expandClouddeployTargetExecutionConfigs(o interface{}) *clouddeploy.TargetE ArtifactStorage: dcl.StringOrNil(obj["artifact_storage"].(string)), ExecutionTimeout: dcl.StringOrNil(obj["execution_timeout"].(string)), ServiceAccount: dcl.StringOrNil(obj["service_account"].(string)), - Verbose: dcl.Bool(obj["verbose"].(bool)), WorkerPool: dcl.String(obj["worker_pool"].(string)), } } @@ -746,7 +684,6 @@ func flattenClouddeployTargetExecutionConfigs(obj *clouddeploy.TargetExecutionCo "artifact_storage": obj.ArtifactStorage, "execution_timeout": obj.ExecutionTimeout, "service_account": obj.ServiceAccount, - "verbose": obj.Verbose, "worker_pool": obj.WorkerPool, } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddomains/resource_clouddomains_registration.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddomains/resource_clouddomains_registration.go index 91efc29a3de..682a3b8ad9d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddomains/resource_clouddomains_registration.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/clouddomains/resource_clouddomains_registration.go @@ -20,12 +20,11 @@ package clouddomains import ( "fmt" "log" - "net/http" "reflect" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -35,17 +34,17 @@ import ( // waitForRegistrationActive waits for a registration to leave the // "REGISTRATION_PENDING" state and become "ACTIVE" or any other state. func waitForRegistrationActive(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceClouddomainsRegistrationRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) state := d.Get("state").(string) if state == "REGISTRATION_PENDING" { - return retry.RetryableError(fmt.Errorf("Registration %q has state %q.", name, state)) + return resource.RetryableError(fmt.Errorf("Registration %q has state %q.", name, state)) } else if state == "REGISTRATION_FAILED" { - return retry.NonRetryableError(fmt.Errorf("Registration %q has failed with state %q.", name, state)) + return resource.NonRetryableError(fmt.Errorf("Registration %q has failed with state %q.", name, state)) } else { log.Printf("[DEBUG] Registration %q has state %q.", name, state) return nil @@ -762,7 +761,6 @@ func resourceClouddomainsRegistrationCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -771,7 +769,6 @@ func resourceClouddomainsRegistrationCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Registration: %s", err) @@ -828,14 +825,12 @@ func resourceClouddomainsRegistrationRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ClouddomainsRegistration %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudfunctions2/resource_cloudfunctions2_function.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudfunctions2/resource_cloudfunctions2_function.go index d9f19f333fd..6713f6a628b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudfunctions2/resource_cloudfunctions2_function.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudfunctions2/resource_cloudfunctions2_function.go @@ -20,7 +20,6 @@ package cloudfunctions2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -77,18 +76,6 @@ from the given source.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "automatic_update_policy": { - Type: schema.TypeList, - Computed: true, - Optional: true, - Description: `Security patches are applied automatically to the runtime without requiring -the function to be redeployed.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - ExactlyOneOf: []string{}, - }, "docker_repository": { Type: schema.TypeString, Computed: true, @@ -111,34 +98,12 @@ function exported by the module specified in source_location.`, Description: `User-provided build-time environment variables for the function.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "on_deploy_update_policy": { - Type: schema.TypeList, - Optional: true, - Description: `Security patches are only applied when a function is redeployed.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "runtime_version": { - Type: schema.TypeString, - Computed: true, - Description: `The runtime version which was used during latest function deployment.`, - }, - }, - }, - ExactlyOneOf: []string{}, - }, "runtime": { Type: schema.TypeString, Optional: true, Description: `The runtime in which to run the function. Required when deploying a new function, optional when updating an existing function.`, }, - "service_account": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The fully-qualified name of the service account to be used for building the container.`, - }, "source": { Type: schema.TypeList, Optional: true, @@ -623,11 +588,6 @@ func resourceCloudfunctions2functionCreate(d *schema.ResourceData, meta interfac obj["labels"] = labelsProp } - obj, err = resourceCloudfunctions2functionEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{Cloudfunctions2BasePath}}projects/{{project}}/locations/{{location}}/functions?functionId={{name}}") if err != nil { return err @@ -647,7 +607,6 @@ func resourceCloudfunctions2functionCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -656,7 +615,6 @@ func resourceCloudfunctions2functionCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating function: %s", err) @@ -720,14 +678,12 @@ func resourceCloudfunctions2functionRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Cloudfunctions2function %q", d.Id())) @@ -833,18 +789,12 @@ func resourceCloudfunctions2functionUpdate(d *schema.ResourceData, meta interfac obj["labels"] = labelsProp } - obj, err = resourceCloudfunctions2functionEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{Cloudfunctions2BasePath}}projects/{{project}}/locations/{{location}}/functions/{{name}}") if err != nil { return err } log.Printf("[DEBUG] Updating function %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -892,7 +842,6 @@ func resourceCloudfunctions2functionUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -940,8 +889,6 @@ func resourceCloudfunctions2functionDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting function %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -951,7 +898,6 @@ func resourceCloudfunctions2functionDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "function") @@ -1035,12 +981,6 @@ func flattenCloudfunctions2functionBuildConfig(v interface{}, d *schema.Resource flattenCloudfunctions2functionBuildConfigEnvironmentVariables(original["environmentVariables"], d, config) transformed["docker_repository"] = flattenCloudfunctions2functionBuildConfigDockerRepository(original["dockerRepository"], d, config) - transformed["service_account"] = - flattenCloudfunctions2functionBuildConfigServiceAccount(original["serviceAccount"], d, config) - transformed["automatic_update_policy"] = - flattenCloudfunctions2functionBuildConfigAutomaticUpdatePolicy(original["automaticUpdatePolicy"], d, config) - transformed["on_deploy_update_policy"] = - flattenCloudfunctions2functionBuildConfigOnDeployUpdatePolicy(original["onDeployUpdatePolicy"], d, config) return []interface{}{transformed} } func flattenCloudfunctions2functionBuildConfigBuild(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1204,32 +1144,6 @@ func flattenCloudfunctions2functionBuildConfigDockerRepository(v interface{}, d return v } -func flattenCloudfunctions2functionBuildConfigServiceAccount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudfunctions2functionBuildConfigAutomaticUpdatePolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenCloudfunctions2functionBuildConfigOnDeployUpdatePolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - transformed := make(map[string]interface{}) - transformed["runtime_version"] = - flattenCloudfunctions2functionBuildConfigOnDeployUpdatePolicyRuntimeVersion(original["runtimeVersion"], d, config) - return []interface{}{transformed} -} -func flattenCloudfunctions2functionBuildConfigOnDeployUpdatePolicyRuntimeVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenCloudfunctions2functionServiceConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1673,27 +1587,6 @@ func expandCloudfunctions2functionBuildConfig(v interface{}, d tpgresource.Terra transformed["dockerRepository"] = transformedDockerRepository } - transformedServiceAccount, err := expandCloudfunctions2functionBuildConfigServiceAccount(original["service_account"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAccount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAccount"] = transformedServiceAccount - } - - transformedAutomaticUpdatePolicy, err := expandCloudfunctions2functionBuildConfigAutomaticUpdatePolicy(original["automatic_update_policy"], d, config) - if err != nil { - return nil, err - } else { - transformed["automaticUpdatePolicy"] = transformedAutomaticUpdatePolicy - } - - transformedOnDeployUpdatePolicy, err := expandCloudfunctions2functionBuildConfigOnDeployUpdatePolicy(original["on_deploy_update_policy"], d, config) - if err != nil { - return nil, err - } else { - transformed["onDeployUpdatePolicy"] = transformedOnDeployUpdatePolicy - } - return transformed, nil } @@ -1888,53 +1781,6 @@ func expandCloudfunctions2functionBuildConfigDockerRepository(v interface{}, d t return v, nil } -func expandCloudfunctions2functionBuildConfigServiceAccount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudfunctions2functionBuildConfigAutomaticUpdatePolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandCloudfunctions2functionBuildConfigOnDeployUpdatePolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedRuntimeVersion, err := expandCloudfunctions2functionBuildConfigOnDeployUpdatePolicyRuntimeVersion(original["runtime_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRuntimeVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["runtimeVersion"] = transformedRuntimeVersion - } - - return transformed, nil -} - -func expandCloudfunctions2functionBuildConfigOnDeployUpdatePolicyRuntimeVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandCloudfunctions2functionServiceConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -2432,21 +2278,3 @@ func expandCloudfunctions2functionEffectiveLabels(v interface{}, d tpgresource.T } return m, nil } - -func resourceCloudfunctions2functionEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - if obj == nil || obj["buildConfig"] == nil { - return obj, nil - } - - build_config := obj["buildConfig"].(map[string]interface{}) - - // Automatic Update policy is the default from API, unset it if the data - // contains the on-deploy policy. - if build_config["onDeployUpdatePolicy"] != nil { - delete(build_config, "automaticUpdatePolicy") - } - - obj["buildConfig"] = build_config - - return obj, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group.go index b2857f846da..e3443d4e69e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group.go @@ -20,7 +20,6 @@ package cloudidentity import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -242,7 +241,6 @@ func resourceCloudIdentityGroupCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -251,7 +249,6 @@ func resourceCloudIdentityGroupCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Group: %s", err) @@ -350,14 +347,12 @@ func resourceCloudIdentityGroupRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudIdentityGroup %q", d.Id())) @@ -429,7 +424,6 @@ func resourceCloudIdentityGroupUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Group %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -465,7 +459,6 @@ func resourceCloudIdentityGroupUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -504,8 +497,6 @@ func resourceCloudIdentityGroupDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Group %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -515,7 +506,6 @@ func resourceCloudIdentityGroupDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Group") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group_membership.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group_membership.go index d5e0803910a..23eb454c8db 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group_membership.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudidentity/resource_cloud_identity_group_membership.go @@ -20,7 +20,6 @@ package cloudidentity import ( "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -198,7 +197,6 @@ func resourceCloudIdentityGroupMembershipCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -207,7 +205,6 @@ func resourceCloudIdentityGroupMembershipCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GroupMembership: %s", err) @@ -265,14 +262,12 @@ func resourceCloudIdentityGroupMembershipRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(transformCloudIdentityGroupMembershipReadError(err), d, fmt.Sprintf("CloudIdentityGroupMembership %q", d.Id())) @@ -450,8 +445,6 @@ func resourceCloudIdentityGroupMembershipDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GroupMembership %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -461,7 +454,6 @@ func resourceCloudIdentityGroupMembershipDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GroupMembership") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudids/resource_cloud_ids_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudids/resource_cloud_ids_endpoint.go index b23d2e1fd89..9302e03814a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudids/resource_cloud_ids_endpoint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudids/resource_cloud_ids_endpoint.go @@ -20,7 +20,6 @@ package cloudids import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -183,7 +182,6 @@ func resourceCloudIdsEndpointCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -192,7 +190,6 @@ func resourceCloudIdsEndpointCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Endpoint: %s", err) @@ -259,14 +256,12 @@ func resourceCloudIdsEndpointRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudIdsEndpoint %q", d.Id())) @@ -336,7 +331,6 @@ func resourceCloudIdsEndpointUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Endpoint %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("threat_exceptions") { @@ -364,7 +358,6 @@ func resourceCloudIdsEndpointUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -412,8 +405,6 @@ func resourceCloudIdsEndpointDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Endpoint %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -423,7 +414,6 @@ func resourceCloudIdsEndpointDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Endpoint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudquotas/data_source_google_cloud_quotas_quota_infos.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudquotas/data_source_google_cloud_quotas_quota_infos.go deleted file mode 100644 index 98bf12609bf..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudquotas/data_source_google_cloud_quotas_quota_infos.go +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package cloudquotas - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleCloudQuotasQuotaInfos() *schema.Resource { - return &schema.Resource{ - Read: dataSourceGoogleCloudQuotasQuotaInfosRead, - - Schema: map[string]*schema.Schema{ - "parent": { - Type: schema.TypeString, - Required: true, - }, - "service": { - Type: schema.TypeString, - Required: true, - }, - "quota_infos": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "service": { - Type: schema.TypeString, - Computed: true, - }, - "quota_id": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "metric": { - Type: schema.TypeString, - Computed: true, - }, - "is_precise": { - Type: schema.TypeBool, - Computed: true, - }, - "refresh_interval": { - Type: schema.TypeString, - Computed: true, - }, - "container_type": { - Type: schema.TypeString, - Computed: true, - }, - "dimensions": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "metric_display_name": { - Type: schema.TypeString, - Computed: true, - }, - "quota_display_name": { - Type: schema.TypeString, - Computed: true, - }, - "metric_unit": { - Type: schema.TypeString, - Computed: true, - }, - "quota_increase_eligibility": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_eligible": { - Type: schema.TypeBool, - Computed: true, - }, - "ineligibility_reason": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "is_fixed": { - Type: schema.TypeBool, - Computed: true, - }, - "dimensions_infos": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "dimensions": { - Type: schema.TypeMap, - Computed: true, - }, - "details": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "value": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - "applicable_locations": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - "is_concurrent": { - Type: schema.TypeBool, - Computed: true, - }, - "service_request_quota_uri": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - UseJSONNumber: true, - } -} - -func dataSourceGoogleCloudQuotasQuotaInfosRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{CloudQuotasBasePath}}{{parent}}/locations/global/services/{{service}}/quotaInfos") - if err != nil { - return fmt.Errorf("error setting api endpoint") - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudQuotasQuotaInfo %q", d.Id())) - } - - var quotaInfos []map[string]interface{} - for { - fetchedQuotaInfos := res["quotaInfos"].([]interface{}) - for _, rawQuotaInfo := range fetchedQuotaInfos { - quotaInfos = append(quotaInfos, flattenCloudQuotasQuotaInfo(rawQuotaInfo.(map[string]interface{}), d, config)) - } - - if res["nextPageToken"] == nil || res["nextPageToken"].(string) == "" { - break - } - url, err = tpgresource.ReplaceVars(d, config, "{{CloudQuotasBasePath}}{{parent}}/locations/global/services/{{service}}/quotaInfos?pageToken="+res["nextPageToken"].(string)) - if err != nil { - return fmt.Errorf("error setting api endpoint") - } - res, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return transport_tpg.HandleDataSourceNotFoundError(err, d, fmt.Sprintf("CloudQuotasQuotaInfo %q", d.Id()), url) - } - } - - if err := d.Set("quota_infos", quotaInfos); err != nil { - return fmt.Errorf("error reading quota infos : %s", err) - } - - d.SetId(url) - return nil -} - -func flattenCloudQuotasQuotaInfo(rawQuotaInfo map[string]interface{}, d *schema.ResourceData, config *transport_tpg.Config) map[string]interface{} { - quotaInfo := make(map[string]interface{}) - - quotaInfo["name"] = rawQuotaInfo["name"] - quotaInfo["quota_id"] = rawQuotaInfo["quotaId"] - quotaInfo["metric"] = rawQuotaInfo["metric"] - quotaInfo["service"] = rawQuotaInfo["service"] - quotaInfo["is_precise"] = rawQuotaInfo["isPrecise"] - quotaInfo["refresh_interval"] = rawQuotaInfo["refreshInterval"] - quotaInfo["container_type"] = rawQuotaInfo["containerType"] - quotaInfo["dimensions"] = rawQuotaInfo["dimensions"] - quotaInfo["metric_display_name"] = rawQuotaInfo["metricDisplayName"] - quotaInfo["quota_display_name"] = rawQuotaInfo["quotaDisplayName"] - quotaInfo["metric_unit"] = rawQuotaInfo["metricUnit"] - quotaInfo["quota_increase_eligibility"] = flattenCloudQuotasQuotaInfoQuotaIncreaseEligibility(rawQuotaInfo["quotaIncreaseEligibility"], d, config) - quotaInfo["is_fixed"] = rawQuotaInfo["isFixed"] - quotaInfo["dimensions_infos"] = flattenCloudQuotasQuotaInfoDimensionsInfos(rawQuotaInfo["dimensionsInfos"], d, config) - quotaInfo["is_concurrent"] = rawQuotaInfo["isConcurrent"] - quotaInfo["service_request_quota_uri"] = rawQuotaInfo["serviceRequestQuotaUri"] - - return quotaInfo -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go deleted file mode 100644 index 905787403ea..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudquotas/resource_cloud_quotas_quota_preference.go +++ /dev/null @@ -1,683 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package cloudquotas - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceCloudQuotasQuotaPreference() *schema.Resource { - return &schema.Resource{ - Create: resourceCloudQuotasQuotaPreferenceCreate, - Read: resourceCloudQuotasQuotaPreferenceRead, - Update: resourceCloudQuotasQuotaPreferenceUpdate, - Delete: resourceCloudQuotasQuotaPreferenceDelete, - - Importer: &schema.ResourceImporter{ - State: resourceCloudQuotasQuotaPreferenceImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "parent": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `The parent of the quota preference. Allowed parents are "projects/[project-id / number]" or "folders/[folder-id / number]" or "organizations/[org-id / number]".`, - }, - "quota_config": { - Type: schema.TypeList, - Required: true, - Description: `The preferred quota configuration.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "preferred_value": { - Type: schema.TypeString, - Required: true, - Description: `The preferred value. Must be greater than or equal to -1. If set to -1, it means the value is "unlimited".`, - }, - "annotations": { - Type: schema.TypeMap, - Optional: true, - Description: `The annotations map for clients to store small amounts of arbitrary data. Do not put PII or other sensitive information here. See https://google.aip.dev/128#annotations. - -An object containing a list of "key: value" pairs. Example: '{ "name": "wrench", "mass": "1.3kg", "count": "3" }'.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "granted_value": { - Type: schema.TypeString, - Computed: true, - Description: `Granted quota value.`, - }, - "request_origin": { - Type: schema.TypeString, - Computed: true, - Description: `The origin of the quota preference request.`, - }, - "state_detail": { - Type: schema.TypeString, - Computed: true, - Description: `Optional details about the state of this quota preference.`, - }, - "trace_id": { - Type: schema.TypeString, - Computed: true, - Description: `The trace id that the Google Cloud uses to provision the requested quota. This trace id may be used by the client to contact Cloud support to track the state of a quota preference request. The trace id is only produced for increase requests and is unique for each request. The quota decrease requests do not have a trace id.`, - }, - }, - }, - }, - "quota_id": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The id of the quota to which the quota preference is applied. A quota id is unique in the service. -Example: 'CPUS-per-project-region'.`, - }, - "service": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The name of the service to which the quota preference is applied.`, - }, - "contact_email": { - Type: schema.TypeString, - Optional: true, - Description: `An email address that can be used for quota related communication between the Google Cloud and the user in case the Google Cloud needs further information to make a decision on whether the user preferred quota can be granted. - -The Google account for the email address must have quota update permission for the project, folder or organization this quota preference is for.`, - }, - "dimensions": { - Type: schema.TypeMap, - Computed: true, - Optional: true, - Description: `The dimensions that this quota preference applies to. The key of the map entry is the name of a dimension, such as "region", "zone", "network_id", and the value of the map entry is the dimension value. If a dimension is missing from the map of dimensions, the quota preference applies to all the dimension values except for those that have other quota preferences configured for the specific value. - -NOTE: QuotaPreferences can only be applied across all values of "user" and "resource" dimension. Do not set values for "user" or "resource" in the dimension map. - -Example: '{"provider": "Foo Inc"}' where "provider" is a service specific dimension.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "ignore_safety_checks": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"QUOTA_SAFETY_CHECK_UNSPECIFIED", "QUOTA_DECREASE_BELOW_USAGE", "QUOTA_DECREASE_PERCENTAGE_TOO_HIGH", ""}), - Description: `The list of quota safety checks to be ignored. Default value: "QUOTA_SAFETY_CHECK_UNSPECIFIED" Possible values: ["QUOTA_SAFETY_CHECK_UNSPECIFIED", "QUOTA_DECREASE_BELOW_USAGE", "QUOTA_DECREASE_PERCENTAGE_TOO_HIGH"]`, - Default: "QUOTA_SAFETY_CHECK_UNSPECIFIED", - }, - "justification": { - Type: schema.TypeString, - Optional: true, - Description: `The reason / justification for this quota preference.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Optional: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The resource name of the quota preference. Required except in the CREATE requests.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Create time stamp. -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'.`, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - Description: `The current etag of the quota preference. If an etag is provided on update and does not match the current server's etag of the quota preference, the request will be blocked and an ABORTED error will be returned. See https://google.aip.dev/134#etags for more details on etags.`, - }, - "reconciling": { - Type: schema.TypeBool, - Computed: true, - Description: `Is the quota preference pending Google Cloud approval and fulfillment.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Update time stamp. -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'.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceCloudQuotasQuotaPreferenceCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - nameProp, err := expandCloudQuotasQuotaPreferenceName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - serviceProp, err := expandCloudQuotasQuotaPreferenceService(d.Get("service"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("service"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceProp)) && (ok || !reflect.DeepEqual(v, serviceProp)) { - obj["service"] = serviceProp - } - quotaIdProp, err := expandCloudQuotasQuotaPreferenceQuotaId(d.Get("quota_id"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("quota_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(quotaIdProp)) && (ok || !reflect.DeepEqual(v, quotaIdProp)) { - obj["quotaId"] = quotaIdProp - } - quotaConfigProp, err := expandCloudQuotasQuotaPreferenceQuotaConfig(d.Get("quota_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("quota_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(quotaConfigProp)) && (ok || !reflect.DeepEqual(v, quotaConfigProp)) { - obj["quotaConfig"] = quotaConfigProp - } - dimensionsProp, err := expandCloudQuotasQuotaPreferenceDimensions(d.Get("dimensions"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dimensions"); !tpgresource.IsEmptyValue(reflect.ValueOf(dimensionsProp)) && (ok || !reflect.DeepEqual(v, dimensionsProp)) { - obj["dimensions"] = dimensionsProp - } - justificationProp, err := expandCloudQuotasQuotaPreferenceJustification(d.Get("justification"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("justification"); !tpgresource.IsEmptyValue(reflect.ValueOf(justificationProp)) && (ok || !reflect.DeepEqual(v, justificationProp)) { - obj["justification"] = justificationProp - } - contactEmailProp, err := expandCloudQuotasQuotaPreferenceContactEmail(d.Get("contact_email"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("contact_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(contactEmailProp)) && (ok || !reflect.DeepEqual(v, contactEmailProp)) { - obj["contactEmail"] = contactEmailProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{CloudQuotasBasePath}}{{parent}}/locations/global/quotaPreferences?quotaPreferenceId={{name}}&ignoreSafetyChecks={{ignore_safety_checks}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new QuotaPreference: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating QuotaPreference: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/global/quotaPreferences/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating QuotaPreference %q: %#v", d.Id(), res) - - return resourceCloudQuotasQuotaPreferenceRead(d, meta) -} - -func resourceCloudQuotasQuotaPreferenceRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{CloudQuotasBasePath}}{{parent}}/locations/global/quotaPreferences/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudQuotasQuotaPreference %q", d.Id())) - } - - if err := d.Set("name", flattenCloudQuotasQuotaPreferenceName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("service", flattenCloudQuotasQuotaPreferenceService(res["service"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("quota_id", flattenCloudQuotasQuotaPreferenceQuotaId(res["quotaId"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("quota_config", flattenCloudQuotasQuotaPreferenceQuotaConfig(res["quotaConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("dimensions", flattenCloudQuotasQuotaPreferenceDimensions(res["dimensions"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("etag", flattenCloudQuotasQuotaPreferenceEtag(res["etag"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("create_time", flattenCloudQuotasQuotaPreferenceCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("update_time", flattenCloudQuotasQuotaPreferenceUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - if err := d.Set("reconciling", flattenCloudQuotasQuotaPreferenceReconciling(res["reconciling"], d, config)); err != nil { - return fmt.Errorf("Error reading QuotaPreference: %s", err) - } - - return nil -} - -func resourceCloudQuotasQuotaPreferenceUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - nameProp, err := expandCloudQuotasQuotaPreferenceName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - serviceProp, err := expandCloudQuotasQuotaPreferenceService(d.Get("service"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("service"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, serviceProp)) { - obj["service"] = serviceProp - } - quotaIdProp, err := expandCloudQuotasQuotaPreferenceQuotaId(d.Get("quota_id"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("quota_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, quotaIdProp)) { - obj["quotaId"] = quotaIdProp - } - quotaConfigProp, err := expandCloudQuotasQuotaPreferenceQuotaConfig(d.Get("quota_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("quota_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, quotaConfigProp)) { - obj["quotaConfig"] = quotaConfigProp - } - dimensionsProp, err := expandCloudQuotasQuotaPreferenceDimensions(d.Get("dimensions"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dimensions"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dimensionsProp)) { - obj["dimensions"] = dimensionsProp - } - justificationProp, err := expandCloudQuotasQuotaPreferenceJustification(d.Get("justification"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("justification"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, justificationProp)) { - obj["justification"] = justificationProp - } - contactEmailProp, err := expandCloudQuotasQuotaPreferenceContactEmail(d.Get("contact_email"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("contact_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, contactEmailProp)) { - obj["contactEmail"] = contactEmailProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{CloudQuotasBasePath}}{{parent}}/locations/global/quotaPreferences/{{name}}?ignoreSafetyChecks={{ignore_safety_checks}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating QuotaPreference %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("name") { - updateMask = append(updateMask, "name") - } - - if d.HasChange("service") { - updateMask = append(updateMask, "service") - } - - if d.HasChange("quota_id") { - updateMask = append(updateMask, "quotaId") - } - - if d.HasChange("quota_config") { - updateMask = append(updateMask, "quotaConfig") - } - - if d.HasChange("dimensions") { - updateMask = append(updateMask, "dimensions") - } - - if d.HasChange("justification") { - updateMask = append(updateMask, "justification") - } - - if d.HasChange("contact_email") { - updateMask = append(updateMask, "contactEmail") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating QuotaPreference %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating QuotaPreference %q: %#v", d.Id(), res) - } - - } - - return resourceCloudQuotasQuotaPreferenceRead(d, meta) -} - -func resourceCloudQuotasQuotaPreferenceDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[WARNING] CloudQuotas QuotaPreference resources"+ - " cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+ - " state, but will still be present on Google Cloud.", d.Id()) - d.SetId("") - - return nil -} - -func resourceCloudQuotasQuotaPreferenceImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P.+)/locations/global/quotaPreferences/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/global/quotaPreferences/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenCloudQuotasQuotaPreferenceName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenCloudQuotasQuotaPreferenceService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceQuotaId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceQuotaConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["preferred_value"] = - flattenCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(original["preferredValue"], d, config) - transformed["state_detail"] = - flattenCloudQuotasQuotaPreferenceQuotaConfigStateDetail(original["stateDetail"], d, config) - transformed["granted_value"] = - flattenCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(original["grantedValue"], d, config) - transformed["trace_id"] = - flattenCloudQuotasQuotaPreferenceQuotaConfigTraceId(original["traceId"], d, config) - transformed["annotations"] = - flattenCloudQuotasQuotaPreferenceQuotaConfigAnnotations(original["annotations"], d, config) - transformed["request_origin"] = - flattenCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(original["requestOrigin"], d, config) - return []interface{}{transformed} -} -func flattenCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceQuotaConfigStateDetail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceQuotaConfigTraceId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceQuotaConfigAnnotations(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // ignore read on this field - return d.Get("quota_config.0.annotations") -} - -func flattenCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceDimensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenCloudQuotasQuotaPreferenceReconciling(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandCloudQuotasQuotaPreferenceName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return tpgresource.GetResourceNameFromSelfLink(v.(string)), nil -} - -func expandCloudQuotasQuotaPreferenceService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPreferredValue, err := expandCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(original["preferred_value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPreferredValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["preferredValue"] = transformedPreferredValue - } - - transformedStateDetail, err := expandCloudQuotasQuotaPreferenceQuotaConfigStateDetail(original["state_detail"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStateDetail); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["stateDetail"] = transformedStateDetail - } - - transformedGrantedValue, err := expandCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(original["granted_value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedGrantedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["grantedValue"] = transformedGrantedValue - } - - transformedTraceId, err := expandCloudQuotasQuotaPreferenceQuotaConfigTraceId(original["trace_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTraceId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["traceId"] = transformedTraceId - } - - transformedAnnotations, err := expandCloudQuotasQuotaPreferenceQuotaConfigAnnotations(original["annotations"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAnnotations); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["annotations"] = transformedAnnotations - } - - transformedRequestOrigin, err := expandCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(original["request_origin"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequestOrigin); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requestOrigin"] = transformedRequestOrigin - } - - return transformed, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfigPreferredValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfigStateDetail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfigGrantedValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfigTraceId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfigAnnotations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} - -func expandCloudQuotasQuotaPreferenceQuotaConfigRequestOrigin(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceDimensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} - -func expandCloudQuotasQuotaPreferenceJustification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandCloudQuotasQuotaPreferenceContactEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_domain_mapping.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_domain_mapping.go index 68838d096cf..023bab4945c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_domain_mapping.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_domain_mapping.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -359,7 +358,6 @@ func resourceCloudRunDomainMappingCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -368,7 +366,6 @@ func resourceCloudRunDomainMappingCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) if err != nil { @@ -468,14 +465,12 @@ func resourceCloudRunDomainMappingRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) if err != nil { @@ -538,8 +533,6 @@ func resourceCloudRunDomainMappingDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DomainMapping %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -549,7 +542,6 @@ func resourceCloudRunDomainMappingDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_service.go index e177877c05e..a31227fa90d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrun/resource_cloud_run_service.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -1217,7 +1216,6 @@ func resourceCloudRunServiceCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1226,7 +1224,6 @@ func resourceCloudRunServiceCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) if err != nil { @@ -1326,14 +1323,12 @@ func resourceCloudRunServiceRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) if err != nil { @@ -1427,7 +1422,6 @@ func resourceCloudRunServiceUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Service %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1442,7 +1436,6 @@ func resourceCloudRunServiceUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) @@ -1487,8 +1480,6 @@ func resourceCloudRunServiceDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Service %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1498,7 +1489,6 @@ func resourceCloudRunServiceDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsCloudRunCreationConflict}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_job.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_job.go index c8bb773541a..2081a30de67 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_job.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_job.go @@ -20,7 +20,6 @@ package cloudrunv2 import ( "fmt" "log" - "net/http" "reflect" "time" @@ -256,10 +255,9 @@ If omitted, a port number will be chosen and passed to the container through the Description: `Email address of the IAM service account associated with the Task of a Job. The service account represents the identity of the running task, and determines what permissions the task has. If not provided, the task will use the project's default service account.`, }, "timeout": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: verify.ValidateRegexp(`^[0-9]+(?:\.[0-9]{1,9})?s$`), + Type: schema.TypeString, + Computed: true, + Optional: true, Description: `Max allowed time duration the Task may be active before the system will actively try to mark it failed and kill associated containers. This applies per attempt of a task, meaning each retry can run for the full timeout. A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, @@ -798,7 +796,6 @@ func resourceCloudRunV2JobCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -807,7 +804,6 @@ func resourceCloudRunV2JobCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Job: %s", err) @@ -827,6 +823,9 @@ func resourceCloudRunV2JobCreate(d *schema.ResourceData, meta interface{}) error config, res, &opRes, project, "Creating Job", userAgent, d.Timeout(schema.TimeoutCreate)) if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create Job: %s", err) } @@ -867,14 +866,12 @@ func resourceCloudRunV2JobRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudRunV2Job %q", d.Id())) @@ -1028,7 +1025,6 @@ func resourceCloudRunV2JobUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Job %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1043,7 +1039,6 @@ func resourceCloudRunV2JobUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1090,8 +1085,6 @@ func resourceCloudRunV2JobDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Job %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1101,7 +1094,6 @@ func resourceCloudRunV2JobDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Job") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_service.go index cc95a7b5268..43353baf5a6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2/resource_cloud_run_v2_service.go @@ -20,7 +20,6 @@ package cloudrunv2 import ( "fmt" "log" - "net/http" "reflect" "time" @@ -302,7 +301,6 @@ is the value of container.ports[0].containerPort.`, Description: `List of ports to expose from the container. Only a single port can be specified. The specified ports must be listening on all interfaces (0.0.0.0) within the container to be accessible. If omitted, a port number will be chosen and passed to the container through the PORT environment variable for the container to listen on`, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "container_port": { @@ -559,10 +557,9 @@ All system labels in v1 now have a corresponding field in v2 RevisionTemplate.`, Description: `Enables session affinity. For more information, go to https://cloud.google.com/run/docs/configuring/session-affinity`, }, "timeout": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: verify.ValidateRegexp(`^[0-9]+(?:\.[0-9]{1,9})?s$`), + Type: schema.TypeString, + Computed: true, + Optional: true, Description: `Max allowed time for an instance to respond to a request. A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, @@ -600,7 +597,7 @@ A duration in seconds with up to nine fractional digits, ending with 's'. Exampl "gcs": { Type: schema.TypeList, Optional: true, - Description: `Cloud Storage bucket mounted as a volume using GCSFuse. This feature is only supported in the gen2 execution environment and requires launch-stage to be set to ALPHA or BETA.`, + Description: `Represents a GCS Bucket mounted as a volume.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -1201,7 +1198,6 @@ func resourceCloudRunV2ServiceCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1210,7 +1206,6 @@ func resourceCloudRunV2ServiceCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Service: %s", err) @@ -1230,6 +1225,9 @@ func resourceCloudRunV2ServiceCreate(d *schema.ResourceData, meta interface{}) e config, res, &opRes, project, "Creating Service", userAgent, d.Timeout(schema.TimeoutCreate)) if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error waiting to create Service: %s", err) } @@ -1270,14 +1268,12 @@ func resourceCloudRunV2ServiceRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudRunV2Service %q", d.Id())) @@ -1473,7 +1469,6 @@ func resourceCloudRunV2ServiceUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Service %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1488,7 +1483,6 @@ func resourceCloudRunV2ServiceUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1535,8 +1529,6 @@ func resourceCloudRunV2ServiceDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Service %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1546,7 +1538,6 @@ func resourceCloudRunV2ServiceDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Service") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudscheduler/resource_cloud_scheduler_job.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudscheduler/resource_cloud_scheduler_job.go index 8488216583b..17e46d480fb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudscheduler/resource_cloud_scheduler_job.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudscheduler/resource_cloud_scheduler_job.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -53,20 +52,6 @@ func validateAuthHeaders(_ context.Context, diff *schema.ResourceDiff, v interfa return nil } -// Suppress diffs in below cases -// "https://hello-rehvs75zla-uc.a.run.app/" -> "https://hello-rehvs75zla-uc.a.run.app" -// "https://hello-rehvs75zla-uc.a.run.app" -> "https://hello-rehvs75zla-uc.a.run.app/" -func LastSlashDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { - if last := len(new) - 1; last >= 0 && new[last] == '/' { - new = new[:last] - } - - if last := len(old) - 1; last >= 0 && old[last] == '/' { - old = old[:last] - } - return new == old -} - func authHeaderDiffSuppress(k, old, new string, d *schema.ResourceData) bool { // If generating an `oauth_token` and `scope` is not provided in the configuration, // the default "https://www.googleapis.com/auth/cloud-platform" scope will be used. @@ -256,7 +241,7 @@ send a request to the targeted url`, "uri": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: LastSlashDiffSuppress, + DiffSuppressFunc: tpgresource.LastSlashDiffSuppress, Description: `The full URI path that the request will be sent to.`, }, "body": { @@ -561,7 +546,6 @@ func resourceCloudSchedulerJobCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -570,7 +554,6 @@ func resourceCloudSchedulerJobCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Job: %s", err) @@ -643,14 +626,12 @@ func resourceCloudSchedulerJobRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudSchedulerJob %q", d.Id())) @@ -787,7 +768,6 @@ func resourceCloudSchedulerJobUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Job %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -802,7 +782,6 @@ func resourceCloudSchedulerJobUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -874,8 +853,6 @@ func resourceCloudSchedulerJobDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Job %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -885,7 +862,6 @@ func resourceCloudSchedulerJobDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Job") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudtasks/resource_cloud_tasks_queue.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudtasks/resource_cloud_tasks_queue.go index ea82fe4b1a5..a08ade87ab1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudtasks/resource_cloud_tasks_queue.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/cloudtasks/resource_cloud_tasks_queue.go @@ -20,7 +20,6 @@ package cloudtasks import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -310,7 +309,6 @@ func resourceCloudTasksQueueCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -319,7 +317,6 @@ func resourceCloudTasksQueueCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Queue: %s", err) @@ -362,14 +359,12 @@ func resourceCloudTasksQueueRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CloudTasksQueue %q", d.Id())) @@ -445,7 +440,6 @@ func resourceCloudTasksQueueUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Queue %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("app_engine_routing_override") { @@ -485,7 +479,6 @@ func resourceCloudTasksQueueUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -526,8 +519,6 @@ func resourceCloudTasksQueueDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Queue %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -537,7 +528,6 @@ func resourceCloudTasksQueueDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Queue") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/data_source_google_composer_user_workloads_config_map.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/data_source_google_composer_user_workloads_config_map.go deleted file mode 100644 index 3b97c5ec34e..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/data_source_google_composer_user_workloads_config_map.go +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package composer diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/data_source_google_composer_user_workloads_secret.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/data_source_google_composer_user_workloads_secret.go deleted file mode 100644 index 3b97c5ec34e..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/data_source_google_composer_user_workloads_secret.go +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package composer diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_environment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_environment.go index c9d47864b66..0a5be2b96c1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_environment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_environment.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "log" - "net" "regexp" "strings" "time" @@ -156,10 +155,6 @@ func ResourceComposerEnvironment() *schema.Resource { tpgresource.DefaultProviderProject, tpgresource.DefaultProviderRegion, tpgresource.SetLabelsDiff, - customdiff.Sequence( - customdiff.ValidateChange("config.0.software_config.0.image_version", imageVersionChangeValidationFunc), - versionValidationCustomizeDiffFunc, - ), ), Schema: map[string]*schema.Schema{ @@ -420,6 +415,7 @@ func ResourceComposerEnvironment() *schema.Resource { Type: schema.TypeString, Computed: true, Optional: true, + ForceNew: true, AtLeastOneOf: composerSoftwareConfigKeys, ValidateFunc: verify.ValidateRegexp(composerEnvironmentVersionRegexp), DiffSuppressFunc: composerImageVersionDiffSuppress, @@ -1075,21 +1071,6 @@ func resourceComposerEnvironmentUpdate(d *schema.ResourceData, meta interface{}) return err } - if d.HasChange("config.0.software_config.0.image_version") { - patchObj := &composer.Environment{ - Config: &composer.EnvironmentConfig{ - SoftwareConfig: &composer.SoftwareConfig{}, - }, - } - if config != nil && config.SoftwareConfig != nil { - patchObj.Config.SoftwareConfig.ImageVersion = config.SoftwareConfig.ImageVersion - } - err = resourceComposerEnvironmentPatchField("config.softwareConfig.imageVersion", userAgent, patchObj, d, tfConfig) - if err != nil { - return err - } - } - if d.HasChange("config.0.software_config.0.scheduler_count") { patchObj := &composer.Environment{ Config: &composer.EnvironmentConfig{ @@ -2688,17 +2669,3 @@ func versionValidationCustomizeDiffFunc(ctx context.Context, d *schema.ResourceD } return nil } - -func validateComposerInternalIpv4CidrBlock(v any, k string) (warns []string, errs []error) { - cidr_range := v.(string) - _, ip_net, err := net.ParseCIDR(cidr_range) - if err != nil { - errs = append(errs, fmt.Errorf("Invalid CIDR range: %s", err)) - return - } - ones, _ := ip_net.Mask.Size() - if ones != 20 { - errs = append(errs, fmt.Errorf("Composer Internal IPv4 CIDR range must have size /20")) - } - return -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_user_workloads_secret.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_user_workloads_secret.go deleted file mode 100644 index 3b97c5ec34e..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/composer/resource_composer_user_workloads_secret.go +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package composer diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/compute_instance_helpers.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/compute_instance_helpers.go index 58b022cf3b5..30c1380ede7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/compute_instance_helpers.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/compute_instance_helpers.go @@ -131,23 +131,6 @@ func expandScheduling(v interface{}) (*compute.Scheduling, error) { scheduling.InstanceTerminationAction = v.(string) scheduling.ForceSendFields = append(scheduling.ForceSendFields, "InstanceTerminationAction") } - if v, ok := original["max_run_duration"]; ok { - transformedMaxRunDuration, err := expandComputeMaxRunDuration(v) - if err != nil { - return nil, err - } - scheduling.MaxRunDuration = transformedMaxRunDuration - scheduling.ForceSendFields = append(scheduling.ForceSendFields, "MaxRunDuration") - } - - if v, ok := original["on_instance_stop_action"]; ok { - transformedOnInstanceStopAction, err := expandComputeOnInstanceStopAction(v) - if err != nil { - return nil, err - } - scheduling.OnInstanceStopAction = transformedOnInstanceStopAction - scheduling.ForceSendFields = append(scheduling.ForceSendFields, "OnInstanceStopAction") - } if v, ok := original["local_ssd_recovery_timeout"]; ok { transformedLocalSsdRecoveryTimeout, err := expandComputeLocalSsdRecoveryTimeout(v) if err != nil { @@ -159,58 +142,6 @@ func expandScheduling(v interface{}) (*compute.Scheduling, error) { return scheduling, nil } -func expandComputeMaxRunDuration(v interface{}) (*compute.Duration, error) { - l := v.([]interface{}) - duration := compute.Duration{} - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - - transformedNanos, err := expandComputeMaxRunDurationNanos(original["nanos"]) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedNanos); val.IsValid() && !tpgresource.IsEmptyValue(val) { - duration.Nanos = int64(transformedNanos.(int)) - } - - transformedSeconds, err := expandComputeMaxRunDurationSeconds(original["seconds"]) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeconds); val.IsValid() && !tpgresource.IsEmptyValue(val) { - duration.Seconds = int64(transformedSeconds.(int)) - } - - return &duration, nil -} - -func expandComputeMaxRunDurationNanos(v interface{}) (interface{}, error) { - return v, nil -} - -func expandComputeMaxRunDurationSeconds(v interface{}) (interface{}, error) { - return v, nil -} - -func expandComputeOnInstanceStopAction(v interface{}) (*compute.SchedulingOnInstanceStopAction, error) { - l := v.([]interface{}) - onInstanceStopAction := compute.SchedulingOnInstanceStopAction{} - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - - if d, ok := original["discard_local_ssd"]; ok { - onInstanceStopAction.DiscardLocalSsd = d.(bool) - } else { - return nil, nil - } - - return &onInstanceStopAction, nil -} - func expandComputeLocalSsdRecoveryTimeout(v interface{}) (*compute.Duration, error) { l := v.([]interface{}) duration := compute.Duration{} @@ -257,14 +188,6 @@ func flattenScheduling(resp *compute.Scheduling) []map[string]interface{} { schedulingMap["automatic_restart"] = *resp.AutomaticRestart } - if resp.MaxRunDuration != nil { - schedulingMap["max_run_duration"] = flattenComputeMaxRunDuration(resp.MaxRunDuration) - } - - if resp.OnInstanceStopAction != nil { - schedulingMap["on_instance_stop_action"] = flattenOnInstanceStopAction(resp.OnInstanceStopAction) - } - if resp.LocalSsdRecoveryTimeout != nil { schedulingMap["local_ssd_recovery_timeout"] = flattenComputeLocalSsdRecoveryTimeout(resp.LocalSsdRecoveryTimeout) } @@ -282,25 +205,6 @@ func flattenScheduling(resp *compute.Scheduling) []map[string]interface{} { return []map[string]interface{}{schedulingMap} } -func flattenComputeMaxRunDuration(v *compute.Duration) []interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - transformed["nanos"] = v.Nanos - transformed["seconds"] = v.Seconds - return []interface{}{transformed} -} - -func flattenOnInstanceStopAction(v *compute.SchedulingOnInstanceStopAction) []interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - transformed["discard_local_ssd"] = v.DiscardLocalSsd - return []interface{}{transformed} -} - func flattenComputeLocalSsdRecoveryTimeout(v *compute.Duration) []interface{} { if v == nil { return nil @@ -549,7 +453,6 @@ func expandConfidentialInstanceConfig(d tpgresource.TerraformResourceData) *comp prefix := "confidential_instance_config.0" return &compute.ConfidentialInstanceConfig{ EnableConfidentialCompute: d.Get(prefix + ".enable_confidential_compute").(bool), - ConfidentialInstanceType: d.Get(prefix + ".confidential_instance_type").(string), } } @@ -560,7 +463,6 @@ func flattenConfidentialInstanceConfig(ConfidentialInstanceConfig *compute.Confi return []map[string]interface{}{{ "enable_confidential_compute": ConfidentialInstanceConfig.EnableConfidentialCompute, - "confidential_instance_type": ConfidentialInstanceConfig.ConfidentialInstanceType, }} } @@ -624,7 +526,7 @@ func schedulingHasChangeRequiringReboot(d *schema.ResourceData) bool { oScheduling := o.([]interface{})[0].(map[string]interface{}) newScheduling := n.([]interface{})[0].(map[string]interface{}) - return hasNodeAffinitiesChanged(oScheduling, newScheduling) || hasMaxRunDurationChanged(oScheduling, newScheduling) + return hasNodeAffinitiesChanged(oScheduling, newScheduling) } // Terraform doesn't correctly calculate changes on schema.Set, so we do it manually @@ -655,35 +557,15 @@ func schedulingHasChangeWithoutReboot(d *schema.ResourceData) bool { return true } - if oScheduling["provisioning_model"] != newScheduling["provisioning_model"] { + if oScheduling["min_node_cpus"] != newScheduling["min_node_cpus"] { return true } - if oScheduling["instance_termination_action"] != newScheduling["instance_termination_action"] { - return true - } - - return false -} - -func hasMaxRunDurationChanged(oScheduling, nScheduling map[string]interface{}) bool { - oMrd := oScheduling["max_run_duration"].([]interface{}) - nMrd := nScheduling["max_run_duration"].([]interface{}) - - if (len(oMrd) == 0 || oMrd[0] == nil) && (len(nMrd) == 0 || nMrd[0] == nil) { - return false - } - if (len(oMrd) == 0 || oMrd[0] == nil) || (len(nMrd) == 0 || nMrd[0] == nil) { + if oScheduling["provisioning_model"] != newScheduling["provisioning_model"] { return true } - oldMrd := oMrd[0].(map[string]interface{}) - newMrd := nMrd[0].(map[string]interface{}) - - if oldMrd["seconds"] != newMrd["seconds"] { - return true - } - if oldMrd["nanos"] != newMrd["nanos"] { + if oScheduling["instance_termination_action"] != newScheduling["instance_termination_action"] { return true } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/data_source_compute_secutity_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/data_source_compute_secutity_policy.go deleted file mode 100644 index 74b9d7f9347..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/data_source_compute_secutity_policy.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package compute - -import ( - "errors" - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleComputeSecurityPolicy() *schema.Resource { - // Generate datasource schema from resource - dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceComputeSecurityPolicy().Schema) - - // Set 'Optional' schema elements - tpgresource.AddOptionalFieldsToSchema(dsSchema, "name") - tpgresource.AddOptionalFieldsToSchema(dsSchema, "project") - tpgresource.AddOptionalFieldsToSchema(dsSchema, "self_link") - - return &schema.Resource{ - Read: dataSourceComputSecurityPolicyRead, - Schema: dsSchema, - } -} - -func dataSourceComputSecurityPolicyRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - id := "" - - if name, ok := d.GetOk("name"); ok { - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - - id = fmt.Sprintf("projects/%s/global/securityPolicies/%s", project, name.(string)) - d.SetId(id) - } else if selfLink, ok := d.GetOk("self_link"); ok { - parsed, err := tpgresource.ParseSecurityPolicyFieldValue(selfLink.(string), d, config) - if err != nil { - return err - } - - if err := d.Set("name", parsed.Name); err != nil { - return fmt.Errorf("Error setting name: %s", err) - } - - if err := d.Set("project", parsed.Project); err != nil { - return fmt.Errorf("Error setting project: %s", err) - } - - id = fmt.Sprintf("projects/%s/global/securityPolicies/%s", parsed.Project, parsed.Name) - d.SetId(id) - } else { - return errors.New("Must provide either `self_link` or `name`") - } - - err := resourceComputeSecurityPolicyRead(d, meta) - if err != nil { - return err - } - - if d.Id() == "" { - return fmt.Errorf("%s not found", id) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/data_source_google_compute_subnetworks.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/data_source_google_compute_subnetworks.go deleted file mode 100644 index e694fa2cd59..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/data_source_google_compute_subnetworks.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package compute - -import ( - "fmt" - "path/filepath" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleComputeSubnetworks() *schema.Resource { - return &schema.Resource{ - Read: dataSourceGoogleComputeSubnetworksRead, - - Schema: map[string]*schema.Schema{ - "filter": { - Type: schema.TypeString, - Optional: true, - }, - "project": { - Type: schema.TypeString, - Optional: true, - }, - "region": { - Type: schema.TypeString, - Optional: true, - }, - "subnetworks": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Computed: true, - }, - "ip_cidr_range": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "network": { - Type: schema.TypeString, - Computed: true, - }, - "network_self_link": { - Type: schema.TypeString, - Computed: true, - }, - "private_ip_google_access": { - Type: schema.TypeBool, - Computed: true, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func dataSourceGoogleComputeSubnetworksRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for subnetwork: %s", err) - } - - region, err := tpgresource.GetRegion(d, config) - if err != nil { - return fmt.Errorf("Error fetching region for subnetwork: %s", err) - } - - filter := d.Get("filter").(string) - - subnetworks := make([]map[string]interface{}, 0) - - subnetworkList, err := config.NewComputeClient(userAgent).Subnetworks.List(project, region).Filter(filter).Do() - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Subnetworks : %s %s", project, region)) - } - - for _, subnet := range subnetworkList.Items { - subnetworks = append(subnetworks, map[string]interface{}{ - "description": subnet.Description, - "ip_cidr_range": subnet.IpCidrRange, - "name": subnet.Name, - "network_self_link": filepath.Base(subnet.Network), - "network": subnet.Network, - "private_ip_google_access": subnet.PrivateIpGoogleAccess, - "self_link": subnet.SelfLink, - }) - } - - if err := d.Set("subnetworks", subnetworks); err != nil { - return fmt.Errorf("Error retrieving subnetworks: %s", err) - } - - d.SetId(fmt.Sprintf( - "projects/%s/regions/%s/subnetworks", - project, - region, - )) - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/image.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/image.go index 0da0d39f419..df985b333a6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/image.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/image.go @@ -32,7 +32,7 @@ var ( resolveImageLink = regexp.MustCompile(fmt.Sprintf("^https://www.googleapis.com/compute/[a-z0-9]+/projects/(%s)/global/images/(%s)", verify.ProjectRegex, resolveImageImageRegex)) windowsSqlImage = regexp.MustCompile("^sql-(?:server-)?([0-9]{4})-([a-z]+)-windows-(?:server-)?([0-9]{4})(?:-r([0-9]+))?-dc-v[0-9]+$") - canonicalUbuntuLtsImage = regexp.MustCompile("^ubuntu-(minimal-)?([0-9]+)(?:.*(arm64|amd64))?.*$") + canonicalUbuntuLtsImage = regexp.MustCompile("^ubuntu-(minimal-)?([0-9]+)(?:.*(arm64))?.*$") cosLtsImage = regexp.MustCompile("^cos-([0-9]+)-") ) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_address.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_address.go index 2178086bb42..91877d75d34 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_address.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_address.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -167,6 +166,7 @@ configuration. These addresses are regional resources. configure Private Service Connect. Only global internal addresses can use this purpose. + This should only be set when using an Internal address.`, }, "region": { @@ -348,7 +348,6 @@ func resourceComputeAddressCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -357,7 +356,6 @@ func resourceComputeAddressCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Address: %s", err) @@ -470,14 +468,12 @@ func resourceComputeAddressRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeAddress %q", d.Id())) @@ -586,8 +582,6 @@ func resourceComputeAddressUpdate(d *schema.ResourceData, meta interface{}) erro return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -601,7 +595,6 @@ func resourceComputeAddressUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Address %q: %s", d.Id(), err) @@ -649,8 +642,6 @@ func resourceComputeAddressDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Address %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -660,7 +651,6 @@ func resourceComputeAddressDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Address") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_autoscaler.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_autoscaler.go index a882a0e7bde..2fc36712896 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_autoscaler.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_autoscaler.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -397,7 +396,6 @@ func resourceComputeAutoscalerCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -406,7 +404,6 @@ func resourceComputeAutoscalerCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Autoscaler: %s", err) @@ -459,14 +456,12 @@ func resourceComputeAutoscalerRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeAutoscaler %q", d.Id())) @@ -559,7 +554,6 @@ func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Autoscaler %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -574,7 +568,6 @@ func resourceComputeAutoscalerUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -621,8 +614,6 @@ func resourceComputeAutoscalerDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Autoscaler %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -632,7 +623,6 @@ func resourceComputeAutoscalerDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Autoscaler") @@ -1028,7 +1018,7 @@ func expandComputeAutoscalerAutoscalingPolicy(v interface{}, d tpgresource.Terra transformedMaxReplicas, err := expandComputeAutoscalerAutoscalingPolicyMaxReplicas(original["max_replicas"], d, config) if err != nil { return nil, err - } else { + } else if val := reflect.ValueOf(transformedMaxReplicas); val.IsValid() && !tpgresource.IsEmptyValue(val) { transformed["maxNumReplicas"] = transformedMaxReplicas } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket.go index 30efd7fca9f..f2617844f0f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -340,7 +339,6 @@ func resourceComputeBackendBucketCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -349,7 +347,6 @@ func resourceComputeBackendBucketCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BackendBucket: %s", err) @@ -422,14 +419,12 @@ func resourceComputeBackendBucketRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeBackendBucket %q", d.Id())) @@ -549,7 +544,6 @@ func resourceComputeBackendBucketUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating BackendBucket %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -564,7 +558,6 @@ func resourceComputeBackendBucketUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -630,8 +623,6 @@ func resourceComputeBackendBucketDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BackendBucket %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -641,7 +632,6 @@ func resourceComputeBackendBucketDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BackendBucket") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket_signed_url_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket_signed_url_key.go index 6c011b684a9..383ee4f318e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket_signed_url_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_bucket_signed_url_key.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -134,7 +133,6 @@ func resourceComputeBackendBucketSignedUrlKeyCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -143,7 +141,6 @@ func resourceComputeBackendBucketSignedUrlKeyCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BackendBucketSignedUrlKey: %s", err) @@ -196,14 +193,12 @@ func resourceComputeBackendBucketSignedUrlKeyRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeBackendBucketSignedUrlKey %q", d.Id())) @@ -266,8 +261,6 @@ func resourceComputeBackendBucketSignedUrlKeyDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BackendBucketSignedUrlKey %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -277,7 +270,6 @@ func resourceComputeBackendBucketSignedUrlKeyDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BackendBucketSignedUrlKey") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service.go index b0de8c749c8..8b3c7d293b5 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -809,6 +808,7 @@ The possible values are: UNAVAILABLE_WEIGHT. Otherwise, Load Balancing remains equal-weight. + This field is applicable to either: * A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, @@ -818,6 +818,7 @@ This field is applicable to either: Load Balancing). Only MAGLEV and WEIGHTED_MAGLEV values are possible for External Network Load Balancing. The default is MAGLEV. + If session_affinity is not NONE, and this field is not set to MAGLEV, WEIGHTED_MAGLEV, or RING_HASH, session affinity settings will not take effect. @@ -859,10 +860,7 @@ The default value is 1.0.`, Optional: true, Description: `Settings controlling eviction of unhealthy hosts from the load balancing pool. Applicable backend service types can be a global backend service with the -loadBalancingScheme set to INTERNAL_SELF_MANAGED or EXTERNAL_MANAGED. - -From version 6.0.0 outlierDetection default terraform values will be removed to match default GCP value. -Default values are enforce by GCP without providing them.`, +loadBalancingScheme set to INTERNAL_SELF_MANAGED or EXTERNAL_MANAGED.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -1062,12 +1060,6 @@ alt name matches one of the specified values.`, }, }, }, - "service_lb_policy": { - Type: schema.TypeString, - Optional: true, - Description: `URL to networkservices.ServiceLbPolicy resource. -Can only be set if load balancing scheme is EXTERNAL, EXTERNAL_MANAGED, INTERNAL_MANAGED or INTERNAL_SELF_MANAGED and the scope is global.`, - }, "session_affinity": { Type: schema.TypeString, Computed: true, @@ -1080,10 +1072,8 @@ not applicable if the protocol is UDP. Possible values: ["NONE", "CLIENT_IP", "C Type: schema.TypeInt, Computed: true, Optional: true, - Description: `The backend service timeout has a different meaning depending on the type of load balancer. -For more information see, [Backend service settings](https://cloud.google.com/compute/docs/reference/rest/v1/backendServices). -The default is 30 seconds. -The full range of timeout values allowed goes from 1 through 2,147,483,647 seconds.`, + Description: `How many seconds to wait for the backend before considering it a +failed request. Default is 30 seconds. Valid range is [1, 86400].`, }, "creation_timestamp": { Type: schema.TypeString, @@ -1152,9 +1142,7 @@ UTILIZATION. Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL). See the [Backend Services Overview](https://cloud.google.com/load-balancing/docs/backend-service#balancing-mode) -for an explanation of load balancing modes. - -From version 6.0.0 default value will be UTILIZATION to match default GCP value. Default value: "UTILIZATION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, +for an explanation of load balancing modes. Default value: "UTILIZATION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, Default: "UTILIZATION", }, "capacity_scaler": { @@ -1420,12 +1408,6 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{ } else if v, ok := d.GetOkExists("log_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(logConfigProp)) && (ok || !reflect.DeepEqual(v, logConfigProp)) { obj["logConfig"] = logConfigProp } - serviceLbPolicyProp, err := expandComputeBackendServiceServiceLbPolicy(d.Get("service_lb_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("service_lb_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceLbPolicyProp)) && (ok || !reflect.DeepEqual(v, serviceLbPolicyProp)) { - obj["serviceLbPolicy"] = serviceLbPolicyProp - } obj, err = resourceComputeBackendServiceEncoder(d, meta, obj) if err != nil { @@ -1451,7 +1433,6 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1460,7 +1441,6 @@ func resourceComputeBackendServiceCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BackendService: %s", err) @@ -1552,14 +1532,12 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeBackendService %q", d.Id())) @@ -1680,9 +1658,6 @@ func resourceComputeBackendServiceRead(d *schema.ResourceData, meta interface{}) if err := d.Set("log_config", flattenComputeBackendServiceLogConfig(res["logConfig"], d, config)); err != nil { return fmt.Errorf("Error reading BackendService: %s", err) } - if err := d.Set("service_lb_policy", flattenComputeBackendServiceServiceLbPolicy(res["serviceLbPolicy"], d, config)); err != nil { - return fmt.Errorf("Error reading BackendService: %s", err) - } if err := d.Set("self_link", tpgresource.ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil { return fmt.Errorf("Error reading BackendService: %s", err) } @@ -1868,12 +1843,6 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ } else if v, ok := d.GetOkExists("log_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, logConfigProp)) { obj["logConfig"] = logConfigProp } - serviceLbPolicyProp, err := expandComputeBackendServiceServiceLbPolicy(d.Get("service_lb_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("service_lb_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, serviceLbPolicyProp)) { - obj["serviceLbPolicy"] = serviceLbPolicyProp - } obj, err = resourceComputeBackendServiceEncoder(d, meta, obj) if err != nil { @@ -1886,7 +1855,6 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating BackendService %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1901,7 +1869,6 @@ func resourceComputeBackendServiceUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1986,8 +1953,6 @@ func resourceComputeBackendServiceDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BackendService %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1997,7 +1962,6 @@ func resourceComputeBackendServiceDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BackendService") @@ -3213,10 +3177,6 @@ func flattenComputeBackendServiceLogConfigSampleRate(v interface{}, d *schema.Re return v } -func flattenComputeBackendServiceServiceLbPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandComputeBackendServiceAffinityCookieTtlSec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -4284,10 +4244,6 @@ func expandComputeBackendServiceLogConfigSampleRate(v interface{}, d tpgresource return v, nil } -func expandComputeBackendServiceServiceLbPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func resourceComputeBackendServiceEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { // The BackendService API's Update / PUT API is badly formed and behaves like // a PATCH field for at least IAP. When sent a `null` `iap` field, the API diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service_signed_url_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service_signed_url_key.go index 276a5fafc6d..33389c45538 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service_signed_url_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_backend_service_signed_url_key.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -134,7 +133,6 @@ func resourceComputeBackendServiceSignedUrlKeyCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -143,7 +141,6 @@ func resourceComputeBackendServiceSignedUrlKeyCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BackendServiceSignedUrlKey: %s", err) @@ -196,14 +193,12 @@ func resourceComputeBackendServiceSignedUrlKeyRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeBackendServiceSignedUrlKey %q", d.Id())) @@ -266,8 +261,6 @@ func resourceComputeBackendServiceSignedUrlKeyDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BackendServiceSignedUrlKey %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -277,7 +270,6 @@ func resourceComputeBackendServiceSignedUrlKeyDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BackendServiceSignedUrlKey") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk.go index a67cac2a160..ebee59abd95 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk.go @@ -22,7 +22,6 @@ import ( "errors" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -33,6 +32,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "github.com/hashicorp/terraform-provider-google/google/verify" ) // diffsupress for hyperdisk provisioned_iops @@ -634,21 +634,11 @@ encryption key that protects this resource.`, }, }, }, - "storage_pool": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareResourceNames, - Description: `The URL of the storage pool in which the new disk is created. -For example: -* https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/storagePools/{storagePool} -* /projects/{project}/zones/{zone}/storagePools/{storagePool}`, - }, "type": { Type: schema.TypeString, Optional: true, ForceNew: true, - DiffSuppressFunc: tpgresource.CompareResourceNames, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `URL of the disk type resource describing which disk type to use to create the disk. Provide this when creating the disk.`, Default: "pd-standard", @@ -732,7 +722,8 @@ used.`, Description: `Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance`, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, }, }, "project": { @@ -754,10 +745,11 @@ func computeDiskGuestOsFeaturesSchema() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The type of supported feature. Read [Enabling guest operating system features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) to see a list of available options.`, + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: verify.ValidateEnum([]string{"MULTI_IP_SUBNET", "SECURE_BOOT", "SEV_CAPABLE", "UEFI_COMPATIBLE", "VIRTIO_SCSI_MULTIQUEUE", "WINDOWS", "GVNIC", "SEV_LIVE_MIGRATABLE", "SEV_SNP_CAPABLE", "SUSPEND_RESUME_COMPATIBLE", "TDX_CAPABLE"}), + Description: `The type of supported feature. Read [Enabling guest operating system features](https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images#guest-os-features) to see a list of available options. Possible values: ["MULTI_IP_SUBNET", "SECURE_BOOT", "SEV_CAPABLE", "UEFI_COMPATIBLE", "VIRTIO_SCSI_MULTIQUEUE", "WINDOWS", "GVNIC", "SEV_LIVE_MIGRATABLE", "SEV_SNP_CAPABLE", "SUSPEND_RESUME_COMPATIBLE", "TDX_CAPABLE"]`, }, }, } @@ -855,12 +847,6 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { } else if v, ok := d.GetOkExists("licenses"); !tpgresource.IsEmptyValue(reflect.ValueOf(licensesProp)) && (ok || !reflect.DeepEqual(v, licensesProp)) { obj["licenses"] = licensesProp } - storagePoolProp, err := expandComputeDiskStoragePool(d.Get("storage_pool"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("storage_pool"); !tpgresource.IsEmptyValue(reflect.ValueOf(storagePoolProp)) && (ok || !reflect.DeepEqual(v, storagePoolProp)) { - obj["storagePool"] = storagePoolProp - } labelsProp, err := expandComputeDiskEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -922,7 +908,6 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -931,7 +916,6 @@ func resourceComputeDiskCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Disk: %s", err) @@ -984,14 +968,12 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeDisk %q", d.Id())) @@ -1076,9 +1058,6 @@ func resourceComputeDiskRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("licenses", flattenComputeDiskLicenses(res["licenses"], d, config)); err != nil { return fmt.Errorf("Error reading Disk: %s", err) } - if err := d.Set("storage_pool", flattenComputeDiskStoragePool(res["storagePool"], d, config)); err != nil { - return fmt.Errorf("Error reading Disk: %s", err) - } if err := d.Set("terraform_labels", flattenComputeDiskTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading Disk: %s", err) } @@ -1156,8 +1135,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1171,7 +1148,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Disk %q: %s", d.Id(), err) @@ -1206,8 +1182,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1221,7 +1195,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Disk %q: %s", d.Id(), err) @@ -1256,8 +1229,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1271,7 +1242,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Disk %q: %s", d.Id(), err) @@ -1306,8 +1276,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1321,7 +1289,6 @@ func resourceComputeDiskUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Disk %q: %s", d.Id(), err) @@ -1369,7 +1336,6 @@ func resourceComputeDiskDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) readRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", @@ -1441,7 +1407,6 @@ func resourceComputeDiskDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Disk") @@ -1667,13 +1632,6 @@ func flattenComputeDiskLicenses(v interface{}, d *schema.ResourceData, config *t return tpgresource.ConvertAndMapStringArr(v.([]interface{}), tpgresource.ConvertSelfLinkToV1) } -func flattenComputeDiskStoragePool(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - func flattenComputeDiskTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -1940,10 +1898,6 @@ func expandComputeDiskLicenses(v interface{}, d tpgresource.TerraformResourceDat return req, nil } -func expandComputeDiskStoragePool(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeDiskEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_async_replication.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_async_replication.go index 9a8f24b14b5..ea81d823e6c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_async_replication.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_async_replication.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "google.golang.org/api/compute/v1" ) @@ -147,23 +147,23 @@ func resourceDiskAsyncReplicationCreate(d *schema.ResourceData, meta interface{} return err } } - err = retry.Retry(time.Minute*time.Duration(5), func() *retry.RetryError { + err = resource.Retry(time.Minute*time.Duration(5), func() *resource.RetryError { diskStatus, err := asyncReplicationGetDiskStatus(clientCompute, zv, rv) if err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } if diskStatus.ResourceStatus == nil { - return retry.NonRetryableError(fmt.Errorf("no resource status for disk: %s", resourceId)) + return resource.NonRetryableError(fmt.Errorf("no resource status for disk: %s", resourceId)) } if secondaryState, ok := diskStatus.ResourceStatus.AsyncSecondaryDisks[secondaryDisk]; ok { if secondaryState.State != "ACTIVE" { time.Sleep(5 * time.Second) - return retry.RetryableError(fmt.Errorf("secondary disk %s state (%s) is not: ACTIVE", secondaryDisk, secondaryState)) + return resource.RetryableError(fmt.Errorf("secondary disk %s state (%s) is not: ACTIVE", secondaryDisk, secondaryState)) } return nil } time.Sleep(5 * time.Second) - return retry.RetryableError(fmt.Errorf("secondary disk %s state not available", secondaryDisk)) + return resource.RetryableError(fmt.Errorf("secondary disk %s state not available", secondaryDisk)) }) if err != nil { return err @@ -271,19 +271,19 @@ func resourceDiskAsyncReplicationDelete(d *schema.ResourceData, meta interface{} return err } } - err = retry.Retry(time.Minute*time.Duration(5), func() *retry.RetryError { + err = resource.Retry(time.Minute*time.Duration(5), func() *resource.RetryError { diskStatus, err := asyncReplicationGetDiskStatus(clientCompute, zv, rv) if err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } if secondaryState, ok := diskStatus.ResourceStatus.AsyncSecondaryDisks[resourceName]; ok { if secondaryState.State != "STOPPED" { time.Sleep(5 * time.Second) - return retry.RetryableError(fmt.Errorf("secondary disk %s state (%s) is not STOPPED", secondaryDisk, secondaryState)) + return resource.RetryableError(fmt.Errorf("secondary disk %s state (%s) is not STOPPED", secondaryDisk, secondaryState)) } return nil } - return retry.NonRetryableError(fmt.Errorf("secondary disk %s state not available", secondaryDisk)) + return resource.NonRetryableError(fmt.Errorf("secondary disk %s state not available", secondaryDisk)) }) if err != nil { return err diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_resource_policy_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_resource_policy_attachment.go index cccfdd3acb6..e0767cb5fc1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_resource_policy_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_disk_resource_policy_attachment.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -124,7 +123,6 @@ func resourceComputeDiskResourcePolicyAttachmentCreate(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -133,7 +131,6 @@ func resourceComputeDiskResourcePolicyAttachmentCreate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DiskResourcePolicyAttachment: %s", err) @@ -186,14 +183,12 @@ func resourceComputeDiskResourcePolicyAttachmentRead(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeDiskResourcePolicyAttachment %q", d.Id())) @@ -269,7 +264,6 @@ func resourceComputeDiskResourcePolicyAttachmentDelete(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) obj = make(map[string]interface{}) zone, err := tpgresource.GetZone(d, config) @@ -305,7 +299,6 @@ func resourceComputeDiskResourcePolicyAttachmentDelete(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DiskResourcePolicyAttachment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_external_vpn_gateway.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_external_vpn_gateway.go index 7e1f8492669..3637c11f4d3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_external_vpn_gateway.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_external_vpn_gateway.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -216,7 +215,6 @@ func resourceComputeExternalVpnGatewayCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -225,7 +223,6 @@ func resourceComputeExternalVpnGatewayCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ExternalVpnGateway: %s", err) @@ -278,14 +275,12 @@ func resourceComputeExternalVpnGatewayRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeExternalVpnGateway %q", d.Id())) @@ -364,8 +359,6 @@ func resourceComputeExternalVpnGatewayUpdate(d *schema.ResourceData, meta interf return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -379,7 +372,6 @@ func resourceComputeExternalVpnGatewayUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating ExternalVpnGateway %q: %s", d.Id(), err) @@ -427,8 +419,6 @@ func resourceComputeExternalVpnGatewayDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ExternalVpnGateway %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -438,7 +428,6 @@ func resourceComputeExternalVpnGatewayDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ExternalVpnGateway") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall.go index e7c01d96e2b..277afee1da5 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall.go @@ -22,7 +22,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "sort" "strings" @@ -466,7 +465,7 @@ func resourceComputeFirewallCreate(d *schema.ResourceData, meta interface{}) err descriptionProp, err := expandComputeFirewallDescription(d.Get("description"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("description"); ok || !reflect.DeepEqual(v, descriptionProp) { + } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } destinationRangesProp, err := expandComputeFirewallDestinationRanges(d.Get("destination_ranges"), d, config) @@ -561,7 +560,6 @@ func resourceComputeFirewallCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -570,7 +568,6 @@ func resourceComputeFirewallCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Firewall: %s", err) @@ -623,14 +620,12 @@ func resourceComputeFirewallRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeFirewall %q", d.Id())) @@ -726,7 +721,7 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err descriptionProp, err := expandComputeFirewallDescription(d.Get("description"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("description"); ok || !reflect.DeepEqual(v, descriptionProp) { + } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } destinationRangesProp, err := expandComputeFirewallDestinationRanges(d.Get("destination_ranges"), d, config) @@ -796,7 +791,6 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Firewall %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -811,7 +805,6 @@ func resourceComputeFirewallUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -858,8 +851,6 @@ func resourceComputeFirewallDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Firewall %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -869,7 +860,6 @@ func resourceComputeFirewallDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Firewall") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall_policy_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall_policy_rule.go index b75d24c5ed9..93ff6e04be6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall_policy_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_firewall_policy_rule.go @@ -59,7 +59,7 @@ func ResourceComputeFirewallPolicyRule() *schema.Resource { "action": { Type: schema.TypeString, Required: true, - Description: "The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\", \"goto_next\" and \"apply_security_profile_group\".", + Description: "The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\" and \"goto_next\".", }, "direction": { @@ -109,12 +109,6 @@ func ResourceComputeFirewallPolicyRule() *schema.Resource { Description: "Denotes whether to enable logging for a particular rule. If logging is enabled, logs will be exported to the configured export destination in Stackdriver. Logs may be exported to BigQuery or Pub/Sub. Note: you cannot enable logging on \"goto_next\" rules.", }, - "security_profile_group": { - Type: schema.TypeString, - Optional: true, - Description: "A fully-qualified URL of a SecurityProfileGroup resource. Example: https://networksecurity.googleapis.com/v1/organizations/{organizationId}/locations/global/securityProfileGroups/my-security-profile-group. It must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.", - }, - "target_resources": { Type: schema.TypeList, Optional: true, @@ -130,12 +124,6 @@ func ResourceComputeFirewallPolicyRule() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "tls_inspect": { - Type: schema.TypeBool, - Optional: true, - Description: "Boolean flag indicating if the traffic should be TLS decrypted. It can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.", - }, - "kind": { Type: schema.TypeString, Computed: true, @@ -265,10 +253,8 @@ func resourceComputeFirewallPolicyRuleCreate(d *schema.ResourceData, meta interf Description: dcl.String(d.Get("description").(string)), Disabled: dcl.Bool(d.Get("disabled").(bool)), EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetResources: tpgdclresource.ExpandStringArray(d.Get("target_resources")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } id, err := obj.ID() @@ -320,10 +306,8 @@ func resourceComputeFirewallPolicyRuleRead(d *schema.ResourceData, meta interfac Description: dcl.String(d.Get("description").(string)), Disabled: dcl.Bool(d.Get("disabled").(bool)), EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetResources: tpgdclresource.ExpandStringArray(d.Get("target_resources")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -372,18 +356,12 @@ func resourceComputeFirewallPolicyRuleRead(d *schema.ResourceData, meta interfac if err = d.Set("enable_logging", res.EnableLogging); err != nil { return fmt.Errorf("error setting enable_logging in state: %s", err) } - if err = d.Set("security_profile_group", res.SecurityProfileGroup); err != nil { - return fmt.Errorf("error setting security_profile_group in state: %s", err) - } if err = d.Set("target_resources", res.TargetResources); err != nil { return fmt.Errorf("error setting target_resources in state: %s", err) } if err = d.Set("target_service_accounts", res.TargetServiceAccounts); err != nil { return fmt.Errorf("error setting target_service_accounts in state: %s", err) } - if err = d.Set("tls_inspect", res.TlsInspect); err != nil { - return fmt.Errorf("error setting tls_inspect in state: %s", err) - } if err = d.Set("kind", res.Kind); err != nil { return fmt.Errorf("error setting kind in state: %s", err) } @@ -405,10 +383,8 @@ func resourceComputeFirewallPolicyRuleUpdate(d *schema.ResourceData, meta interf Description: dcl.String(d.Get("description").(string)), Disabled: dcl.Bool(d.Get("disabled").(bool)), EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetResources: tpgdclresource.ExpandStringArray(d.Get("target_resources")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } directive := tpgdclresource.UpdateDirective userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -455,10 +431,8 @@ func resourceComputeFirewallPolicyRuleDelete(d *schema.ResourceData, meta interf Description: dcl.String(d.Get("description").(string)), Disabled: dcl.Bool(d.Get("disabled").(bool)), EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetResources: tpgdclresource.ExpandStringArray(d.Get("target_resources")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } log.Printf("[DEBUG] Deleting FirewallPolicyRule %q", d.Id()) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_forwarding_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_forwarding_rule.go index 5d83e665fb6..7ad83dfb957 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_forwarding_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_forwarding_rule.go @@ -18,12 +18,9 @@ package compute import ( - "bytes" "context" "fmt" "log" - "net" - "net/http" "reflect" "strings" "time" @@ -53,57 +50,6 @@ func forwardingRuleCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, v return nil } -// Port range '80' and '80-80' is equivalent. -// `old` is read from the server and always has the full range format (e.g. '80-80', '1024-2048'). -// `new` can be either a single port or a port range. -func PortRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - return old == new+"-"+new -} - -// Suppresses diff for IPv4 and IPv6 different formats. -// It also suppresses diffs if an IP is changing to a reference. -func InternalIpDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { - addr_equality := false - netmask_equality := false - - addr_netmask_old := strings.Split(old, "/") - addr_netmask_new := strings.Split(new, "/") - - // Check if old or new are IPs (with or without netmask) - var addr_old net.IP - if net.ParseIP(addr_netmask_old[0]) == nil { - addr_old = net.ParseIP(old) - } else { - addr_old = net.ParseIP(addr_netmask_old[0]) - } - var addr_new net.IP - if net.ParseIP(addr_netmask_new[0]) == nil { - addr_new = net.ParseIP(new) - } else { - addr_new = net.ParseIP(addr_netmask_new[0]) - } - - if addr_old != nil { - if addr_new == nil { - // old is an IP and new is a reference - addr_equality = true - } else { - // old and new are IP addresses - addr_equality = bytes.Equal(addr_old, addr_new) - } - } - - // If old and new both have a netmask compare them, otherwise suppress - // This is not technically correct but prevents the permadiff described in https://github.com/hashicorp/terraform-provider-google/issues/16400 - if (len(addr_netmask_old)) == 2 && (len(addr_netmask_new) == 2) { - netmask_equality = addr_netmask_old[1] == addr_netmask_new[1] - } else { - netmask_equality = true - } - - return addr_equality && netmask_equality -} - func ResourceComputeForwardingRule() *schema.Resource { return &schema.Resource{ Create: resourceComputeForwardingRuleCreate, @@ -151,7 +97,7 @@ lowercase letters and numbers and must start with a letter.`, Computed: true, Optional: true, ForceNew: true, - DiffSuppressFunc: InternalIpDiffSuppress, + DiffSuppressFunc: tpgresource.InternalIpDiffSuppress, Description: `IP address for which this forwarding rule accepts traffic. When a client sends traffic to this IP address, the forwarding rule directs the traffic to the referenced 'target' or 'backendService'. @@ -165,6 +111,7 @@ required under the following circumstances: * When the 'target' is a Private Service Connect Google APIs bundle, you must specify an 'IPAddress'. + Otherwise, you can optionally specify an IP address that references an existing static (reserved) IP address resource. When omitted, Google Cloud assigns an ephemeral IP address. @@ -182,6 +129,7 @@ forwarding rule: * 'global/addresses/address-name' * 'address-name' + The forwarding rule's 'target' or 'backendService', and in most cases, also the 'loadBalancingScheme', determine the type of IP address that you can use. For detailed information, see @@ -358,7 +306,7 @@ networkTier of the Address. Possible values: ["PREMIUM", "STANDARD"]`, Computed: true, Optional: true, ForceNew: true, - DiffSuppressFunc: PortRangeDiffSuppress, + DiffSuppressFunc: tpgresource.PortRangeDiffSuppress, Description: `The 'ports', 'portRange', and 'allPorts' fields are mutually exclusive. Only packets addressed to ports in the specified range will be forwarded to the backends configured with this forwarding rule. @@ -510,6 +458,7 @@ The forwarded traffic must be of a type appropriate to the target object. * 'vpc-sc' - [ APIs that support VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/supported-products). * 'all-apis' - [All supported Google APIs](https://cloud.google.com/vpc/docs/private-service-connect#supported-apis). + For Private Service Connect forwarding rules that forward traffic to managed services, the target must be a service attachment.`, }, "base_forwarding_rule": { @@ -659,18 +608,18 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ } else if v, ok := d.GetOkExists("target"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetProp)) && (ok || !reflect.DeepEqual(v, targetProp)) { obj["target"] = targetProp } - labelFingerprintProp, err := expandComputeForwardingRuleLabelFingerprint(d.Get("label_fingerprint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("label_fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelFingerprintProp)) && (ok || !reflect.DeepEqual(v, labelFingerprintProp)) { - obj["labelFingerprint"] = labelFingerprintProp - } allowGlobalAccessProp, err := expandComputeForwardingRuleAllowGlobalAccess(d.Get("allow_global_access"), d, config) if err != nil { return err } else if v, ok := d.GetOkExists("allow_global_access"); ok || !reflect.DeepEqual(v, allowGlobalAccessProp) { obj["allowGlobalAccess"] = allowGlobalAccessProp } + labelFingerprintProp, err := expandComputeForwardingRuleLabelFingerprint(d.Get("label_fingerprint"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("label_fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelFingerprintProp)) && (ok || !reflect.DeepEqual(v, labelFingerprintProp)) { + obj["labelFingerprint"] = labelFingerprintProp + } allPortsProp, err := expandComputeForwardingRuleAllPorts(d.Get("all_ports"), d, config) if err != nil { return err @@ -751,7 +700,6 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -760,7 +708,6 @@ func resourceComputeForwardingRuleCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ForwardingRule: %s", err) @@ -873,14 +820,12 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeForwardingRule %q", d.Id())) @@ -941,15 +886,15 @@ func resourceComputeForwardingRuleRead(d *schema.ResourceData, meta interface{}) if err := d.Set("target", flattenComputeForwardingRuleTarget(res["target"], d, config)); err != nil { return fmt.Errorf("Error reading ForwardingRule: %s", err) } - if err := d.Set("label_fingerprint", flattenComputeForwardingRuleLabelFingerprint(res["labelFingerprint"], d, config)); err != nil { - return fmt.Errorf("Error reading ForwardingRule: %s", err) - } if err := d.Set("allow_global_access", flattenComputeForwardingRuleAllowGlobalAccess(res["allowGlobalAccess"], d, config)); err != nil { return fmt.Errorf("Error reading ForwardingRule: %s", err) } if err := d.Set("labels", flattenComputeForwardingRuleLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading ForwardingRule: %s", err) } + if err := d.Set("label_fingerprint", flattenComputeForwardingRuleLabelFingerprint(res["labelFingerprint"], d, config)); err != nil { + return fmt.Errorf("Error reading ForwardingRule: %s", err) + } if err := d.Set("all_ports", flattenComputeForwardingRuleAllPorts(res["allPorts"], d, config)); err != nil { return fmt.Errorf("Error reading ForwardingRule: %s", err) } @@ -1025,8 +970,6 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1040,7 +983,6 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) @@ -1055,29 +997,21 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ return err } } - if d.HasChange("label_fingerprint") || d.HasChange("effective_labels") { + if d.HasChange("allow_global_access") { obj := make(map[string]interface{}) - labelFingerprintProp, err := expandComputeForwardingRuleLabelFingerprint(d.Get("label_fingerprint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("label_fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelFingerprintProp)) { - obj["labelFingerprint"] = labelFingerprintProp - } - labelsProp, err := expandComputeForwardingRuleEffectiveLabels(d.Get("effective_labels"), d, config) + allowGlobalAccessProp, err := expandComputeForwardingRuleAllowGlobalAccess(d.Get("allow_global_access"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp + } else if v, ok := d.GetOkExists("allow_global_access"); ok || !reflect.DeepEqual(v, allowGlobalAccessProp) { + obj["allowGlobalAccess"] = allowGlobalAccessProp } - url, err := tpgresource.ReplaceVarsForId(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/forwardingRules/{{name}}/setLabels") + url, err := tpgresource.ReplaceVarsForId(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/forwardingRules/{{name}}") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1085,13 +1019,12 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, - Method: "POST", + Method: "PATCH", Project: billingProject, RawURL: url, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) @@ -1106,22 +1039,26 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ return err } } - if d.HasChange("allow_global_access") { + if d.HasChange("label_fingerprint") || d.HasChange("effective_labels") { obj := make(map[string]interface{}) - allowGlobalAccessProp, err := expandComputeForwardingRuleAllowGlobalAccess(d.Get("allow_global_access"), d, config) + labelFingerprintProp, err := expandComputeForwardingRuleLabelFingerprint(d.Get("label_fingerprint"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("allow_global_access"); ok || !reflect.DeepEqual(v, allowGlobalAccessProp) { - obj["allowGlobalAccess"] = allowGlobalAccessProp + } else if v, ok := d.GetOkExists("label_fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelFingerprintProp)) { + obj["labelFingerprint"] = labelFingerprintProp } - - url, err := tpgresource.ReplaceVarsForId(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/forwardingRules/{{name}}") + labelsProp, err := expandComputeForwardingRuleEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err + } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { + obj["labels"] = labelsProp } - headers := make(http.Header) + url, err := tpgresource.ReplaceVarsForId(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/forwardingRules/{{name}}/setLabels") + if err != nil { + return err + } // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1130,13 +1067,12 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, - Method: "PATCH", + Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) @@ -1189,8 +1125,6 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1204,7 +1138,6 @@ func resourceComputeForwardingRuleUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating ForwardingRule %q: %s", d.Id(), err) @@ -1252,8 +1185,6 @@ func resourceComputeForwardingRuleDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ForwardingRule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1263,7 +1194,6 @@ func resourceComputeForwardingRuleDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ForwardingRule") @@ -1379,10 +1309,6 @@ func flattenComputeForwardingRuleTarget(v interface{}, d *schema.ResourceData, c return v } -func flattenComputeForwardingRuleLabelFingerprint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenComputeForwardingRuleAllowGlobalAccess(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1402,6 +1328,10 @@ func flattenComputeForwardingRuleLabels(v interface{}, d *schema.ResourceData, c return transformed } +func flattenComputeForwardingRuleLabelFingerprint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenComputeForwardingRuleAllPorts(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1601,11 +1531,11 @@ func expandComputeForwardingRuleTarget(v interface{}, d tpgresource.TerraformRes return url + v.(string), nil } -func expandComputeForwardingRuleLabelFingerprint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { +func expandComputeForwardingRuleAllowGlobalAccess(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } -func expandComputeForwardingRuleAllowGlobalAccess(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { +func expandComputeForwardingRuleLabelFingerprint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_address.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_address.go index ceaf1d19e93..30cc8c8672e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_address.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_address.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -228,7 +227,6 @@ func resourceComputeGlobalAddressCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) // Note: Global external IP addresses and internal IP addresses are always Premium Tier. // An address with type INTERNAL cannot have a network tier if addressTypeProp != "INTERNAL" { @@ -242,7 +240,6 @@ func resourceComputeGlobalAddressCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GlobalAddress: %s", err) @@ -295,14 +292,12 @@ func resourceComputeGlobalAddressRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeGlobalAddress %q", d.Id())) @@ -373,8 +368,6 @@ func resourceComputeGlobalAddressDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GlobalAddress %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -384,7 +377,6 @@ func resourceComputeGlobalAddressDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GlobalAddress") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_forwarding_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_forwarding_rule.go index dd5213e5a47..75c75f87e2a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_forwarding_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_forwarding_rule.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -89,6 +88,7 @@ The forwarded traffic must be of a type appropriate to the target object. * 'vpc-sc' - [ APIs that support VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/supported-products). * 'all-apis' - [All supported Google APIs](https://cloud.google.com/vpc/docs/private-service-connect#supported-apis). + For Private Service Connect forwarding rules that forward traffic to managed services, the target must be a service attachment.`, }, "ip_address": { @@ -96,7 +96,7 @@ For Private Service Connect forwarding rules that forward traffic to managed ser Computed: true, Optional: true, ForceNew: true, - DiffSuppressFunc: InternalIpDiffSuppress, + DiffSuppressFunc: tpgresource.InternalIpDiffSuppress, Description: `IP address for which this forwarding rule accepts traffic. When a client sends traffic to this IP address, the forwarding rule directs the traffic to the referenced 'target'. @@ -110,6 +110,7 @@ required under the following circumstances: * When the 'target' is a Private Service Connect Google APIs bundle, you must specify an 'IPAddress'. + Otherwise, you can optionally specify an IP address that references an existing static (reserved) IP address resource. When omitted, Google Cloud assigns an ephemeral IP address. @@ -127,6 +128,7 @@ forwarding rule: * 'global/addresses/address-name' * 'address-name' + The forwarding rule's 'target', and in most cases, also the 'loadBalancingScheme', determine the type of IP address that you can use. For detailed information, see @@ -284,7 +286,7 @@ APIs, a network must be provided.`, Type: schema.TypeString, Optional: true, ForceNew: true, - DiffSuppressFunc: PortRangeDiffSuppress, + DiffSuppressFunc: tpgresource.PortRangeDiffSuppress, Description: `The 'portRange' field has the following limitations: * It requires that the forwarding rule 'IPProtocol' be TCP, UDP, or SCTP, and @@ -533,7 +535,6 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -542,7 +543,6 @@ func resourceComputeGlobalForwardingRuleCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GlobalForwardingRule: %s", err) @@ -655,14 +655,12 @@ func resourceComputeGlobalForwardingRuleRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeGlobalForwardingRule %q", d.Id())) @@ -777,8 +775,6 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -792,7 +788,6 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating GlobalForwardingRule %q: %s", d.Id(), err) @@ -822,8 +817,6 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -837,7 +830,6 @@ func resourceComputeGlobalForwardingRuleUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating GlobalForwardingRule %q: %s", d.Id(), err) @@ -885,8 +877,6 @@ func resourceComputeGlobalForwardingRuleDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GlobalForwardingRule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -896,7 +886,6 @@ func resourceComputeGlobalForwardingRuleDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GlobalForwardingRule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint.go index f6b9c2f1795..3acaf203b10 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -149,7 +148,6 @@ func resourceComputeGlobalNetworkEndpointCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -158,7 +156,6 @@ func resourceComputeGlobalNetworkEndpointCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GlobalNetworkEndpoint: %s", err) @@ -211,14 +208,12 @@ func resourceComputeGlobalNetworkEndpointRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeGlobalNetworkEndpoint %q", d.Id())) @@ -299,7 +294,6 @@ func resourceComputeGlobalNetworkEndpointDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) toDelete := make(map[string]interface{}) portProp, err := expandNestedComputeGlobalNetworkEndpointPort(d.Get("port"), d, config) if err != nil { @@ -338,7 +332,6 @@ func resourceComputeGlobalNetworkEndpointDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GlobalNetworkEndpoint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint_group.go index a26f8f81c6b..e7549440cb8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_global_network_endpoint_group.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -153,7 +152,6 @@ func resourceComputeGlobalNetworkEndpointGroupCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -162,7 +160,6 @@ func resourceComputeGlobalNetworkEndpointGroupCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GlobalNetworkEndpointGroup: %s", err) @@ -215,14 +212,12 @@ func resourceComputeGlobalNetworkEndpointGroupRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeGlobalNetworkEndpointGroup %q", d.Id())) @@ -278,8 +273,6 @@ func resourceComputeGlobalNetworkEndpointGroupDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GlobalNetworkEndpointGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -289,7 +282,6 @@ func resourceComputeGlobalNetworkEndpointGroupDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GlobalNetworkEndpointGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ha_vpn_gateway.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ha_vpn_gateway.go index c6bc4c880bb..f44085bb56c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ha_vpn_gateway.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ha_vpn_gateway.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -209,7 +208,6 @@ func resourceComputeHaVpnGatewayCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -218,7 +216,6 @@ func resourceComputeHaVpnGatewayCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating HaVpnGateway: %s", err) @@ -271,14 +268,12 @@ func resourceComputeHaVpnGatewayRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeHaVpnGateway %q", d.Id())) @@ -340,8 +335,6 @@ func resourceComputeHaVpnGatewayDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting HaVpnGateway %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -351,7 +344,6 @@ func resourceComputeHaVpnGatewayDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "HaVpnGateway") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_health_check.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_health_check.go index 81476fd7d0e..32a421d8c8b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_health_check.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_health_check.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strconv" "strings" @@ -780,7 +779,6 @@ func resourceComputeHealthCheckCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -789,7 +787,6 @@ func resourceComputeHealthCheckCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating HealthCheck: %s", err) @@ -842,14 +839,12 @@ func resourceComputeHealthCheckRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeHealthCheck %q", d.Id())) @@ -1017,7 +1012,6 @@ func resourceComputeHealthCheckUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating HealthCheck %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1032,7 +1026,6 @@ func resourceComputeHealthCheckUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1079,8 +1072,6 @@ func resourceComputeHealthCheckDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting HealthCheck %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1090,7 +1081,6 @@ func resourceComputeHealthCheckDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "HealthCheck") @@ -2118,6 +2108,7 @@ func expandComputeHealthCheckLogConfigEnable(v interface{}, d tpgresource.Terraf } func resourceComputeHealthCheckEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + if _, ok := d.GetOk("http_health_check"); ok { hc := d.Get("http_health_check").([]interface{})[0] ps := hc.(map[string]interface{})["port_specification"] diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_http_health_check.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_http_health_check.go index d59276abb47..b66799ac435 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_http_health_check.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_http_health_check.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -223,7 +222,6 @@ func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -232,7 +230,6 @@ func resourceComputeHttpHealthCheckCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating HttpHealthCheck: %s", err) @@ -285,14 +282,12 @@ func resourceComputeHttpHealthCheckRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeHttpHealthCheck %q", d.Id())) @@ -416,7 +411,6 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating HttpHealthCheck %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -431,7 +425,6 @@ func resourceComputeHttpHealthCheckUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -478,8 +471,6 @@ func resourceComputeHttpHealthCheckDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting HttpHealthCheck %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -489,7 +480,6 @@ func resourceComputeHttpHealthCheckDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "HttpHealthCheck") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_https_health_check.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_https_health_check.go index d6b930b9098..353cca2cd90 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_https_health_check.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_https_health_check.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -223,7 +222,6 @@ func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -232,7 +230,6 @@ func resourceComputeHttpsHealthCheckCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating HttpsHealthCheck: %s", err) @@ -285,14 +282,12 @@ func resourceComputeHttpsHealthCheckRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeHttpsHealthCheck %q", d.Id())) @@ -416,7 +411,6 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating HttpsHealthCheck %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -431,7 +425,6 @@ func resourceComputeHttpsHealthCheckUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -478,8 +471,6 @@ func resourceComputeHttpsHealthCheckDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting HttpsHealthCheck %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -489,7 +480,6 @@ func resourceComputeHttpsHealthCheckDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "HttpsHealthCheck") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_image.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_image.go index fe070bd6693..9972a76cdac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_image.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_image.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -410,7 +409,6 @@ func resourceComputeImageCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -419,7 +417,6 @@ func resourceComputeImageCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Image: %s", err) @@ -472,14 +469,12 @@ func resourceComputeImageRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeImage %q", d.Id())) @@ -585,8 +580,6 @@ func resourceComputeImageUpdate(d *schema.ResourceData, meta interface{}) error return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -600,7 +593,6 @@ func resourceComputeImageUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Image %q: %s", d.Id(), err) @@ -648,8 +640,6 @@ func resourceComputeImageDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Image %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -659,7 +649,6 @@ func resourceComputeImageDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Image") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance.go index b5d1f763296..e1e83f84d8d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance.go @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/mitchellh/hashstructure" @@ -26,30 +26,6 @@ import ( "google.golang.org/api/compute/v1" ) -func IpCidrRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - // The range may be a: - // A) single IP address (e.g. 10.2.3.4) - // B) CIDR format string (e.g. 10.1.2.0/24) - // C) netmask (e.g. /24) - // - // For A) and B), no diff to suppress, they have to match completely. - // For C), The API picks a network IP address and this creates a diff of the form: - // network_interface.0.alias_ip_range.0.ip_cidr_range: "10.128.1.0/24" => "/24" - // We should only compare the mask portion for this case. - if len(new) > 0 && new[0] == '/' { - oldNetmaskStartPos := strings.LastIndex(old, "/") - - if oldNetmaskStartPos != -1 { - oldNetmask := old[strings.LastIndex(old, "/"):] - if oldNetmask == new { - return true - } - } - } - - return false -} - var ( bootDiskKeys = []string{ "boot_disk.0.auto_delete", @@ -80,8 +56,6 @@ var ( "scheduling.0.min_node_cpus", "scheduling.0.provisioning_model", "scheduling.0.instance_termination_action", - "scheduling.0.max_run_duration", - "scheduling.0.on_instance_stop_action", "scheduling.0.local_ssd_recovery_timeout", } @@ -318,10 +292,9 @@ func ResourceComputeInstance() *schema.Resource { }, "machine_type": { - Type: schema.TypeString, - Required: true, - Description: `The machine type to create.`, - DiffSuppressFunc: tpgresource.CompareResourceNames, + Type: schema.TypeString, + Required: true, + Description: `The machine type to create.`, }, "name": { @@ -418,7 +391,7 @@ func ResourceComputeInstance() *schema.Resource { "ip_cidr_range": { Type: schema.TypeString, Required: true, - DiffSuppressFunc: IpCidrRangeDiffSuppress, + DiffSuppressFunc: tpgresource.IpCidrRangeDiffSuppress, Description: `The IP CIDR range represented by this alias IP range.`, }, "subnetwork_range_name": { @@ -776,51 +749,6 @@ func ResourceComputeInstance() *schema.Resource { AtLeastOneOf: schedulingKeys, Description: `Specifies the action GCE should take when SPOT VM is preempted.`, }, - "max_run_duration": { - Type: schema.TypeList, - Optional: true, - Description: `The timeout for new network connections to hosts.`, - MaxItems: 1, - ForceNew: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "seconds": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: `Span of time at a resolution of a second. -Must be from 0 to 315,576,000,000 inclusive.`, - }, - "nanos": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `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.`, - }, - }, - }, - }, - "on_instance_stop_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - ForceNew: true, - Description: `Defines the behaviour for instances with the instance_termination_action.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "discard_local_ssd": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, the contents of any attached Local SSD disks will be discarded.`, - Default: false, - ForceNew: true, - }, - }, - }, - }, "local_ssd_recovery_timeout": { Type: schema.TypeList, Optional: true, @@ -991,20 +919,11 @@ be from 0 to 999,999,999 inclusive.`, Description: `The Confidential VM config being used by the instance. on_host_maintenance has to be set to TERMINATE or this will fail to create.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "enable_confidential_compute": { - Type: schema.TypeBool, - Optional: true, - Description: `Defines whether the instance should have confidential compute enabled. Field will be deprecated in a future release`, - AtLeastOneOf: []string{"confidential_instance_config.0.enable_confidential_compute", "confidential_instance_config.0.confidential_instance_type"}, - }, - "confidential_instance_type": { - Type: schema.TypeString, - Optional: true, - Description: ` - Specifies which confidential computing technology to use. - This could be one of the following values: SEV, SEV_SNP. - If SEV_SNP, min_cpu_platform = "AMD Milan" is currently required.`, - AtLeastOneOf: []string{"confidential_instance_config.0.enable_confidential_compute", "confidential_instance_config.0.confidential_instance_type"}, + Type: schema.TypeBool, + Required: true, + Description: `Defines whether the instance should have confidential compute enabled.`, }, }, }, @@ -1333,7 +1252,7 @@ func waitUntilInstanceHasDesiredStatus(config *transport_tpg.Config, d *schema.R } return instance.Id, instance.Status, nil } - stateChangeConf := retry.StateChangeConf{ + stateChangeConf := resource.StateChangeConf{ Delay: 5 * time.Second, Pending: getAllStatusBut(desiredStatus), Refresh: stateRefreshFunc, @@ -1439,7 +1358,6 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("metadata_fingerprint", instance.Metadata.Fingerprint); err != nil { return fmt.Errorf("Error setting metadata_fingerprint: %s", err) } - if err := d.Set("can_ip_forward", instance.CanIpForward); err != nil { return fmt.Errorf("Error setting can_ip_forward: %s", err) } @@ -2279,7 +2197,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err desiredStatus := d.Get("desired_status").(string) if statusBeforeUpdate == "RUNNING" && desiredStatus != "TERMINATED" && !d.Get("allow_stopping_for_update").(bool) { - return fmt.Errorf("Changing the machine_type, min_cpu_platform, service_account, enable_display, shielded_instance_config, scheduling.node_affinities, scheduling.max_run_duration " + + return fmt.Errorf("Changing the machine_type, min_cpu_platform, service_account, enable_display, shielded_instance_config, scheduling.node_affinities " + "or network_interface.[#d].(network/subnetwork/subnetwork_project) or advanced_machine_features on a started instance requires stopping it. " + "To acknowledge this, please set allow_stopping_for_update = true in your config. " + "You can also stop it by setting desired_status = \"TERMINATED\", but the instance will not be restarted after the update.") @@ -2333,7 +2251,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err if d.HasChange("service_account.0.email") || scopesChange { sa := d.Get("service_account").([]interface{}) req := &compute.InstancesSetServiceAccountRequest{ForceSendFields: []string{"email"}} - if !isEmptyServiceAccountBlock(d) && len(sa) > 0 && sa[0] != nil { + if len(sa) > 0 && sa[0] != nil { saMap := sa[0].(map[string]interface{}) req.Email = saMap["email"].(string) req.Scopes = tpgresource.CanonicalizeServiceScopes(tpgresource.ConvertStringSet(saMap["scopes"].(*schema.Set))) @@ -2943,11 +2861,6 @@ func serviceAccountDiffSuppress(k, old, new string, d *schema.ResourceData) bool // suppress changes between { } and {scopes:[]} if l[0] != nil { contents := l[0].(map[string]interface{}) - email := contents["email"] - if email != "" { - // if email is non empty, don't suppress the diff - return false - } if scopes, ok := contents["scopes"]; ok { a := scopes.(*schema.Set).List() if a != nil && len(a) > 0 { @@ -2957,42 +2870,3 @@ func serviceAccountDiffSuppress(k, old, new string, d *schema.ResourceData) bool } return true } - -// isEmptyServiceAccountBlock is used to work around an issue when updating -// service accounts. Creating the instance with some scopes but without -// specifying a service account email, assigns default compute service account -// to the instance: -// -// service_account { -// scopes = ["some-scope"] -// } -// -// Then when updating the instance with empty service account: -// -// service_account { -// scopes = [] -// } -// -// the default Terraform behavior is to clear scopes without clearing the -// email. The email was previously computed to be the default service account -// and has not been modified, so the default plan is to leave it unchanged. -// However, when creating a new instance: -// -// service_account { -// scopes = [] -// } -// -// indicates an instance without any service account set. -// isEmptyServiceAccountBlock is used to detect empty service_account block -// and if it is, it is interpreted as no service account and no scopes. -func isEmptyServiceAccountBlock(d *schema.ResourceData) bool { - serviceAccountsConfig := d.GetRawConfig().GetAttr("service_account") - if serviceAccountsConfig.IsNull() || len(serviceAccountsConfig.AsValueSlice()) == 0 { - return true - } - serviceAccount := serviceAccountsConfig.AsValueSlice()[0] - if serviceAccount.GetAttr("email").IsNull() && len(serviceAccount.GetAttr("scopes").AsValueSlice()) == 0 { - return true - } - return false -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_manager.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_manager.go index 0fa24f4563e..a394898a5ce 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_manager.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_manager.go @@ -5,11 +5,12 @@ package compute import ( "fmt" "log" + "sort" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -224,8 +225,8 @@ func ResourceComputeInstanceGroupManager() *schema.Resource { "minimal_action": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"NONE", "REFRESH", "RESTART", "REPLACE"}, false), - Description: `Minimal action to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to update without stopping instances, RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a REFRESH, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`, + ValidateFunc: validation.StringInSlice([]string{"REFRESH", "RESTART", "REPLACE"}, false), + Description: `Minimal action to be taken on an instance. You can specify either REFRESH to update without stopping instances, RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a REFRESH, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`, }, "most_disruptive_allowed_action": { @@ -453,11 +454,6 @@ func ResourceComputeInstanceGroupManager() *schema.Resource { Computed: true, Description: `A bit indicating whether this configuration has been applied to all managed instances in the group.`, }, - "current_revision": { - Type: schema.TypeString, - Computed: true, - Description: `Current all-instances configuration revision. This value is in RFC3339 text format.`, - }, }, }, }, @@ -475,7 +471,7 @@ func ResourceComputeInstanceGroupManager() *schema.Resource { "per_instance_configs": { Type: schema.TypeList, Computed: true, - Description: `Status of per-instance configs on the instances.`, + Description: `Status of per-instance configs on the instance.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "all_effective": { @@ -721,8 +717,8 @@ func resourceComputeInstanceGroupManagerRead(d *schema.ResourceData, meta interf Name: operation, Zone: zone, } - if err := d.Set("operation", ""); err != nil { - return fmt.Errorf("Error unsetting operation: %s", err) + if err := d.Set("operation", op.Name); err != nil { + return fmt.Errorf("Error setting operation: %s", err) } err = ComputeOperationWaitTime(config, op, project, "Creating InstanceGroupManager", userAgent, d.Timeout(schema.TimeoutCreate)) if err != nil { @@ -1029,7 +1025,7 @@ func resourceComputeInstanceGroupManagerDelete(d *schema.ResourceData, meta inte func computeIGMWaitForInstanceStatus(d *schema.ResourceData, meta interface{}) error { waitForUpdates := d.Get("wait_for_instances_status").(string) == "UPDATED" - conf := retry.StateChangeConf{ + conf := resource.StateChangeConf{ Pending: []string{"creating", "error", "updating per instance configs", "reaching version target", "updating all instances config"}, Target: []string{"created"}, Refresh: waitForInstancesRefreshFunc(getManager, waitForUpdates, d, meta), @@ -1288,29 +1284,54 @@ func flattenStatefulPolicyStatefulExternalIps(d *schema.ResourceData, statefulPo } func flattenStatefulPolicyStatefulIps(d *schema.ResourceData, ipfieldName string, ips map[string]compute.StatefulPolicyPreservedStateNetworkIp) []map[string]interface{} { + // statefulPolicy.PreservedState.ExternalIPs and statefulPolicy.PreservedState.InternalIPs are affected by API-side reordering // of external/internal IPs, where ordering is done by the interface_name value. - // Below we reorder the IPs to match the order in the config. + // Below we intend to reorder the IPs to match the order in the config. // Also, data is converted from a map (client library's statefulPolicy.PreservedState.ExternalIPs, or .InternalIPs) to a slice (stored in state). // Any IPs found from the API response that aren't in the config are appended to the end of the slice. - configData := []map[string]interface{}{} - for _, item := range d.Get(ipfieldName).([]interface{}) { - configData = append(configData, item.(map[string]interface{})) + + configIpOrder := d.Get(ipfieldName).([]interface{}) + order := map[string]int{} // record map of interface name to index + for i, el := range configIpOrder { + ip := el.(map[string]interface{}) + interfaceName := ip["interface_name"].(string) + order[interfaceName] = i } - apiData := []map[string]interface{}{} + + orderedResult := make([]map[string]interface{}, len(configIpOrder)) + unexpectedIps := []map[string]interface{}{} for interfaceName, ip := range ips { data := map[string]interface{}{ "interface_name": interfaceName, "delete_rule": ip.AutoDelete, } - apiData = append(apiData, data) + + index, found := order[interfaceName] + if !found { + unexpectedIps = append(unexpectedIps, data) + continue + } + orderedResult[index] = data // Put elements from API response in order that matches the config } - sorted, err := tpgresource.SortMapsByConfigOrder(configData, apiData, "interface_name") - if err != nil { - log.Printf("[ERROR] Could not sort API response for %s: %s", ipfieldName, err) - return apiData + sort.Slice(unexpectedIps, func(i, j int) bool { + return unexpectedIps[i]["interface_name"].(string) < unexpectedIps[j]["interface_name"].(string) + }) + + // Remove any nils from the ordered list. This can occur if the API doesn't include an interface present in the config. + finalResult := []map[string]interface{}{} + for _, item := range orderedResult { + if item != nil { + finalResult = append(finalResult, item) + } } - return sorted + + if len(unexpectedIps) > 0 { + // Additional IPs returned from API but not in the config are appended to the end of the slice + finalResult = append(finalResult, unexpectedIps...) + } + + return finalResult } func flattenUpdatePolicy(updatePolicy *compute.InstanceGroupManagerUpdatePolicy) []map[string]interface{} { @@ -1452,8 +1473,7 @@ func flattenStatusVersionTarget(versionTarget *compute.InstanceGroupManagerStatu func flattenStatusAllInstancesConfig(allInstancesConfig *compute.InstanceGroupManagerStatusAllInstancesConfig) []map[string]interface{} { results := []map[string]interface{}{} data := map[string]interface{}{ - "effective": allInstancesConfig.Effective, - "current_revision": allInstancesConfig.CurrentRevision, + "effective": allInstancesConfig.Effective, } results = append(results, data) return results diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_membership.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_membership.go index d49aaa342e9..fd91cba3d7d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_membership.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_membership.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -129,7 +128,6 @@ func resourceComputeInstanceGroupMembershipCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -138,7 +136,6 @@ func resourceComputeInstanceGroupMembershipCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating InstanceGroupMembership: %s", err) @@ -191,14 +188,12 @@ func resourceComputeInstanceGroupMembershipRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeInstanceGroupMembership %q", d.Id())) @@ -261,7 +256,6 @@ func resourceComputeInstanceGroupMembershipDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) toDelete := make(map[string]interface{}) // Instance @@ -284,7 +278,6 @@ func resourceComputeInstanceGroupMembershipDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "InstanceGroupMembership") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_named_port.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_named_port.go index 95ef9514318..04916e203b0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_named_port.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_group_named_port.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -148,7 +147,6 @@ func resourceComputeInstanceGroupNamedPortCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -157,7 +155,6 @@ func resourceComputeInstanceGroupNamedPortCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating InstanceGroupNamedPort: %s", err) @@ -210,14 +207,12 @@ func resourceComputeInstanceGroupNamedPortRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeInstanceGroupNamedPort %q", d.Id())) @@ -296,8 +291,6 @@ func resourceComputeInstanceGroupNamedPortDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting InstanceGroupNamedPort %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -307,7 +300,6 @@ func resourceComputeInstanceGroupNamedPortDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "InstanceGroupNamedPort") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_settings.go deleted file mode 100644 index 94f181f3b18..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_settings.go +++ /dev/null @@ -1,482 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceComputeInstanceSettings() *schema.Resource { - return &schema.Resource{ - Create: resourceComputeInstanceSettingsCreate, - Read: resourceComputeInstanceSettingsRead, - Update: resourceComputeInstanceSettingsUpdate, - Delete: resourceComputeInstanceSettingsDelete, - - Importer: &schema.ResourceImporter{ - State: resourceComputeInstanceSettingsImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "zone": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `A reference to the zone where the machine resides.`, - }, - "metadata": { - Type: schema.TypeList, - Optional: true, - Description: `The metadata key/value pairs assigned to all the instances in the corresponding scope.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "items": { - Type: schema.TypeMap, - Optional: true, - Description: `A metadata key/value items map. The total size of all keys and values must be less than 512KB`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - }, - }, - }, - "fingerprint": { - Type: schema.TypeString, - Computed: true, - Description: `The fingerprint used for optimistic locking of this resource. Used -internally during updates.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceComputeInstanceSettingsCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - fingerprintProp, err := expandComputeInstanceSettingsFingerprint(d.Get("fingerprint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(fingerprintProp)) && (ok || !reflect.DeepEqual(v, fingerprintProp)) { - obj["fingerprint"] = fingerprintProp - } - metadataProp, err := expandComputeInstanceSettingsMetadata(d.Get("metadata"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("metadata"); !tpgresource.IsEmptyValue(reflect.ValueOf(metadataProp)) && (ok || !reflect.DeepEqual(v, metadataProp)) { - obj["metadata"] = metadataProp - } - zoneProp, err := expandComputeInstanceSettingsZone(d.Get("zone"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(zoneProp)) && (ok || !reflect.DeepEqual(v, zoneProp)) { - obj["zone"] = zoneProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/instanceSettings?update_mask=*") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new InstanceSettings: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceSettings: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating InstanceSettings: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/zones/{{zone}}/instanceSettings") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = ComputeOperationWaitTime( - config, res, project, "Creating InstanceSettings", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create InstanceSettings: %s", err) - } - - log.Printf("[DEBUG] Finished creating InstanceSettings %q: %#v", d.Id(), res) - - return resourceComputeInstanceSettingsRead(d, meta) -} - -func resourceComputeInstanceSettingsRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/instanceSettings") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceSettings: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeInstanceSettings %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading InstanceSettings: %s", err) - } - - if err := d.Set("fingerprint", flattenComputeInstanceSettingsFingerprint(res["fingerprint"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceSettings: %s", err) - } - if err := d.Set("metadata", flattenComputeInstanceSettingsMetadata(res["metadata"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceSettings: %s", err) - } - if err := d.Set("zone", flattenComputeInstanceSettingsZone(res["zone"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceSettings: %s", err) - } - - return nil -} - -func resourceComputeInstanceSettingsUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceSettings: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - fingerprintProp, err := expandComputeInstanceSettingsFingerprint(d.Get("fingerprint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, fingerprintProp)) { - obj["fingerprint"] = fingerprintProp - } - metadataProp, err := expandComputeInstanceSettingsMetadata(d.Get("metadata"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("metadata"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, metadataProp)) { - obj["metadata"] = metadataProp - } - zoneProp, err := expandComputeInstanceSettingsZone(d.Get("zone"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, zoneProp)) { - obj["zone"] = zoneProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/instanceSettings?update_mask=*") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating InstanceSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating InstanceSettings %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating InstanceSettings %q: %#v", d.Id(), res) - } - - err = ComputeOperationWaitTime( - config, res, project, "Updating InstanceSettings", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - - return resourceComputeInstanceSettingsRead(d, meta) -} - -func resourceComputeInstanceSettingsDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/instanceSettings") - if err != nil { - return err - } - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceSettings: %s", err) - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - }) - - if err != nil { - return err - } - - obj := map[string]interface{}{"fingerprint": res["fingerprint"], "metadata": map[string]interface{}{"items": map[string]string{}}} - log.Printf("[DEBUG] Emptying InstanceSettings %#v", obj) - - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": "*"}) - if err != nil { - return err - } - - res, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - }) - - if err != nil { - return fmt.Errorf("Error emptying InstanceSettings %s", err) - } else { - log.Printf("[DEBUG] Finished emptying InstanceSettings %#v", res) - } - - time.Sleep(1 * time.Minute) - - return nil -} - -func resourceComputeInstanceSettingsImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/zones/(?P[^/]+)/instanceSettings$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/zones/{{zone}}/instanceSettings") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenComputeInstanceSettingsFingerprint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInstanceSettingsMetadata(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["items"] = - flattenComputeInstanceSettingsMetadataItems(original["items"], d, config) - return []interface{}{transformed} -} -func flattenComputeInstanceSettingsMetadataItems(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInstanceSettingsZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - -func expandComputeInstanceSettingsFingerprint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - project, err := tpgresource.GetProject(d, config) - if err != nil { - return nil, err - } - - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return nil, err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/instanceSettings/{{name}}") - if err != nil { - return nil, err - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - }) - - if err != nil { - return nil, err - } - - return res["fingerprint"], nil -} - -func expandComputeInstanceSettingsMetadata(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedItems, err := expandComputeInstanceSettingsMetadataItems(original["items"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedItems); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["items"] = transformedItems - } - - return transformed, nil -} - -func expandComputeInstanceSettingsMetadataItems(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} - -func expandComputeInstanceSettingsZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - f, err := tpgresource.ParseGlobalFieldValue("zones", v.(string), "project", d, config, true) - if err != nil { - return nil, fmt.Errorf("Invalid value for zone: %s", err) - } - return f.RelativeLink(), nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_template.go index 6dd2d5806d9..d7f57ba098c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_instance_template.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/errwrap" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -31,8 +31,6 @@ var ( "scheduling.0.min_node_cpus", "scheduling.0.provisioning_model", "scheduling.0.instance_termination_action", - "scheduling.0.max_run_duration", - "scheduling.0.on_instance_stop_action", "scheduling.0.local_ssd_recovery_timeout", } @@ -487,7 +485,7 @@ Google Cloud KMS.`, Type: schema.TypeString, Required: true, ForceNew: true, - DiffSuppressFunc: IpCidrRangeDiffSuppress, + DiffSuppressFunc: tpgresource.IpCidrRangeDiffSuppress, Description: `The IP CIDR range represented by this alias IP range. This IP CIDR range must belong to the specified subnetwork and cannot contain IP addresses reserved by system or used by other network interfaces. At the time of writing only a netmask (e.g. /24) may be supplied, with a CIDR format resulting in an API error.`, }, "subnetwork_range_name": { @@ -678,51 +676,6 @@ Google Cloud KMS.`, AtLeastOneOf: schedulingInstTemplateKeys, Description: `Specifies the action GCE should take when SPOT VM is preempted.`, }, - "max_run_duration": { - Type: schema.TypeList, - Optional: true, - Description: `The timeout for new network connections to hosts.`, - MaxItems: 1, - ForceNew: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "seconds": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: `Span of time at a resolution of a second. -Must be from 0 to 315,576,000,000 inclusive.`, - }, - "nanos": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `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.`, - }, - }, - }, - }, - "on_instance_stop_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - ForceNew: true, - Description: `Defines the behaviour for instances with the instance_termination_action.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "discard_local_ssd": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, the contents of any attached Local SSD disks will be discarded.`, - Default: false, - ForceNew: true, - }, - }, - }, - }, "local_ssd_recovery_timeout": { Type: schema.TypeList, Optional: true, @@ -854,22 +807,12 @@ be from 0 to 999,999,999 inclusive.`, Description: `The Confidential VM config being used by the instance. on_host_maintenance has to be set to TERMINATE or this will fail to create.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "enable_confidential_compute": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Defines whether the instance should have confidential compute enabled. Field will be deprecated in a future release.`, - AtLeastOneOf: []string{"confidential_instance_config.0.enable_confidential_compute", "confidential_instance_config.0.confidential_instance_type"}, - }, - "confidential_instance_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: ` - Specifies which confidential computing technology to use. - This could be one of the following values: SEV, SEV_SNP. - If SEV_SNP, min_cpu_platform = "AMD Milan" is currently required.`, - AtLeastOneOf: []string{"confidential_instance_config.0.enable_confidential_compute", "confidential_instance_config.0.confidential_instance_type"}, + Type: schema.TypeBool, + Required: true, + ForceNew: true, + Description: `Defines whether the instance should have confidential compute enabled.`, }, }, }, @@ -1376,9 +1319,9 @@ func resourceComputeInstanceTemplateCreate(d *schema.ResourceData, meta interfac if v, ok := d.GetOk("name"); ok { itName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - itName = id.PrefixedUniqueId(v.(string)) + itName = resource.PrefixedUniqueId(v.(string)) } else { - itName = id.UniqueId() + itName = resource.UniqueId() } instanceTemplate := &compute.InstanceTemplate{ Description: d.Get("description").(string), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect.go deleted file mode 100644 index 93b986f3df7..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect.go +++ /dev/null @@ -1,1215 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceComputeInterconnect() *schema.Resource { - return &schema.Resource{ - Create: resourceComputeInterconnectCreate, - Read: resourceComputeInterconnectRead, - Update: resourceComputeInterconnectUpdate, - Delete: resourceComputeInterconnectDelete, - - Importer: &schema.ResourceImporter{ - State: resourceComputeInterconnectImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "customer_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Customer name, to put in the Letter of Authorization as the party authorized to request a -crossconnect.`, - }, - "interconnect_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"DEDICATED", "PARTNER", "IT_PRIVATE"}), - Description: `Type of interconnect. Note that a value IT_PRIVATE has been deprecated in favor of DEDICATED. -Can take one of the following values: - - PARTNER: A partner-managed interconnection shared between customers though a partner. - - DEDICATED: A dedicated physical interconnection with the customer. Possible values: ["DEDICATED", "PARTNER", "IT_PRIVATE"]`, - }, - "link_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"LINK_TYPE_ETHERNET_10G_LR", "LINK_TYPE_ETHERNET_100G_LR"}), - Description: `Type of link requested. Note that this field indicates the speed of each of the links in the -bundle, not the speed of the entire bundle. Can take one of the following values: - - LINK_TYPE_ETHERNET_10G_LR: A 10G Ethernet with LR optics. - - LINK_TYPE_ETHERNET_100G_LR: A 100G Ethernet with LR optics. Possible values: ["LINK_TYPE_ETHERNET_10G_LR", "LINK_TYPE_ETHERNET_100G_LR"]`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `URL of the InterconnectLocation object that represents where this connection is to be provisioned.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^[a-z]([-a-z0-9]*[a-z0-9])?$`), - Description: `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.`, - }, - "requested_link_count": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: `Target number of physical links in the link bundle, as requested by the customer.`, - }, - "admin_enabled": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Administrative status of the interconnect. When this is set to true, the Interconnect is -functional and can carry traffic. When set to false, no packets can be carried over the -interconnect and no BGP routes are exchanged over it. By default, the status is set to true.`, - Default: true, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `An optional description of this resource. Provide this property when you create the resource.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `Labels for this resource. These can only be added or modified by the setLabels -method. Each label key/value pair must comply with RFC1035. Label values may be empty. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "macsec": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Configuration that enables Media Access Control security (MACsec) on the Cloud -Interconnect connection between Google and your on-premises router.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pre_shared_keys": { - Type: schema.TypeList, - Required: true, - ForceNew: true, - Description: `A keychain placeholder describing a set of named key objects along with their -start times. A MACsec CKN/CAK is generated for each key in the key chain. -Google router automatically picks the key with the most recent startTime when establishing -or re-establishing a MACsec secure link.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^[a-z]([-a-z0-9]*[a-z0-9])?$`), - Description: `A name for this pre-shared key. 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.`, - }, - "fail_open": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `If set to true, the Interconnect connection is configured with a should-secure -MACsec security policy, that allows the Google router to fallback to cleartext -traffic if the MKA session cannot be established. By default, the Interconnect -connection is configured with a must-secure security policy that drops all traffic -if the MKA session cannot be established with your router.`, - }, - "start_time": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `A RFC3339 timestamp on or after which the key is valid. startTime can be in the -future. If the keychain has a single key, startTime can be omitted. If the keychain -has multiple keys, startTime is mandatory for each key. The start times of keys must -be in increasing order. The start times of two consecutive keys must be at least 6 -hours apart.`, - }, - }, - }, - }, - }, - }, - }, - "macsec_enabled": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Enable or disable MACsec on this Interconnect connection. -MACsec enablement fails if the MACsec object is not specified.`, - }, - "noc_contact_email": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Email address to contact the customer NOC for operations and maintenance notifications -regarding this Interconnect. If specified, this will be used for notifications in addition to -all other forms described, such as Cloud Monitoring logs alerting and Cloud Notifications. -This field is required for users who sign up for Cloud Interconnect using workforce identity -federation.`, - }, - "remote_location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Indicates that this is a Cross-Cloud Interconnect. This field specifies the location outside -of Google's network that the interconnect is connected to.`, - }, - "requested_features": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `interconnects.list of features requested for this Interconnect connection. Options: MACSEC ( -If specified then the connection is created on MACsec capable hardware ports. If not -specified, the default value is false, which allocates non-MACsec capable ports first if -available). Possible values: ["MACSEC"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"MACSEC"}), - }, - }, - "available_features": { - Type: schema.TypeList, - Computed: true, - Description: `interconnects.list of features available for this Interconnect connection. Can take the value: -MACSEC. If present then the Interconnect connection is provisioned on MACsec capable hardware -ports. If not present then the Interconnect connection is provisioned on non-MACsec capable -ports and MACsec isn't supported and enabling MACsec fails).`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "circuit_infos": { - Type: schema.TypeList, - Computed: true, - Description: `A list of CircuitInfo objects, that describe the individual circuits in this LAG.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "customer_demarc_id": { - Type: schema.TypeString, - Computed: true, - Description: `Customer-side demarc ID for this circuit.`, - }, - "google_circuit_id": { - Type: schema.TypeString, - Computed: true, - Description: `Google-assigned unique ID for this circuit. Assigned at circuit turn-up.`, - }, - "google_demarc_id": { - Type: schema.TypeString, - Computed: true, - Description: `Google-side demarc ID for this circuit. Assigned at circuit turn-up and provided by -Google to the customer in the LOA.`, - }, - }, - }, - }, - "creation_timestamp": { - Type: schema.TypeString, - Computed: true, - Description: `Creation timestamp in RFC3339 text format.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - ForceNew: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "expected_outages": { - Type: schema.TypeList, - Computed: true, - Description: `A list of outages expected for this Interconnect.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "affected_circuits": { - Type: schema.TypeList, - Computed: true, - Description: `If issueType is IT_PARTIAL_OUTAGE, a list of the Google-side circuit IDs that will be -affected.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": { - Type: schema.TypeString, - Computed: true, - Description: `A description about the purpose of the outage.`, - }, - "end_time": { - Type: schema.TypeString, - Computed: true, - Description: `Scheduled end time for the outage (milliseconds since Unix epoch).`, - }, - "issue_type": { - Type: schema.TypeString, - Computed: true, - Description: `Form this outage is expected to take. Note that the versions of this enum prefixed with -"IT_" have been deprecated in favor of the unprefixed values. Can take one of the -following values: - - OUTAGE: The Interconnect may be completely out of service for some or all of the - specified window. - - PARTIAL_OUTAGE: Some circuits comprising the Interconnect as a whole should remain - up, but with reduced bandwidth.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `Unique identifier for this outage notification.`, - }, - "source": { - Type: schema.TypeString, - Computed: true, - Description: `The party that generated this notification. Note that the value of NSRC_GOOGLE has been -deprecated in favor of GOOGLE. Can take the following value: - - GOOGLE: this notification as generated by Google.`, - }, - "start_time": { - Type: schema.TypeString, - Computed: true, - Description: `Scheduled start time for the outage (milliseconds since Unix epoch).`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `State of this notification. Note that the versions of this enum prefixed with "NS_" have -been deprecated in favor of the unprefixed values. Can take one of the following values: - - ACTIVE: This outage notification is active. The event could be in the past, present, - or future. See startTime and endTime for scheduling. - - CANCELLED: The outage associated with this notification was cancelled before the - outage was due to start. - - COMPLETED: The outage associated with this notification is complete.`, - }, - }, - }, - }, - "google_ip_address": { - Type: schema.TypeString, - Computed: true, - Description: `IP address configured on the Google side of the Interconnect link. -This can be used only for ping tests.`, - }, - "google_reference_id": { - Type: schema.TypeString, - Computed: true, - Description: `Google reference ID to be used when raising support tickets with Google or otherwise to debug -backend connectivity issues.`, - }, - "interconnect_attachments": { - Type: schema.TypeList, - Computed: true, - Description: `A list of the URLs of all InterconnectAttachments configured to use this Interconnect.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "label_fingerprint": { - Type: schema.TypeString, - Computed: true, - Description: `A fingerprint for the labels being applied to this Interconnect, which is essentially a hash -of the labels set used for optimistic locking. The fingerprint is initially generated by -Compute Engine and changes after every request to modify or update labels. -You must always provide an up-to-date fingerprint hash in order to update or change labels, -otherwise the request will fail with error 412 conditionNotMet.`, - }, - "operational_status": { - Type: schema.TypeString, - Computed: true, - Description: `The current status of this Interconnect's functionality, which can take one of the following: - - OS_ACTIVE: A valid Interconnect, which is turned up and is ready to use. Attachments may - be provisioned on this Interconnect. - - OS_UNPROVISIONED: An Interconnect that has not completed turnup. No attachments may be - provisioned on this Interconnect. - - OS_UNDER_MAINTENANCE: An Interconnect that is undergoing internal maintenance. No - attachments may be provisioned or updated on this Interconnect.`, - }, - "peer_ip_address": { - Type: schema.TypeString, - Computed: true, - Description: `IP address configured on the customer side of the Interconnect link. -The customer should configure this IP address during turnup when prompted by Google NOC. -This can be used only for ping tests.`, - }, - "provisioned_link_count": { - Type: schema.TypeInt, - Computed: true, - Description: `Number of links actually provisioned in this interconnect.`, - }, - "satisfies_pzs": { - Type: schema.TypeBool, - Computed: true, - Description: `Reserved for future use.`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `The current state of Interconnect functionality, which can take one of the following values: - - ACTIVE: The Interconnect is valid, turned up and ready to use. - Attachments may be provisioned on this Interconnect. - - UNPROVISIONED: The Interconnect has not completed turnup. No attachments may b - provisioned on this Interconnect. - - UNDER_MAINTENANCE: The Interconnect is undergoing internal maintenance. No attachments may - be provisioned or updated on this Interconnect.`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceComputeInterconnectCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandComputeInterconnectDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - nameProp, err := expandComputeInterconnectName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - locationProp, err := expandComputeInterconnectLocation(d.Get("location"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("location"); !tpgresource.IsEmptyValue(reflect.ValueOf(locationProp)) && (ok || !reflect.DeepEqual(v, locationProp)) { - obj["location"] = locationProp - } - linkTypeProp, err := expandComputeInterconnectLinkType(d.Get("link_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("link_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(linkTypeProp)) && (ok || !reflect.DeepEqual(v, linkTypeProp)) { - obj["linkType"] = linkTypeProp - } - requestedLinkCountProp, err := expandComputeInterconnectRequestedLinkCount(d.Get("requested_link_count"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("requested_link_count"); !tpgresource.IsEmptyValue(reflect.ValueOf(requestedLinkCountProp)) && (ok || !reflect.DeepEqual(v, requestedLinkCountProp)) { - obj["requestedLinkCount"] = requestedLinkCountProp - } - interconnectTypeProp, err := expandComputeInterconnectInterconnectType(d.Get("interconnect_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("interconnect_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(interconnectTypeProp)) && (ok || !reflect.DeepEqual(v, interconnectTypeProp)) { - obj["interconnectType"] = interconnectTypeProp - } - adminEnabledProp, err := expandComputeInterconnectAdminEnabled(d.Get("admin_enabled"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("admin_enabled"); ok || !reflect.DeepEqual(v, adminEnabledProp) { - obj["adminEnabled"] = adminEnabledProp - } - nocContactEmailProp, err := expandComputeInterconnectNocContactEmail(d.Get("noc_contact_email"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("noc_contact_email"); !tpgresource.IsEmptyValue(reflect.ValueOf(nocContactEmailProp)) && (ok || !reflect.DeepEqual(v, nocContactEmailProp)) { - obj["nocContactEmail"] = nocContactEmailProp - } - customerNameProp, err := expandComputeInterconnectCustomerName(d.Get("customer_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("customer_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(customerNameProp)) && (ok || !reflect.DeepEqual(v, customerNameProp)) { - obj["customerName"] = customerNameProp - } - labelFingerprintProp, err := expandComputeInterconnectLabelFingerprint(d.Get("label_fingerprint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("label_fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelFingerprintProp)) && (ok || !reflect.DeepEqual(v, labelFingerprintProp)) { - obj["labelFingerprint"] = labelFingerprintProp - } - macsecProp, err := expandComputeInterconnectMacsec(d.Get("macsec"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("macsec"); !tpgresource.IsEmptyValue(reflect.ValueOf(macsecProp)) && (ok || !reflect.DeepEqual(v, macsecProp)) { - obj["macsec"] = macsecProp - } - macsecEnabledProp, err := expandComputeInterconnectMacsecEnabled(d.Get("macsec_enabled"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("macsec_enabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(macsecEnabledProp)) && (ok || !reflect.DeepEqual(v, macsecEnabledProp)) { - obj["macsecEnabled"] = macsecEnabledProp - } - remoteLocationProp, err := expandComputeInterconnectRemoteLocation(d.Get("remote_location"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("remote_location"); !tpgresource.IsEmptyValue(reflect.ValueOf(remoteLocationProp)) && (ok || !reflect.DeepEqual(v, remoteLocationProp)) { - obj["remoteLocation"] = remoteLocationProp - } - requestedFeaturesProp, err := expandComputeInterconnectRequestedFeatures(d.Get("requested_features"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("requested_features"); !tpgresource.IsEmptyValue(reflect.ValueOf(requestedFeaturesProp)) && (ok || !reflect.DeepEqual(v, requestedFeaturesProp)) { - obj["requestedFeatures"] = requestedFeaturesProp - } - labelsProp, err := expandComputeInterconnectEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/interconnects") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new Interconnect: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Interconnect: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating Interconnect: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/global/interconnects/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = ComputeOperationWaitTime( - config, res, project, "Creating Interconnect", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create Interconnect: %s", err) - } - - log.Printf("[DEBUG] Finished creating Interconnect %q: %#v", d.Id(), res) - - return resourceComputeInterconnectRead(d, meta) -} - -func resourceComputeInterconnectRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/interconnects/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Interconnect: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeInterconnect %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - - if err := d.Set("description", flattenComputeInterconnectDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("creation_timestamp", flattenComputeInterconnectCreationTimestamp(res["creationTimestamp"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("name", flattenComputeInterconnectName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("location", flattenComputeInterconnectLocation(res["location"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("link_type", flattenComputeInterconnectLinkType(res["linkType"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("requested_link_count", flattenComputeInterconnectRequestedLinkCount(res["requestedLinkCount"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("interconnect_type", flattenComputeInterconnectInterconnectType(res["interconnectType"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("admin_enabled", flattenComputeInterconnectAdminEnabled(res["adminEnabled"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("noc_contact_email", flattenComputeInterconnectNocContactEmail(res["nocContactEmail"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("customer_name", flattenComputeInterconnectCustomerName(res["customerName"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("operational_status", flattenComputeInterconnectOperationalStatus(res["operationalStatus"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("provisioned_link_count", flattenComputeInterconnectProvisionedLinkCount(res["provisionedLinkCount"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("interconnect_attachments", flattenComputeInterconnectInterconnectAttachments(res["interconnectAttachments"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("peer_ip_address", flattenComputeInterconnectPeerIpAddress(res["peerIpAddress"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("google_ip_address", flattenComputeInterconnectGoogleIpAddress(res["googleIpAddress"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("google_reference_id", flattenComputeInterconnectGoogleReferenceId(res["googleReferenceId"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("expected_outages", flattenComputeInterconnectExpectedOutages(res["expectedOutages"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("circuit_infos", flattenComputeInterconnectCircuitInfos(res["circuitInfos"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("labels", flattenComputeInterconnectLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("label_fingerprint", flattenComputeInterconnectLabelFingerprint(res["labelFingerprint"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("state", flattenComputeInterconnectState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("satisfies_pzs", flattenComputeInterconnectSatisfiesPzs(res["satisfiesPzs"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("macsec", flattenComputeInterconnectMacsec(res["macsec"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("macsec_enabled", flattenComputeInterconnectMacsecEnabled(res["macsecEnabled"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("remote_location", flattenComputeInterconnectRemoteLocation(res["remoteLocation"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("requested_features", flattenComputeInterconnectRequestedFeatures(res["requestedFeatures"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("available_features", flattenComputeInterconnectAvailableFeatures(res["availableFeatures"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("terraform_labels", flattenComputeInterconnectTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - if err := d.Set("effective_labels", flattenComputeInterconnectEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading Interconnect: %s", err) - } - - return nil -} - -func resourceComputeInterconnectUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels" and "terraform_labels" are mutable - return resourceComputeInterconnectRead(d, meta) -} - -func resourceComputeInterconnectDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Interconnect: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/interconnects/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting Interconnect %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "Interconnect") - } - - err = ComputeOperationWaitTime( - config, res, project, "Deleting Interconnect", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting Interconnect %q: %#v", d.Id(), res) - return nil -} - -func resourceComputeInterconnectImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/global/interconnects/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/global/interconnects/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenComputeInterconnectDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectCreationTimestamp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - -func flattenComputeInterconnectLinkType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectRequestedLinkCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeInterconnectInterconnectType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectAdminEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectNocContactEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectCustomerName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectOperationalStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectProvisionedLinkCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeInterconnectInterconnectAttachments(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectPeerIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectGoogleIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectGoogleReferenceId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutages(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenComputeInterconnectExpectedOutagesName(original["name"], d, config), - "description": flattenComputeInterconnectExpectedOutagesDescription(original["description"], d, config), - "source": flattenComputeInterconnectExpectedOutagesSource(original["source"], d, config), - "state": flattenComputeInterconnectExpectedOutagesState(original["state"], d, config), - "issue_type": flattenComputeInterconnectExpectedOutagesIssueType(original["issueType"], d, config), - "affected_circuits": flattenComputeInterconnectExpectedOutagesAffectedCircuits(original["affectedCircuits"], d, config), - "start_time": flattenComputeInterconnectExpectedOutagesStartTime(original["startTime"], d, config), - "end_time": flattenComputeInterconnectExpectedOutagesEndTime(original["endTime"], d, config), - }) - } - return transformed -} -func flattenComputeInterconnectExpectedOutagesName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesSource(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesIssueType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesAffectedCircuits(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesStartTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectExpectedOutagesEndTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectCircuitInfos(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "google_circuit_id": flattenComputeInterconnectCircuitInfosGoogleCircuitId(original["googleCircuitId"], d, config), - "google_demarc_id": flattenComputeInterconnectCircuitInfosGoogleDemarcId(original["googleDemarcId"], d, config), - "customer_demarc_id": flattenComputeInterconnectCircuitInfosCustomerDemarcId(original["customerDemarcId"], d, config), - }) - } - return transformed -} -func flattenComputeInterconnectCircuitInfosGoogleCircuitId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectCircuitInfosGoogleDemarcId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectCircuitInfosCustomerDemarcId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenComputeInterconnectLabelFingerprint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectSatisfiesPzs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectMacsec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["pre_shared_keys"] = - flattenComputeInterconnectMacsecPreSharedKeys(original["preSharedKeys"], d, config) - return []interface{}{transformed} -} -func flattenComputeInterconnectMacsecPreSharedKeys(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenComputeInterconnectMacsecPreSharedKeysName(original["name"], d, config), - "start_time": flattenComputeInterconnectMacsecPreSharedKeysStartTime(original["startTime"], d, config), - "fail_open": flattenComputeInterconnectMacsecPreSharedKeysFailOpen(original["failOpen"], d, config), - }) - } - return transformed -} -func flattenComputeInterconnectMacsecPreSharedKeysName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectMacsecPreSharedKeysStartTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectMacsecPreSharedKeysFailOpen(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectMacsecEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectRemoteLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectRequestedFeatures(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectAvailableFeatures(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenComputeInterconnectEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandComputeInterconnectDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectLinkType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectRequestedLinkCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectInterconnectType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectAdminEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectNocContactEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectCustomerName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectLabelFingerprint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectMacsec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPreSharedKeys, err := expandComputeInterconnectMacsecPreSharedKeys(original["pre_shared_keys"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPreSharedKeys); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["preSharedKeys"] = transformedPreSharedKeys - } - - return transformed, nil -} - -func expandComputeInterconnectMacsecPreSharedKeys(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandComputeInterconnectMacsecPreSharedKeysName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedStartTime, err := expandComputeInterconnectMacsecPreSharedKeysStartTime(original["start_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStartTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["startTime"] = transformedStartTime - } - - transformedFailOpen, err := expandComputeInterconnectMacsecPreSharedKeysFailOpen(original["fail_open"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFailOpen); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["failOpen"] = transformedFailOpen - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeInterconnectMacsecPreSharedKeysName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectMacsecPreSharedKeysStartTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectMacsecPreSharedKeysFailOpen(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectMacsecEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectRemoteLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectRequestedFeatures(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeInterconnectEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_attachment.go index 1f404ac2fa1..043bce5e968 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_attachment.go @@ -20,12 +20,11 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -37,15 +36,15 @@ import ( // "UNPROVISIONED" state, to indicate that it's either ready or awaiting partner // activity. func waitForAttachmentToBeProvisioned(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceComputeInterconnectAttachmentRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) state := d.Get("state").(string) if state == "UNPROVISIONED" { - return retry.RetryableError(fmt.Errorf("InterconnectAttachment %q has state %q.", name, state)) + return resource.RetryableError(fmt.Errorf("InterconnectAttachment %q has state %q.", name, state)) } log.Printf("InterconnectAttachment %q has state %q.", name, state) return nil @@ -154,9 +153,11 @@ domain. If not specified, the value will default to AVAILABILITY_DOMAIN_ANY.`, Description: `Indicates the user-supplied encryption option of this interconnect attachment. Can only be specified at attachment creation for PARTNER or DEDICATED attachments. + * NONE - This is the default value, which means that the VLAN attachment carries unencrypted traffic. VMs are able to send traffic to, or receive traffic from, such a VLAN attachment. + * IPSEC - The VLAN attachment carries only encrypted traffic that is encrypted by an IPsec device, such as an HA VPN gateway or third-party IPsec VPN. VMs cannot directly send traffic to, or receive traffic from, @@ -180,14 +181,17 @@ be set if type is PARTNER.`, Description: `URL of addresses that have been reserved for the interconnect attachment, Used only for interconnect attachment that has the encryption option as IPSEC. + The addresses must be RFC 1918 IP address ranges. When creating HA VPN gateway over the interconnect attachment, if the attachment is configured to use an RFC 1918 IP address, then the VPN gateway's IP address will be allocated from the IP address range specified here. + For example, if the HA VPN gateway's interface 0 is paired to this interconnect attachment, then an RFC 1918 IP address for the VPN gateway interface 0 will be allocated from the IP address specified for this interconnect attachment. + If this field is not specified for interconnect attachment that has encryption option as IPSEC, later on when creating HA VPN gateway on this interconnect attachment, the HA VPN gateway's IP address will be @@ -218,19 +222,9 @@ this interconnect attachment. Currently, only 1440 and 1500 are allowed. If not ValidateFunc: verify.ValidateEnum([]string{"IPV4_IPV6", "IPV4_ONLY", ""}), Description: `The stack type for this interconnect attachment to identify whether the IPv6 feature is enabled or not. If not specified, IPV4_ONLY will be used. + This field can be both set at interconnect attachments creation and update interconnect attachment operations. Possible values: ["IPV4_IPV6", "IPV4_ONLY"]`, - }, - "subnet_length": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `Length of the IPv4 subnet mask. Allowed values: 29 (default), 30. The default value is 29, -except for Cross-Cloud Interconnect connections that use an InterconnectRemoteLocation with a -constraints.subnetLengthRange.min equal to 30. For example, connections that use an Azure -remote location fall into this category. In these cases, the default value is 30, and -requesting 29 returns an error. Where both 29 and 30 are allowed, 29 is preferred, because it -gives Google Cloud Support more debugging visibility.`, }, "type": { Type: schema.TypeString, @@ -253,12 +247,6 @@ using PARTNER type this will be managed upstream.`, Type: schema.TypeString, Computed: true, Description: `IPv4 address + prefix length to be configured on Cloud Router -Interface for this interconnect attachment.`, - }, - "cloud_router_ipv6_address": { - Type: schema.TypeString, - Computed: true, - Description: `IPv6 address + prefix length to be configured on Cloud Router Interface for this interconnect attachment.`, }, "creation_timestamp": { @@ -270,12 +258,6 @@ Interface for this interconnect attachment.`, Type: schema.TypeString, Computed: true, Description: `IPv4 address + prefix length to be configured on the customer -router subinterface for this interconnect attachment.`, - }, - "customer_router_ipv6_address": { - Type: schema.TypeString, - Computed: true, - Description: `IPv6 address + prefix length to be configured on the customer router subinterface for this interconnect attachment.`, }, "google_reference_id": { @@ -426,12 +408,6 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in } else if v, ok := d.GetOkExists("stack_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(stackTypeProp)) && (ok || !reflect.DeepEqual(v, stackTypeProp)) { obj["stackType"] = stackTypeProp } - subnetLengthProp, err := expandComputeInterconnectAttachmentSubnetLength(d.Get("subnet_length"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("subnet_length"); !tpgresource.IsEmptyValue(reflect.ValueOf(subnetLengthProp)) && (ok || !reflect.DeepEqual(v, subnetLengthProp)) { - obj["subnetLength"] = subnetLengthProp - } regionProp, err := expandComputeInterconnectAttachmentRegion(d.Get("region"), d, config) if err != nil { return err @@ -458,7 +434,6 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -467,7 +442,6 @@ func resourceComputeInterconnectAttachmentCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating InterconnectAttachment: %s", err) @@ -524,14 +498,12 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeInterconnectAttachment %q", d.Id())) @@ -604,12 +576,6 @@ func resourceComputeInterconnectAttachmentRead(d *schema.ResourceData, meta inte if err := d.Set("stack_type", flattenComputeInterconnectAttachmentStackType(res["stackType"], d, config)); err != nil { return fmt.Errorf("Error reading InterconnectAttachment: %s", err) } - if err := d.Set("cloud_router_ipv6_address", flattenComputeInterconnectAttachmentCloudRouterIpv6Address(res["cloudRouterIpv6Address"], d, config)); err != nil { - return fmt.Errorf("Error reading InterconnectAttachment: %s", err) - } - if err := d.Set("customer_router_ipv6_address", flattenComputeInterconnectAttachmentCustomerRouterIpv6Address(res["customerRouterIpv6Address"], d, config)); err != nil { - return fmt.Errorf("Error reading InterconnectAttachment: %s", err) - } if err := d.Set("region", flattenComputeInterconnectAttachmentRegion(res["region"], d, config)); err != nil { return fmt.Errorf("Error reading InterconnectAttachment: %s", err) } @@ -679,7 +645,6 @@ func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating InterconnectAttachment %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -694,7 +659,6 @@ func resourceComputeInterconnectAttachmentUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -741,7 +705,6 @@ func resourceComputeInterconnectAttachmentDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) if err := waitForAttachmentToBeProvisioned(d, config, d.Timeout(schema.TimeoutCreate)); err != nil { return fmt.Errorf("Error waiting for InterconnectAttachment %q to be provisioned: %q", d.Get("name").(string), err) } @@ -755,7 +718,6 @@ func resourceComputeInterconnectAttachmentDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "InterconnectAttachment") @@ -931,14 +893,6 @@ func flattenComputeInterconnectAttachmentStackType(v interface{}, d *schema.Reso return v } -func flattenComputeInterconnectAttachmentCloudRouterIpv6Address(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeInterconnectAttachmentCustomerRouterIpv6Address(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenComputeInterconnectAttachmentRegion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -1018,10 +972,6 @@ func expandComputeInterconnectAttachmentStackType(v interface{}, d tpgresource.T return v, nil } -func expandComputeInterconnectAttachmentSubnetLength(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeInterconnectAttachmentRegion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { f, err := tpgresource.ParseGlobalFieldValue("regions", v.(string), "project", d, config, true) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_sweeper.go deleted file mode 100644 index b5e0a9c1906..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_interconnect_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("ComputeInterconnect", testSweepComputeInterconnect) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepComputeInterconnect(region string) error { - resourceName := "ComputeInterconnect" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/interconnects", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["interconnects"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/interconnects/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_managed_ssl_certificate.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_managed_ssl_certificate.go index 3978516e18f..39a360ac945 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_managed_ssl_certificate.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_managed_ssl_certificate.go @@ -20,9 +20,7 @@ package compute import ( "fmt" "log" - "net/http" "reflect" - "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -33,14 +31,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/verify" ) -// For managed SSL certs, if new is an absolute FQDN (trailing '.') but old isn't, treat them as equals. -func AbsoluteDomainSuppress(k, old, new string, _ *schema.ResourceData) bool { - if strings.HasPrefix(k, "managed.0.domains.") { - return old == strings.TrimRight(new, ".") || new == strings.TrimRight(old, ".") - } - return false -} - func ResourceComputeManagedSslCertificate() *schema.Resource { return &schema.Resource{ Create: resourceComputeManagedSslCertificateCreate, @@ -80,7 +70,7 @@ certificate is managed (as indicated by a value of 'MANAGED' in 'type').`, Type: schema.TypeList, Required: true, ForceNew: true, - DiffSuppressFunc: AbsoluteDomainSuppress, + DiffSuppressFunc: tpgresource.AbsoluteDomainSuppress, Description: `Domains for which a managed SSL certificate will be valid. Currently, there can be up to 100 domains in this list.`, MaxItems: 100, @@ -103,6 +93,7 @@ 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. + These are in the same namespace as the managed SSL certificates.`, }, "type": { @@ -205,7 +196,6 @@ func resourceComputeManagedSslCertificateCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -214,7 +204,6 @@ func resourceComputeManagedSslCertificateCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ManagedSslCertificate: %s", err) @@ -267,14 +256,12 @@ func resourceComputeManagedSslCertificateRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeManagedSslCertificate %q", d.Id())) @@ -342,8 +329,6 @@ func resourceComputeManagedSslCertificateDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ManagedSslCertificate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -353,7 +338,6 @@ func resourceComputeManagedSslCertificateDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ManagedSslCertificate") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network.go index 726dcc7fce2..37eba42d832 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -250,7 +249,6 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -259,7 +257,6 @@ func resourceComputeNetworkCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Network: %s", err) @@ -344,14 +341,12 @@ func resourceComputeNetworkRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetwork %q", d.Id())) @@ -471,8 +466,6 @@ func resourceComputeNetworkUpdate(d *schema.ResourceData, meta interface{}) erro return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -486,7 +479,6 @@ func resourceComputeNetworkUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Network %q: %s", d.Id(), err) @@ -534,8 +526,6 @@ func resourceComputeNetworkDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Network %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -545,7 +535,6 @@ func resourceComputeNetworkDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Network") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_attachment.go deleted file mode 100644 index 6976e4e0728..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_attachment.go +++ /dev/null @@ -1,623 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceComputeNetworkAttachment() *schema.Resource { - return &schema.Resource{ - Create: resourceComputeNetworkAttachmentCreate, - Read: resourceComputeNetworkAttachmentRead, - Delete: resourceComputeNetworkAttachmentDelete, - - Importer: &schema.ResourceImporter{ - State: resourceComputeNetworkAttachmentImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "connection_preference": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"ACCEPT_AUTOMATIC", "ACCEPT_MANUAL", "INVALID"}), - Description: `The connection preference of service attachment. The value can be set to ACCEPT_AUTOMATIC. An ACCEPT_AUTOMATIC service attachment is one that always accepts the connection from consumer forwarding rules. Possible values: ["ACCEPT_AUTOMATIC", "ACCEPT_MANUAL", "INVALID"]`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `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.`, - }, - "region": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `URL of the region where the network attachment resides. This field applies only to the region resource. You must specify this field as part of the HTTP request URL. It is not settable as a field in the request body.`, - }, - "subnetworks": { - Type: schema.TypeList, - Required: true, - ForceNew: true, - Description: `An array of URLs where each entry is the URL of a subnet provided by the service consumer to use for endpoints in the producers that connect to this network attachment.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `An optional description of this resource. Provide this property when you create the resource.`, - }, - "producer_accept_lists": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Projects that are allowed to connect to this network attachment. The project can be specified using its id or number.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "producer_reject_lists": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Projects that are not allowed to connect to this network attachment. The project can be specified using its id or number.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "connection_endpoints": { - Type: schema.TypeList, - Computed: true, - Description: `An array of connections for all the producers connected to this network attachment.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ip_address": { - Type: schema.TypeString, - Computed: true, - Description: `The IPv4 address assigned to the producer instance network interface. This value will be a range in case of Serverless.`, - }, - "project_id_or_num": { - Type: schema.TypeString, - Computed: true, - Description: `The project id or number of the interface to which the IP was assigned.`, - }, - "secondary_ip_cidr_ranges": { - Type: schema.TypeString, - Computed: true, - Description: `Alias IP ranges from the same subnetwork.`, - }, - "status": { - Type: schema.TypeString, - Computed: true, - Description: `The status of a connected endpoint to this network attachment.`, - }, - "subnetwork": { - Type: schema.TypeString, - Computed: true, - Description: `The subnetwork used to assign the IP to the producer instance network interface.`, - }, - }, - }, - }, - "creation_timestamp": { - Type: schema.TypeString, - Computed: true, - Description: `Creation timestamp in RFC3339 text format.`, - }, - "fingerprint": { - Type: schema.TypeString, - Computed: true, - Description: `Fingerprint of this resource. A hash of the contents stored in this object. This -field is used in optimistic locking. An up-to-date fingerprint must be provided in order to patch.`, - }, - "id": { - Type: schema.TypeString, - Computed: true, - Description: `The unique identifier for the resource type. The server generates this identifier.`, - }, - "kind": { - Type: schema.TypeString, - Computed: true, - Description: `Type of the resource.`, - }, - "network": { - Type: schema.TypeString, - Computed: true, - Description: `The URL of the network which the Network Attachment belongs to. Practically it is inferred by fetching the network of the first subnetwork associated. -Because it is required that all the subnetworks must be from the same network, it is assured that the Network Attachment belongs to the same network as all the subnetworks.`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - Description: `Server-defined URL for the resource.`, - }, - "self_link_with_id": { - Type: schema.TypeString, - Computed: true, - Description: `Server-defined URL for this resource's resource id.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceComputeNetworkAttachmentCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandComputeNetworkAttachmentDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - connectionPreferenceProp, err := expandComputeNetworkAttachmentConnectionPreference(d.Get("connection_preference"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("connection_preference"); !tpgresource.IsEmptyValue(reflect.ValueOf(connectionPreferenceProp)) && (ok || !reflect.DeepEqual(v, connectionPreferenceProp)) { - obj["connectionPreference"] = connectionPreferenceProp - } - subnetworksProp, err := expandComputeNetworkAttachmentSubnetworks(d.Get("subnetworks"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("subnetworks"); !tpgresource.IsEmptyValue(reflect.ValueOf(subnetworksProp)) && (ok || !reflect.DeepEqual(v, subnetworksProp)) { - obj["subnetworks"] = subnetworksProp - } - producerRejectListsProp, err := expandComputeNetworkAttachmentProducerRejectLists(d.Get("producer_reject_lists"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("producer_reject_lists"); !tpgresource.IsEmptyValue(reflect.ValueOf(producerRejectListsProp)) && (ok || !reflect.DeepEqual(v, producerRejectListsProp)) { - obj["producerRejectLists"] = producerRejectListsProp - } - producerAcceptListsProp, err := expandComputeNetworkAttachmentProducerAcceptLists(d.Get("producer_accept_lists"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("producer_accept_lists"); !tpgresource.IsEmptyValue(reflect.ValueOf(producerAcceptListsProp)) && (ok || !reflect.DeepEqual(v, producerAcceptListsProp)) { - obj["producerAcceptLists"] = producerAcceptListsProp - } - fingerprintProp, err := expandComputeNetworkAttachmentFingerprint(d.Get("fingerprint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("fingerprint"); !tpgresource.IsEmptyValue(reflect.ValueOf(fingerprintProp)) && (ok || !reflect.DeepEqual(v, fingerprintProp)) { - obj["fingerprint"] = fingerprintProp - } - nameProp, err := expandComputeNetworkAttachmentName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - regionProp, err := expandComputeNetworkAttachmentRegion(d.Get("region"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("region"); !tpgresource.IsEmptyValue(reflect.ValueOf(regionProp)) && (ok || !reflect.DeepEqual(v, regionProp)) { - obj["region"] = regionProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/networkAttachments") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new NetworkAttachment: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for NetworkAttachment: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating NetworkAttachment: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = ComputeOperationWaitTime( - config, res, project, "Creating NetworkAttachment", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create NetworkAttachment: %s", err) - } - - log.Printf("[DEBUG] Finished creating NetworkAttachment %q: %#v", d.Id(), res) - - return resourceComputeNetworkAttachmentRead(d, meta) -} - -func resourceComputeNetworkAttachmentRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for NetworkAttachment: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetworkAttachment %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - - if err := d.Set("kind", flattenComputeNetworkAttachmentKind(res["kind"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("id", flattenComputeNetworkAttachmentId(res["id"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("creation_timestamp", flattenComputeNetworkAttachmentCreationTimestamp(res["creationTimestamp"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("description", flattenComputeNetworkAttachmentDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("self_link", flattenComputeNetworkAttachmentSelfLink(res["selfLink"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("self_link_with_id", flattenComputeNetworkAttachmentSelfLinkWithId(res["selfLinkWithId"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("connection_preference", flattenComputeNetworkAttachmentConnectionPreference(res["connectionPreference"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("connection_endpoints", flattenComputeNetworkAttachmentConnectionEndpoints(res["connectionEndpoints"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("subnetworks", flattenComputeNetworkAttachmentSubnetworks(res["subnetworks"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("producer_reject_lists", flattenComputeNetworkAttachmentProducerRejectLists(res["producerRejectLists"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("producer_accept_lists", flattenComputeNetworkAttachmentProducerAcceptLists(res["producerAcceptLists"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("fingerprint", flattenComputeNetworkAttachmentFingerprint(res["fingerprint"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("network", flattenComputeNetworkAttachmentNetwork(res["network"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("name", flattenComputeNetworkAttachmentName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - if err := d.Set("region", flattenComputeNetworkAttachmentRegion(res["region"], d, config)); err != nil { - return fmt.Errorf("Error reading NetworkAttachment: %s", err) - } - - return nil -} - -func resourceComputeNetworkAttachmentDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for NetworkAttachment: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting NetworkAttachment %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "NetworkAttachment") - } - - err = ComputeOperationWaitTime( - config, res, project, "Deleting NetworkAttachment", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting NetworkAttachment %q: %#v", d.Id(), res) - return nil -} - -func resourceComputeNetworkAttachmentImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/regions/(?P[^/]+)/networkAttachments/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenComputeNetworkAttachmentKind(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentCreationTimestamp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentSelfLink(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentSelfLinkWithId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentConnectionPreference(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentConnectionEndpoints(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "status": flattenComputeNetworkAttachmentConnectionEndpointsStatus(original["status"], d, config), - "project_id_or_num": flattenComputeNetworkAttachmentConnectionEndpointsProjectIdOrNum(original["projectIdOrNum"], d, config), - "subnetwork": flattenComputeNetworkAttachmentConnectionEndpointsSubnetwork(original["subnetwork"], d, config), - "ip_address": flattenComputeNetworkAttachmentConnectionEndpointsIpAddress(original["ipAddress"], d, config), - "secondary_ip_cidr_ranges": flattenComputeNetworkAttachmentConnectionEndpointsSecondaryIpCidrRanges(original["secondaryIpCidrRanges"], d, config), - }) - } - return transformed -} -func flattenComputeNetworkAttachmentConnectionEndpointsStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentConnectionEndpointsProjectIdOrNum(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentConnectionEndpointsSubnetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentConnectionEndpointsIpAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentConnectionEndpointsSecondaryIpCidrRanges(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentSubnetworks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertAndMapStringArr(v.([]interface{}), tpgresource.ConvertSelfLinkToV1) -} - -func flattenComputeNetworkAttachmentProducerRejectLists(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentProducerAcceptLists(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentFingerprint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeNetworkAttachmentRegion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - -func expandComputeNetworkAttachmentDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeNetworkAttachmentConnectionPreference(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeNetworkAttachmentSubnetworks(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - return nil, fmt.Errorf("Invalid value for subnetworks: nil") - } - f, err := tpgresource.ParseRegionalFieldValue("subnetworks", raw.(string), "project", "region", "zone", d, config, true) - if err != nil { - return nil, fmt.Errorf("Invalid value for subnetworks: %s", err) - } - req = append(req, f.RelativeLink()) - } - return req, nil -} - -func expandComputeNetworkAttachmentProducerRejectLists(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeNetworkAttachmentProducerAcceptLists(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeNetworkAttachmentFingerprint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeNetworkAttachmentName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeNetworkAttachmentRegion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - f, err := tpgresource.ParseGlobalFieldValue("regions", v.(string), "project", d, config, true) - if err != nil { - return nil, fmt.Errorf("Invalid value for region: %s", err) - } - return f.RelativeLink(), nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_attachment_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_attachment_sweeper.go deleted file mode 100644 index ef9b0d56e4e..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_attachment_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("ComputeNetworkAttachment", testSweepComputeNetworkAttachment) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepComputeNetworkAttachment(region string) error { - resourceName := "ComputeNetworkAttachment" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/networkAttachments", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["items"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_edge_security_service_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_edge_security_service_sweeper.go deleted file mode 100644 index 8db869f0659..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_edge_security_service_sweeper.go +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package compute diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint.go index 31565deab88..728d50b7779 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -161,7 +160,6 @@ func resourceComputeNetworkEndpointCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -170,7 +168,6 @@ func resourceComputeNetworkEndpointCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkEndpoint: %s", err) @@ -223,14 +220,12 @@ func resourceComputeNetworkEndpointRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetworkEndpoint %q", d.Id())) @@ -319,7 +314,6 @@ func resourceComputeNetworkEndpointDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) toDelete := make(map[string]interface{}) instanceProp, err := expandNestedComputeNetworkEndpointInstance(d.Get("instance"), d, config) if err != nil { @@ -356,7 +350,6 @@ func resourceComputeNetworkEndpointDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NetworkEndpoint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint_group.go index 2edfc3f53d3..634575067bb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoint_group.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -32,16 +31,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/verify" ) -// Use this method when subnet is optioanl and auto_create_subnetworks = true -// API sometimes choose a subnet so the diff needs to be ignored -func compareOptionalSubnet(_, old, new string, _ *schema.ResourceData) bool { - if tpgresource.IsEmptyValue(reflect.ValueOf(new)) { - return true - } - // otherwise compare as self links - return tpgresource.CompareSelfLinkOrResourceName("", old, new, nil) -} - func ResourceComputeNetworkEndpointGroup() *schema.Resource { return &schema.Resource{ Create: resourceComputeNetworkEndpointGroupCreate, @@ -118,7 +107,7 @@ Possible values include: GCE_VM_IP, GCE_VM_IP_PORT, NON_GCP_PRIVATE_IP_PORT, INT Type: schema.TypeString, Optional: true, ForceNew: true, - DiffSuppressFunc: compareOptionalSubnet, + DiffSuppressFunc: tpgresource.CompareOptionalSubnet, Description: `Optional subnetwork to which all network endpoints in the NEG belong.`, }, "zone": { @@ -219,7 +208,6 @@ func resourceComputeNetworkEndpointGroupCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -228,7 +216,6 @@ func resourceComputeNetworkEndpointGroupCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkEndpointGroup: %s", err) @@ -281,14 +268,12 @@ func resourceComputeNetworkEndpointGroupRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetworkEndpointGroup %q", d.Id())) @@ -361,8 +346,6 @@ func resourceComputeNetworkEndpointGroupDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NetworkEndpointGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -372,7 +355,6 @@ func resourceComputeNetworkEndpointGroupDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NetworkEndpointGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoints.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoints.go index fccc29756b5..72f43b4f928 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoints.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_endpoints.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -262,7 +261,6 @@ func resourceComputeNetworkEndpointsCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) chunkSize := 500 // API only accepts 500 endpoints at a time lastPage, err := networkEndpointsPaginatedMutate(d, obj["networkEndpoints"].([]interface{}), config, userAgent, url, project, billingProject, chunkSize, true) if err != nil { @@ -278,7 +276,6 @@ func resourceComputeNetworkEndpointsCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkEndpoints: %s", err) @@ -331,14 +328,12 @@ func resourceComputeNetworkEndpointsRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetworkEndpoints %q", d.Id())) @@ -416,7 +411,6 @@ func resourceComputeNetworkEndpointsUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating NetworkEndpoints %q: %#v", d.Id(), obj) - headers := make(http.Header) detachUrl, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{network_endpoint_group}}/detachNetworkEndpoints") o, n := d.GetChange("network_endpoints") @@ -492,7 +486,6 @@ func resourceComputeNetworkEndpointsUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -546,7 +539,6 @@ func resourceComputeNetworkEndpointsDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) var endpointsToDelete []interface{} endpoints := d.Get("network_endpoints").(*schema.Set).List() @@ -598,7 +590,6 @@ func resourceComputeNetworkEndpointsDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NetworkEndpoints") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy.go index 377107069ad..229eca47c1c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -152,7 +151,6 @@ func resourceComputeNetworkFirewallPolicyCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -161,7 +159,6 @@ func resourceComputeNetworkFirewallPolicyCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkFirewallPolicy: %s", err) @@ -214,14 +211,12 @@ func resourceComputeNetworkFirewallPolicyRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetworkFirewallPolicy %q", d.Id())) @@ -294,7 +289,6 @@ func resourceComputeNetworkFirewallPolicyUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating NetworkFirewallPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -309,7 +303,6 @@ func resourceComputeNetworkFirewallPolicyUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -356,8 +349,6 @@ func resourceComputeNetworkFirewallPolicyDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NetworkFirewallPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -367,7 +358,6 @@ func resourceComputeNetworkFirewallPolicyDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NetworkFirewallPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy_rule.go index 37072e4c0cb..da22f393841 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_firewall_policy_rule.go @@ -60,7 +60,7 @@ func ResourceComputeNetworkFirewallPolicyRule() *schema.Resource { "action": { Type: schema.TypeString, Required: true, - Description: "The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\", \"goto_next\" and \"apply_security_profile_group\".", + Description: "The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\" and \"goto_next\".", }, "direction": { @@ -125,12 +125,6 @@ func ResourceComputeNetworkFirewallPolicyRule() *schema.Resource { Description: "An optional name for the rule. This field is not a unique identifier and can be updated.", }, - "security_profile_group": { - Type: schema.TypeString, - Optional: true, - Description: "A fully-qualified URL of a SecurityProfileGroup resource. Example: https://networksecurity.googleapis.com/v1/organizations/{organizationId}/locations/global/securityProfileGroups/my-security-profile-group. It must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.", - }, - "target_secure_tags": { Type: schema.TypeList, Optional: true, @@ -145,12 +139,6 @@ func ResourceComputeNetworkFirewallPolicyRule() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "tls_inspect": { - Type: schema.TypeBool, - Optional: true, - Description: "Boolean flag indicating if the traffic should be TLS decrypted. It can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.", - }, - "kind": { Type: schema.TypeString, Computed: true, @@ -331,10 +319,8 @@ func resourceComputeNetworkFirewallPolicyRuleCreate(d *schema.ResourceData, meta EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), Project: dcl.String(project), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } id, err := obj.ID() @@ -392,10 +378,8 @@ func resourceComputeNetworkFirewallPolicyRuleRead(d *schema.ResourceData, meta i EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), Project: dcl.String(project), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -450,18 +434,12 @@ func resourceComputeNetworkFirewallPolicyRuleRead(d *schema.ResourceData, meta i if err = d.Set("rule_name", res.RuleName); err != nil { return fmt.Errorf("error setting rule_name in state: %s", err) } - if err = d.Set("security_profile_group", res.SecurityProfileGroup); err != nil { - return fmt.Errorf("error setting security_profile_group in state: %s", err) - } if err = d.Set("target_secure_tags", flattenComputeNetworkFirewallPolicyRuleTargetSecureTagsArray(res.TargetSecureTags)); err != nil { return fmt.Errorf("error setting target_secure_tags in state: %s", err) } if err = d.Set("target_service_accounts", res.TargetServiceAccounts); err != nil { return fmt.Errorf("error setting target_service_accounts in state: %s", err) } - if err = d.Set("tls_inspect", res.TlsInspect); err != nil { - return fmt.Errorf("error setting tls_inspect in state: %s", err) - } if err = d.Set("kind", res.Kind); err != nil { return fmt.Errorf("error setting kind in state: %s", err) } @@ -489,10 +467,8 @@ func resourceComputeNetworkFirewallPolicyRuleUpdate(d *schema.ResourceData, meta EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), Project: dcl.String(project), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } directive := tpgdclresource.UpdateDirective userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -545,10 +521,8 @@ func resourceComputeNetworkFirewallPolicyRuleDelete(d *schema.ResourceData, meta EnableLogging: dcl.Bool(d.Get("enable_logging").(bool)), Project: dcl.String(project), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } log.Printf("[DEBUG] Deleting NetworkFirewallPolicyRule %q", d.Id()) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_peering_routes_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_peering_routes_config.go index dde73f11551..6715285321d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_peering_routes_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_network_peering_routes_config.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -143,7 +142,6 @@ func resourceComputeNetworkPeeringRoutesConfigCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -152,7 +150,6 @@ func resourceComputeNetworkPeeringRoutesConfigCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkPeeringRoutesConfig: %s", err) @@ -205,14 +202,12 @@ func resourceComputeNetworkPeeringRoutesConfigRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNetworkPeeringRoutesConfig %q", d.Id())) @@ -300,7 +295,6 @@ func resourceComputeNetworkPeeringRoutesConfigUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating NetworkPeeringRoutesConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -315,7 +309,6 @@ func resourceComputeNetworkPeeringRoutesConfigUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_group.go index b03c25e4817..f96d058b3ec 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_group.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -282,7 +281,6 @@ func resourceComputeNodeGroupCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) var sizeParam string if v, ok := d.GetOkExists("initial_size"); ok { sizeParam = fmt.Sprintf("%v", v) @@ -303,7 +301,6 @@ func resourceComputeNodeGroupCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NodeGroup: %s", err) @@ -356,14 +353,12 @@ func resourceComputeNodeGroupRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNodeGroup %q", d.Id())) @@ -475,7 +470,6 @@ func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating NodeGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -527,7 +521,6 @@ func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -561,8 +554,6 @@ func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) er return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -576,7 +567,6 @@ func resourceComputeNodeGroupUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating NodeGroup %q: %s", d.Id(), err) @@ -624,8 +614,6 @@ func resourceComputeNodeGroupDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NodeGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -635,7 +623,6 @@ func resourceComputeNodeGroupDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NodeGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_template.go index 78d57096afe..f11a0149e29 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_node_template.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -258,7 +257,6 @@ func resourceComputeNodeTemplateCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -267,7 +265,6 @@ func resourceComputeNodeTemplateCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NodeTemplate: %s", err) @@ -320,14 +317,12 @@ func resourceComputeNodeTemplateRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeNodeTemplate %q", d.Id())) @@ -398,8 +393,6 @@ func resourceComputeNodeTemplateDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NodeTemplate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -409,7 +402,6 @@ func resourceComputeNodeTemplateDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NodeTemplate") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_packet_mirroring.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_packet_mirroring.go index 9d26d0f1478..e57e8ea3b4b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_packet_mirroring.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_packet_mirroring.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -292,7 +291,6 @@ func resourceComputePacketMirroringCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -301,7 +299,6 @@ func resourceComputePacketMirroringCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PacketMirroring: %s", err) @@ -354,14 +351,12 @@ func resourceComputePacketMirroringRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputePacketMirroring %q", d.Id())) @@ -458,7 +453,6 @@ func resourceComputePacketMirroringUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating PacketMirroring %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -473,7 +467,6 @@ func resourceComputePacketMirroringUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -520,8 +513,6 @@ func resourceComputePacketMirroringDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PacketMirroring %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -531,7 +522,6 @@ func resourceComputePacketMirroringDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PacketMirroring") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_per_instance_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_per_instance_config.go index 8b07f0105a2..6980eadf74e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_per_instance_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_per_instance_config.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -307,7 +306,6 @@ func resourceComputePerInstanceConfigCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -316,7 +314,6 @@ func resourceComputePerInstanceConfigCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PerInstanceConfig: %s", err) @@ -369,14 +366,12 @@ func resourceComputePerInstanceConfigRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputePerInstanceConfig %q", d.Id())) @@ -484,7 +479,6 @@ func resourceComputePerInstanceConfigUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating PerInstanceConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -499,7 +493,6 @@ func resourceComputePerInstanceConfigUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_project_cloud_armor_tier.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_project_cloud_armor_tier.go deleted file mode 100644 index 694284e394f..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_project_cloud_armor_tier.go +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceComputeProjectCloudArmorTier() *schema.Resource { - return &schema.Resource{ - Create: resourceComputeProjectCloudArmorTierCreate, - Read: resourceComputeProjectCloudArmorTierRead, - Update: resourceComputeProjectCloudArmorTierUpdate, - Delete: resourceComputeProjectCloudArmorTierDelete, - - Importer: &schema.ResourceImporter{ - State: resourceComputeProjectCloudArmorTierImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "cloud_armor_tier": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"CA_STANDARD", "CA_ENTERPRISE_PAYGO"}), - Description: `Managed protection tier to be set. Possible values: ["CA_STANDARD", "CA_ENTERPRISE_PAYGO"]`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceComputeProjectCloudArmorTierCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - cloudArmorTierProp, err := expandComputeProjectCloudArmorTierCloudArmorTier(d.Get("cloud_armor_tier"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("cloud_armor_tier"); !tpgresource.IsEmptyValue(reflect.ValueOf(cloudArmorTierProp)) && (ok || !reflect.DeepEqual(v, cloudArmorTierProp)) { - obj["cloudArmorTier"] = cloudArmorTierProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/setCloudArmorTier") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new ProjectCloudArmorTier: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectCloudArmorTier: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ProjectCloudArmorTier: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = ComputeOperationWaitTime( - config, res, project, "Creating ProjectCloudArmorTier", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create ProjectCloudArmorTier: %s", err) - } - - log.Printf("[DEBUG] Finished creating ProjectCloudArmorTier %q: %#v", d.Id(), res) - - return resourceComputeProjectCloudArmorTierRead(d, meta) -} - -func resourceComputeProjectCloudArmorTierRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/{{name}}?fields=cloudArmorTier") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectCloudArmorTier: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeProjectCloudArmorTier %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading ProjectCloudArmorTier: %s", err) - } - - if err := d.Set("cloud_armor_tier", flattenComputeProjectCloudArmorTierCloudArmorTier(res["cloudArmorTier"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectCloudArmorTier: %s", err) - } - - return nil -} - -func resourceComputeProjectCloudArmorTierUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectCloudArmorTier: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - cloudArmorTierProp, err := expandComputeProjectCloudArmorTierCloudArmorTier(d.Get("cloud_armor_tier"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("cloud_armor_tier"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, cloudArmorTierProp)) { - obj["cloudArmorTier"] = cloudArmorTierProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/setCloudArmorTier") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating ProjectCloudArmorTier %q: %#v", d.Id(), obj) - headers := make(http.Header) - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating ProjectCloudArmorTier %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating ProjectCloudArmorTier %q: %#v", d.Id(), res) - } - - err = ComputeOperationWaitTime( - config, res, project, "Updating ProjectCloudArmorTier", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - - return resourceComputeProjectCloudArmorTierRead(d, meta) -} - -func resourceComputeProjectCloudArmorTierDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - log.Printf("[WARNING] Resource [%s] will be only removed from Terraform state, but will be left intact on GCP. %s", d.Id(), userAgent) - - return schema.RemoveFromState(d, meta) -} - -func resourceComputeProjectCloudArmorTierImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenComputeProjectCloudArmorTierCloudArmorTier(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandComputeProjectCloudArmorTierCloudArmorTier(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_advertised_prefix.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_advertised_prefix.go index 99c981cdaa3..4d5bdf50691 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_advertised_prefix.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_advertised_prefix.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -147,7 +146,6 @@ func resourceComputePublicAdvertisedPrefixCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -156,7 +154,6 @@ func resourceComputePublicAdvertisedPrefixCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PublicAdvertisedPrefix: %s", err) @@ -209,14 +206,12 @@ func resourceComputePublicAdvertisedPrefixRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputePublicAdvertisedPrefix %q", d.Id())) @@ -272,8 +267,6 @@ func resourceComputePublicAdvertisedPrefixDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PublicAdvertisedPrefix %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -283,7 +276,6 @@ func resourceComputePublicAdvertisedPrefixDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PublicAdvertisedPrefix") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_delegated_prefix.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_delegated_prefix.go index 2308e4c5e87..43dc630945d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_delegated_prefix.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_public_delegated_prefix.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -166,7 +165,6 @@ func resourceComputePublicDelegatedPrefixCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -175,7 +173,6 @@ func resourceComputePublicDelegatedPrefixCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PublicDelegatedPrefix: %s", err) @@ -228,14 +225,12 @@ func resourceComputePublicDelegatedPrefixRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputePublicDelegatedPrefix %q", d.Id())) @@ -294,8 +289,6 @@ func resourceComputePublicDelegatedPrefixDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PublicDelegatedPrefix %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -305,7 +298,6 @@ func resourceComputePublicDelegatedPrefixDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PublicDelegatedPrefix") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_autoscaler.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_autoscaler.go index 49b5a136e78..7493ad534e7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_autoscaler.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_autoscaler.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -453,7 +452,6 @@ func resourceComputeRegionAutoscalerCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -462,7 +460,6 @@ func resourceComputeRegionAutoscalerCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionAutoscaler: %s", err) @@ -515,14 +512,12 @@ func resourceComputeRegionAutoscalerRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionAutoscaler %q", d.Id())) @@ -615,7 +610,6 @@ func resourceComputeRegionAutoscalerUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating RegionAutoscaler %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -630,7 +624,6 @@ func resourceComputeRegionAutoscalerUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -677,8 +670,6 @@ func resourceComputeRegionAutoscalerDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionAutoscaler %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -688,7 +679,6 @@ func resourceComputeRegionAutoscalerDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionAutoscaler") @@ -1091,7 +1081,7 @@ func expandComputeRegionAutoscalerAutoscalingPolicy(v interface{}, d tpgresource transformedMaxReplicas, err := expandComputeRegionAutoscalerAutoscalingPolicyMaxReplicas(original["max_replicas"], d, config) if err != nil { return nil, err - } else { + } else if val := reflect.ValueOf(transformedMaxReplicas); val.IsValid() && !tpgresource.IsEmptyValue(val) { transformed["maxNumReplicas"] = transformedMaxReplicas } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_backend_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_backend_service.go index 07dac285864..8ea256754e8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_backend_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_backend_service.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -391,9 +390,7 @@ Defaults to 3.`, Type: schema.TypeInt, Optional: true, Description: `Time for which instance will be drained (not accept new -connections, but still work to finish started). - -From version 6.0.0 ConnectionDrainingTimeoutSec default value will be 300 to match default GCP value.`, +connections, but still work to finish started).`, Default: 0, }, @@ -641,6 +638,7 @@ The possible values are: UNAVAILABLE_WEIGHT. Otherwise, Load Balancing remains equal-weight. + This field is applicable to either: * A regional backend service with the service_protocol set to HTTP, HTTPS, or HTTP2, @@ -650,6 +648,7 @@ This field is applicable to either: Load Balancing). Only MAGLEV and WEIGHTED_MAGLEV values are possible for External Network Load Balancing. The default is MAGLEV. + If session_affinity is not NONE, and this field is not set to MAGLEV, WEIGHTED_MAGLEV, or RING_HASH, session affinity settings will not take effect. @@ -698,10 +697,7 @@ This field can only be specified when the load balancing scheme is set to INTERN Optional: true, Description: `Settings controlling eviction of unhealthy hosts from the load balancing pool. This field is applicable only when the 'load_balancing_scheme' is set -to INTERNAL_MANAGED and the 'protocol' is set to HTTP, HTTPS, or HTTP2. - -From version 6.0.0 outlierDetection default terraform values will be removed to match default GCP value. -Default values are enforce by GCP without providing them.`, +to INTERNAL_MANAGED and the 'protocol' is set to HTTP, HTTPS, or HTTP2.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -886,10 +882,8 @@ not applicable if the protocol is UDP. Possible values: ["NONE", "CLIENT_IP", "C Type: schema.TypeInt, Computed: true, Optional: true, - Description: `The backend service timeout has a different meaning depending on the type of load balancer. -For more information see, [Backend service settings](https://cloud.google.com/compute/docs/reference/rest/v1/backendServices). -The default is 30 seconds. -The full range of timeout values allowed goes from 1 through 2,147,483,647 seconds.`, + Description: `How many seconds to wait for the backend before considering it a +failed request. Default is 30 seconds. Valid range is [1, 86400].`, }, "creation_timestamp": { Type: schema.TypeString, @@ -902,11 +896,6 @@ The full range of timeout values allowed goes from 1 through 2,147,483,647 secon Description: `Fingerprint of this resource. A hash of the contents stored in this object. This field is used in optimistic locking.`, }, - "generated_id": { - Type: schema.TypeInt, - Computed: true, - Description: `The unique identifier for the resource. This identifier is defined by the server.`, - }, "project": { Type: schema.TypeString, Optional: true, @@ -957,9 +946,7 @@ partial URL.`, Description: `Specifies the balancing mode for this backend. See the [Backend Services Overview](https://cloud.google.com/load-balancing/docs/backend-service#balancing-mode) -for an explanation of load balancing modes. - -From version 6.0.0 default value will be UTILIZATION to match default GCP value. Default value: "CONNECTION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, +for an explanation of load balancing modes. Default value: "CONNECTION" Possible values: ["UTILIZATION", "RATE", "CONNECTION"]`, Default: "CONNECTION", }, "capacity_scaler": { @@ -1235,7 +1222,6 @@ func resourceComputeRegionBackendServiceCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1244,7 +1230,6 @@ func resourceComputeRegionBackendServiceCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionBackendService: %s", err) @@ -1297,14 +1282,12 @@ func resourceComputeRegionBackendServiceRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionBackendService %q", d.Id())) @@ -1374,9 +1357,6 @@ func resourceComputeRegionBackendServiceRead(d *schema.ResourceData, meta interf if err := d.Set("health_checks", flattenComputeRegionBackendServiceHealthChecks(res["healthChecks"], d, config)); err != nil { return fmt.Errorf("Error reading RegionBackendService: %s", err) } - if err := d.Set("generated_id", flattenComputeRegionBackendServiceGeneratedId(res["id"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionBackendService: %s", err) - } if err := d.Set("iap", flattenComputeRegionBackendServiceIap(res["iap"], d, config)); err != nil { return fmt.Errorf("Error reading RegionBackendService: %s", err) } @@ -1586,7 +1566,6 @@ func resourceComputeRegionBackendServiceUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating RegionBackendService %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -1601,7 +1580,6 @@ func resourceComputeRegionBackendServiceUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1648,8 +1626,6 @@ func resourceComputeRegionBackendServiceDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionBackendService %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1659,7 +1635,6 @@ func resourceComputeRegionBackendServiceDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionBackendService") @@ -2357,23 +2332,6 @@ func flattenComputeRegionBackendServiceHealthChecks(v interface{}, d *schema.Res return tpgresource.ConvertAndMapStringArr(v.([]interface{}), tpgresource.ConvertSelfLinkToV1) } -func flattenComputeRegionBackendServiceGeneratedId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - func flattenComputeRegionBackendServiceIap(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_commitment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_commitment.go index 31a5730b6eb..f7493d3adf6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_commitment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_commitment.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -307,7 +306,6 @@ func resourceComputeRegionCommitmentCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -316,7 +314,6 @@ func resourceComputeRegionCommitmentCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionCommitment: %s", err) @@ -369,14 +366,12 @@ func resourceComputeRegionCommitmentRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionCommitment %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk.go index 49dfb47d167..bd1c5377f0c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk.go @@ -21,7 +21,6 @@ import ( "errors" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -335,7 +334,8 @@ used.`, Description: `Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance`, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, }, }, "project": { @@ -496,7 +496,6 @@ func resourceComputeRegionDiskCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -505,7 +504,6 @@ func resourceComputeRegionDiskCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionDisk: %s", err) @@ -558,14 +556,12 @@ func resourceComputeRegionDiskRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionDisk %q", d.Id())) @@ -704,8 +700,6 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -719,7 +713,6 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating RegionDisk %q: %s", d.Id(), err) @@ -749,8 +742,6 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -764,7 +755,6 @@ func resourceComputeRegionDiskUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating RegionDisk %q: %s", d.Id(), err) @@ -812,7 +802,6 @@ func resourceComputeRegionDiskDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) readRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", @@ -884,7 +873,6 @@ func resourceComputeRegionDiskDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionDisk") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go index d20851d374d..c7abc23a356 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_disk_resource_policy_attachment.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -123,7 +122,6 @@ func resourceComputeRegionDiskResourcePolicyAttachmentCreate(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -132,7 +130,6 @@ func resourceComputeRegionDiskResourcePolicyAttachmentCreate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionDiskResourcePolicyAttachment: %s", err) @@ -185,14 +182,12 @@ func resourceComputeRegionDiskResourcePolicyAttachmentRead(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionDiskResourcePolicyAttachment %q", d.Id())) @@ -260,7 +255,6 @@ func resourceComputeRegionDiskResourcePolicyAttachmentDelete(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) obj = make(map[string]interface{}) region, err := tpgresource.GetRegion(d, config) @@ -287,7 +281,6 @@ func resourceComputeRegionDiskResourcePolicyAttachmentDelete(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionDiskResourcePolicyAttachment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_health_check.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_health_check.go index 9cdb5daaaa1..d7cfc91d5eb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_health_check.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_health_check.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -711,7 +710,6 @@ func resourceComputeRegionHealthCheckCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -720,7 +718,6 @@ func resourceComputeRegionHealthCheckCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionHealthCheck: %s", err) @@ -773,14 +770,12 @@ func resourceComputeRegionHealthCheckRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionHealthCheck %q", d.Id())) @@ -957,7 +952,6 @@ func resourceComputeRegionHealthCheckUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating RegionHealthCheck %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -972,7 +966,6 @@ func resourceComputeRegionHealthCheckUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1019,8 +1012,6 @@ func resourceComputeRegionHealthCheckDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionHealthCheck %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1030,7 +1021,6 @@ func resourceComputeRegionHealthCheckDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionHealthCheck") @@ -2074,6 +2064,7 @@ func expandComputeRegionHealthCheckRegion(v interface{}, d tpgresource.Terraform } func resourceComputeRegionHealthCheckEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + if _, ok := d.GetOk("http_health_check"); ok { hc := d.Get("http_health_check").([]interface{})[0] ps := hc.(map[string]interface{})["port_specification"] diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_group_manager.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_group_manager.go index 65b96dd3362..5ee1d82c8f3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_group_manager.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_group_manager.go @@ -9,7 +9,7 @@ import ( "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -289,8 +289,8 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { "minimal_action": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"NONE", "REFRESH", "RESTART", "REPLACE"}, false), - Description: `Minimal action to be taken on an instance. You can specify either NONE to forbid any actions, REFRESH to update without stopping instances, RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a REFRESH, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`, + ValidateFunc: validation.StringInSlice([]string{"REFRESH", "RESTART", "REPLACE"}, false), + Description: `Minimal action to be taken on an instance. You can specify either REFRESH to update without stopping instances, RESTART to restart existing instances or REPLACE to delete and create new instances from the target template. If you specify a REFRESH, the Updater will attempt to perform that action only. However, if the Updater determines that the minimal action you specify is not enough to perform the update, it might perform a more disruptive action.`, }, "most_disruptive_allowed_action": { @@ -481,11 +481,6 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { Computed: true, Description: `A bit indicating whether this configuration has been applied to all managed instances in the group.`, }, - "current_revision": { - Type: schema.TypeString, - Computed: true, - Description: `Current all-instances configuration revision. This value is in RFC3339 text format.`, - }, }, }, }, @@ -503,7 +498,7 @@ func ResourceComputeRegionInstanceGroupManager() *schema.Resource { "per_instance_configs": { Type: schema.TypeList, Computed: true, - Description: `Status of per-instance configs on the instances.`, + Description: `Status of per-instance configs on the instance.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "all_effective": { @@ -591,7 +586,7 @@ func resourceComputeRegionInstanceGroupManagerCreate(d *schema.ResourceData, met func computeRIGMWaitForInstanceStatus(d *schema.ResourceData, meta interface{}) error { waitForUpdates := d.Get("wait_for_instances_status").(string) == "UPDATED" - conf := retry.StateChangeConf{ + conf := resource.StateChangeConf{ Pending: []string{"creating", "error", "updating per instance configs", "reaching version target", "updating all instances config"}, Target: []string{"created"}, Refresh: waitForInstancesRefreshFunc(getRegionalManager, waitForUpdates, d, meta), @@ -633,7 +628,7 @@ func getRegionalManager(d *schema.ResourceData, meta interface{}) (*compute.Inst return manager, nil } -func waitForInstancesRefreshFunc(f getInstanceManagerFunc, waitForUpdates bool, d *schema.ResourceData, meta interface{}) retry.StateRefreshFunc { +func waitForInstancesRefreshFunc(f getInstanceManagerFunc, waitForUpdates bool, d *schema.ResourceData, meta interface{}) resource.StateRefreshFunc { return func() (interface{}, string, error) { m, err := f(d, meta) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_template.go index 4f30f160949..64dc2da9fd0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_instance_template.go @@ -9,7 +9,7 @@ import ( "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -470,7 +470,7 @@ Google Cloud KMS.`, Type: schema.TypeString, Required: true, ForceNew: true, - DiffSuppressFunc: IpCidrRangeDiffSuppress, + DiffSuppressFunc: tpgresource.IpCidrRangeDiffSuppress, Description: `The IP CIDR range represented by this alias IP range. This IP CIDR range must belong to the specified subnetwork and cannot contain IP addresses reserved by system or used by other network interfaces. At the time of writing only a netmask (e.g. /24) may be supplied, with a CIDR format resulting in an API error.`, }, "subnetwork_range_name": { @@ -651,51 +651,6 @@ Google Cloud KMS.`, AtLeastOneOf: schedulingInstTemplateKeys, Description: `Specifies the action GCE should take when SPOT VM is preempted.`, }, - "max_run_duration": { - Type: schema.TypeList, - Optional: true, - Description: `The timeout for new network connections to hosts.`, - MaxItems: 1, - ForceNew: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "seconds": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: `Span of time at a resolution of a second. -Must be from 0 to 315,576,000,000 inclusive.`, - }, - "nanos": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `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.`, - }, - }, - }, - }, - "on_instance_stop_action": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - ForceNew: true, - Description: `Defines the behaviour for instances with the instance_termination_action.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "discard_local_ssd": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, the contents of any attached Local SSD disks will be discarded.`, - Default: false, - ForceNew: true, - }, - }, - }, - }, "local_ssd_recovery_timeout": { Type: schema.TypeList, Optional: true, @@ -820,22 +775,12 @@ be from 0 to 999,999,999 inclusive.`, Description: `The Confidential VM config being used by the instance. on_host_maintenance has to be set to TERMINATE or this will fail to create.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ + "enable_confidential_compute": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Defines whether the instance should have confidential compute enabled. Field will be deprecated in a future release.`, - AtLeastOneOf: []string{"confidential_instance_config.0.enable_confidential_compute", "confidential_instance_config.0.confidential_instance_type"}, - }, - "confidential_instance_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: ` - Specifies which confidential computing technology to use. - This could be one of the following values: SEV, SEV_SNP. - If SEV_SNP, min_cpu_platform = "AMD Milan" is currently required.`, - AtLeastOneOf: []string{"confidential_instance_config.0.enable_confidential_compute", "confidential_instance_config.0.confidential_instance_type"}, + Type: schema.TypeBool, + Required: true, + ForceNew: true, + Description: `Defines whether the instance should have confidential compute enabled.`, }, }, }, @@ -1085,9 +1030,9 @@ func resourceComputeRegionInstanceTemplateCreate(d *schema.ResourceData, meta in if v, ok := d.GetOk("name"); ok { itName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - itName = id.PrefixedUniqueId(v.(string)) + itName = resource.PrefixedUniqueId(v.(string)) } else { - itName = id.UniqueId() + itName = resource.UniqueId() } instanceTemplate := make(map[string]interface{}) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint.go index 7b6a6b4a52d..6982b44cfdf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -161,7 +160,6 @@ func resourceComputeRegionNetworkEndpointCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -170,7 +168,6 @@ func resourceComputeRegionNetworkEndpointCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionNetworkEndpoint: %s", err) @@ -223,14 +220,12 @@ func resourceComputeRegionNetworkEndpointRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionNetworkEndpoint %q", d.Id())) @@ -319,7 +314,6 @@ func resourceComputeRegionNetworkEndpointDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) toDelete := make(map[string]interface{}) // Port @@ -362,7 +356,6 @@ func resourceComputeRegionNetworkEndpointDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionNetworkEndpoint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint_group.go index 6e4ba4a372d..cf2c96ea118 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_endpoint_group.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -218,8 +217,8 @@ The URL of the network to which all network endpoints in the NEG belong. Uses Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"SERVERLESS", "PRIVATE_SERVICE_CONNECT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT", "GCE_VM_IP_PORTMAP", ""}), - Description: `Type of network endpoints in this network endpoint group. Defaults to SERVERLESS. Default value: "SERVERLESS" Possible values: ["SERVERLESS", "PRIVATE_SERVICE_CONNECT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT", "GCE_VM_IP_PORTMAP"]`, + ValidateFunc: verify.ValidateEnum([]string{"SERVERLESS", "PRIVATE_SERVICE_CONNECT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT", ""}), + Description: `Type of network endpoints in this network endpoint group. Defaults to SERVERLESS. Default value: "SERVERLESS" Possible values: ["SERVERLESS", "PRIVATE_SERVICE_CONNECT", "INTERNET_IP_PORT", "INTERNET_FQDN_PORT"]`, Default: "SERVERLESS", }, "psc_target_service": { @@ -343,7 +342,6 @@ func resourceComputeRegionNetworkEndpointGroupCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -352,7 +350,6 @@ func resourceComputeRegionNetworkEndpointGroupCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionNetworkEndpointGroup: %s", err) @@ -405,14 +402,12 @@ func resourceComputeRegionNetworkEndpointGroupRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionNetworkEndpointGroup %q", d.Id())) @@ -486,8 +481,6 @@ func resourceComputeRegionNetworkEndpointGroupDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionNetworkEndpointGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -497,7 +490,6 @@ func resourceComputeRegionNetworkEndpointGroupDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionNetworkEndpointGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy.go index 403acc552f9..cd786dbcc53 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -159,7 +158,6 @@ func resourceComputeRegionNetworkFirewallPolicyCreate(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -168,7 +166,6 @@ func resourceComputeRegionNetworkFirewallPolicyCreate(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionNetworkFirewallPolicy: %s", err) @@ -221,14 +218,12 @@ func resourceComputeRegionNetworkFirewallPolicyRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionNetworkFirewallPolicy %q", d.Id())) @@ -301,7 +296,6 @@ func resourceComputeRegionNetworkFirewallPolicyUpdate(d *schema.ResourceData, me } log.Printf("[DEBUG] Updating RegionNetworkFirewallPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -316,7 +310,6 @@ func resourceComputeRegionNetworkFirewallPolicyUpdate(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -363,8 +356,6 @@ func resourceComputeRegionNetworkFirewallPolicyDelete(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionNetworkFirewallPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -374,7 +365,6 @@ func resourceComputeRegionNetworkFirewallPolicyDelete(d *schema.ResourceData, me UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionNetworkFirewallPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy_rule.go index 5d2c5537896..37f769e9abc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_network_firewall_policy_rule.go @@ -60,7 +60,7 @@ func ResourceComputeRegionNetworkFirewallPolicyRule() *schema.Resource { "action": { Type: schema.TypeString, Required: true, - Description: "The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\", \"goto_next\" and \"apply_security_profile_group\".", + Description: "The Action to perform when the client connection triggers the rule. Valid actions are \"allow\", \"deny\" and \"goto_next\".", }, "direction": { @@ -133,12 +133,6 @@ func ResourceComputeRegionNetworkFirewallPolicyRule() *schema.Resource { Description: "An optional name for the rule. This field is not a unique identifier and can be updated.", }, - "security_profile_group": { - Type: schema.TypeString, - Optional: true, - Description: "A fully-qualified URL of a SecurityProfileGroup resource. Example: https://networksecurity.googleapis.com/v1/organizations/{organizationId}/locations/global/securityProfileGroups/my-security-profile-group. It must be specified if action = 'apply_security_profile_group' and cannot be specified for other actions.", - }, - "target_secure_tags": { Type: schema.TypeList, Optional: true, @@ -153,12 +147,6 @@ func ResourceComputeRegionNetworkFirewallPolicyRule() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "tls_inspect": { - Type: schema.TypeBool, - Optional: true, - Description: "Boolean flag indicating if the traffic should be TLS decrypted. It can be set only if action = 'apply_security_profile_group' and cannot be set for other actions.", - }, - "kind": { Type: schema.TypeString, Computed: true, @@ -344,10 +332,8 @@ func resourceComputeRegionNetworkFirewallPolicyRuleCreate(d *schema.ResourceData Project: dcl.String(project), Location: dcl.String(region), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeRegionNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } id, err := tpgresource.ReplaceVarsForId(d, config, "projects/{{project}}/regions/{{region}}/firewallPolicies/{{firewall_policy}}/{{priority}}") @@ -410,10 +396,8 @@ func resourceComputeRegionNetworkFirewallPolicyRuleRead(d *schema.ResourceData, Project: dcl.String(project), Location: dcl.String(region), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeRegionNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -471,18 +455,12 @@ func resourceComputeRegionNetworkFirewallPolicyRuleRead(d *schema.ResourceData, if err = d.Set("rule_name", res.RuleName); err != nil { return fmt.Errorf("error setting rule_name in state: %s", err) } - if err = d.Set("security_profile_group", res.SecurityProfileGroup); err != nil { - return fmt.Errorf("error setting security_profile_group in state: %s", err) - } if err = d.Set("target_secure_tags", flattenComputeRegionNetworkFirewallPolicyRuleTargetSecureTagsArray(res.TargetSecureTags)); err != nil { return fmt.Errorf("error setting target_secure_tags in state: %s", err) } if err = d.Set("target_service_accounts", res.TargetServiceAccounts); err != nil { return fmt.Errorf("error setting target_service_accounts in state: %s", err) } - if err = d.Set("tls_inspect", res.TlsInspect); err != nil { - return fmt.Errorf("error setting tls_inspect in state: %s", err) - } if err = d.Set("kind", res.Kind); err != nil { return fmt.Errorf("error setting kind in state: %s", err) } @@ -515,10 +493,8 @@ func resourceComputeRegionNetworkFirewallPolicyRuleUpdate(d *schema.ResourceData Project: dcl.String(project), Location: dcl.String(region), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeRegionNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } directive := tpgdclresource.UpdateDirective userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) @@ -576,10 +552,8 @@ func resourceComputeRegionNetworkFirewallPolicyRuleDelete(d *schema.ResourceData Project: dcl.String(project), Location: dcl.String(region), RuleName: dcl.String(d.Get("rule_name").(string)), - SecurityProfileGroup: dcl.String(d.Get("security_profile_group").(string)), TargetSecureTags: expandComputeRegionNetworkFirewallPolicyRuleTargetSecureTagsArray(d.Get("target_secure_tags")), TargetServiceAccounts: tpgdclresource.ExpandStringArray(d.Get("target_service_accounts")), - TlsInspect: dcl.Bool(d.Get("tls_inspect").(bool)), } log.Printf("[DEBUG] Deleting NetworkFirewallPolicyRule %q", d.Id()) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_per_instance_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_per_instance_config.go index 5cd4e3025b9..7ef384b61ed 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_per_instance_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_per_instance_config.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -307,7 +306,6 @@ func resourceComputeRegionPerInstanceConfigCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -316,7 +314,6 @@ func resourceComputeRegionPerInstanceConfigCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionPerInstanceConfig: %s", err) @@ -369,14 +366,12 @@ func resourceComputeRegionPerInstanceConfigRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionPerInstanceConfig %q", d.Id())) @@ -484,7 +479,6 @@ func resourceComputeRegionPerInstanceConfigUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating RegionPerInstanceConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -499,7 +493,6 @@ func resourceComputeRegionPerInstanceConfigUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_certificate.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_certificate.go index e1cb4b9223b..4433e719e05 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_certificate.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_certificate.go @@ -18,16 +18,13 @@ package compute import ( - "crypto/sha256" - "encoding/hex" "fmt" "log" - "net/http" "reflect" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -35,12 +32,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/verify" ) -// sha256DiffSuppress -// if old is the hex-encoded sha256 sum of new, treat them as equal -func sha256DiffSuppress(_, old, new string, _ *schema.ResourceData) bool { - return hex.EncodeToString(sha256.New().Sum([]byte(old))) == new -} - func ResourceComputeRegionSslCertificate() *schema.Resource { return &schema.Resource{ Create: resourceComputeRegionSslCertificateCreate, @@ -74,7 +65,7 @@ The chain must include at least one intermediate cert.`, Type: schema.TypeString, Required: true, ForceNew: true, - DiffSuppressFunc: sha256DiffSuppress, + DiffSuppressFunc: tpgresource.Sha256DiffSuppress, Description: `The write-only private key in PEM format.`, Sensitive: true, }, @@ -98,6 +89,7 @@ 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. + These are in the same namespace as the managed SSL certificates.`, }, "region": { @@ -215,7 +207,6 @@ func resourceComputeRegionSslCertificateCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -224,7 +215,6 @@ func resourceComputeRegionSslCertificateCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionSslCertificate: %s", err) @@ -277,14 +267,12 @@ func resourceComputeRegionSslCertificateRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionSslCertificate %q", d.Id())) @@ -349,8 +337,6 @@ func resourceComputeRegionSslCertificateDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionSslCertificate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -360,7 +346,6 @@ func resourceComputeRegionSslCertificateDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionSslCertificate") @@ -456,9 +441,9 @@ func expandComputeRegionSslCertificateName(v interface{}, d tpgresource.Terrafor if v, ok := d.GetOk("name"); ok { certName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - certName = id.PrefixedUniqueId(v.(string)) + certName = resource.PrefixedUniqueId(v.(string)) } else { - certName = id.UniqueId() + certName = resource.UniqueId() } // We need to get the {{name}} into schema to set the ID using tpgresource.ReplaceVars diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_policy.go index 14b7a79d4f4..f8b087f8d92 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_ssl_policy.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -85,6 +84,13 @@ 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.`, }, + "region": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + Description: `The region where the regional SSL policy resides.`, + }, "custom_features": { Type: schema.TypeSet, Optional: true, @@ -129,14 +135,6 @@ for information on what cipher suites each profile provides. If 'CUSTOM' is used, the 'custom_features' attribute **must be set**. Default value: "COMPATIBLE" Possible values: ["COMPATIBLE", "MODERN", "RESTRICTED", "CUSTOM"]`, Default: "COMPATIBLE", }, - "region": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The region where the regional SSL policy resides.`, - }, "creation_timestamp": { Type: schema.TypeString, Computed: true, @@ -242,7 +240,6 @@ func resourceComputeRegionSslPolicyCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -251,7 +248,6 @@ func resourceComputeRegionSslPolicyCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionSslPolicy: %s", err) @@ -304,14 +300,12 @@ func resourceComputeRegionSslPolicyRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionSslPolicy %q", d.Id())) @@ -402,7 +396,6 @@ func resourceComputeRegionSslPolicyUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating RegionSslPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -417,7 +410,6 @@ func resourceComputeRegionSslPolicyUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -464,8 +456,6 @@ func resourceComputeRegionSslPolicyDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionSslPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -475,7 +465,6 @@ func resourceComputeRegionSslPolicyDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionSslPolicy") @@ -556,7 +545,7 @@ func flattenComputeRegionSslPolicyRegion(v interface{}, d *schema.ResourceData, if v == nil { return v } - return tpgresource.NameFromSelfLinkStateFunc(v) + return tpgresource.ConvertSelfLinkToV1(v.(string)) } func expandComputeRegionSslPolicyDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_http_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_http_proxy.go index c81b7fcb46e..bcfefde9e51 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_http_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_http_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -164,7 +163,6 @@ func resourceComputeRegionTargetHttpProxyCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -173,7 +171,6 @@ func resourceComputeRegionTargetHttpProxyCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionTargetHttpProxy: %s", err) @@ -226,14 +223,12 @@ func resourceComputeRegionTargetHttpProxyRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionTargetHttpProxy %q", d.Id())) @@ -300,8 +295,6 @@ func resourceComputeRegionTargetHttpProxyUpdate(d *schema.ResourceData, meta int return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -315,7 +308,6 @@ func resourceComputeRegionTargetHttpProxyUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating RegionTargetHttpProxy %q: %s", d.Id(), err) @@ -363,8 +355,6 @@ func resourceComputeRegionTargetHttpProxyDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionTargetHttpProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -374,7 +364,6 @@ func resourceComputeRegionTargetHttpProxyDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionTargetHttpProxy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_https_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_https_proxy.go index bef239d00c6..b417ae9a053 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_https_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_https_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -79,7 +78,8 @@ to the RegionBackendService.`, Optional: true, DiffSuppressFunc: tpgresource.CompareResourceNames, Description: `URLs to certificate manager certificate resources that are used to authenticate connections between users and the load balancer. -sslCertificates and certificateManagerCertificates can't be defined together. +Currently, you may specify up to 15 certificates. Certificate manager certificates do not apply when the load balancing scheme is set to INTERNAL_SELF_MANAGED. +sslCertificates and certificateManagerCertificates fields can not be defined together. Accepted format is '//certificatemanager.googleapis.com/projects/{project}/locations/{location}/certificates/{resourceName}' or just the self_link 'projects/{project}/locations/{location}/certificates/{resourceName}'`, Elem: &schema.Schema{ Type: schema.TypeString, @@ -100,21 +100,6 @@ Accepted format is '//certificatemanager.googleapis.com/projects/{project}/locat DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `The Region in which the created target https proxy should reside. If it is not provided, the provider region is used.`, - }, - "server_tls_policy": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `A URL referring to a networksecurity.ServerTlsPolicy -resource that describes how the proxy should authenticate inbound -traffic. serverTlsPolicy only applies to a global TargetHttpsProxy -attached to globalForwardingRules with the loadBalancingScheme -set to INTERNAL_SELF_MANAGED or EXTERNAL or EXTERNAL_MANAGED. -For details which ServerTlsPolicy resources are accepted with -INTERNAL_SELF_MANAGED and which with EXTERNAL, EXTERNAL_MANAGED -loadBalancingScheme consult ServerTlsPolicy documentation. -If left blank, communications are not encrypted.`, }, "ssl_certificates": { Type: schema.TypeList, @@ -131,6 +116,7 @@ sslCertificates do not apply when the load balancing scheme is set to INTERNAL_S "ssl_policy": { Type: schema.TypeString, Optional: true, + ForceNew: true, DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `A reference to the Region SslPolicy resource that will be associated with the TargetHttpsProxy resource. If not set, the TargetHttpsProxy @@ -205,12 +191,6 @@ func resourceComputeRegionTargetHttpsProxyCreate(d *schema.ResourceData, meta in } else if v, ok := d.GetOkExists("url_map"); !tpgresource.IsEmptyValue(reflect.ValueOf(urlMapProp)) && (ok || !reflect.DeepEqual(v, urlMapProp)) { obj["urlMap"] = urlMapProp } - serverTlsPolicyProp, err := expandComputeRegionTargetHttpsProxyServerTlsPolicy(d.Get("server_tls_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("server_tls_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(serverTlsPolicyProp)) && (ok || !reflect.DeepEqual(v, serverTlsPolicyProp)) { - obj["serverTlsPolicy"] = serverTlsPolicyProp - } regionProp, err := expandComputeRegionTargetHttpsProxyRegion(d.Get("region"), d, config) if err != nil { return err @@ -242,7 +222,6 @@ func resourceComputeRegionTargetHttpsProxyCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -251,7 +230,6 @@ func resourceComputeRegionTargetHttpsProxyCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionTargetHttpsProxy: %s", err) @@ -304,14 +282,12 @@ func resourceComputeRegionTargetHttpsProxyRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionTargetHttpsProxy %q", d.Id())) @@ -357,9 +333,6 @@ func resourceComputeRegionTargetHttpsProxyRead(d *schema.ResourceData, meta inte if err := d.Set("url_map", flattenComputeRegionTargetHttpsProxyUrlMap(res["urlMap"], d, config)); err != nil { return fmt.Errorf("Error reading RegionTargetHttpsProxy: %s", err) } - if err := d.Set("server_tls_policy", flattenComputeRegionTargetHttpsProxyServerTlsPolicy(res["serverTlsPolicy"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionTargetHttpsProxy: %s", err) - } if err := d.Set("region", flattenComputeRegionTargetHttpsProxyRegion(res["region"], d, config)); err != nil { return fmt.Errorf("Error reading RegionTargetHttpsProxy: %s", err) } @@ -403,18 +376,11 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in obj["sslCertificates"] = sslCertificatesProp } - obj, err = resourceComputeRegionTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/targetHttpsProxies/{{name}}/setSslCertificates") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -428,7 +394,6 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating RegionTargetHttpsProxy %q: %s", d.Id(), err) @@ -453,18 +418,11 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in obj["urlMap"] = urlMapProp } - obj, err = resourceComputeRegionTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/targetHttpsProxies/{{name}}/setUrlMap") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -478,80 +436,6 @@ func resourceComputeRegionTargetHttpsProxyUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error updating RegionTargetHttpsProxy %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating RegionTargetHttpsProxy %q: %#v", d.Id(), res) - } - - err = ComputeOperationWaitTime( - config, res, project, "Updating RegionTargetHttpsProxy", userAgent, - d.Timeout(schema.TimeoutUpdate)) - if err != nil { - return err - } - } - if d.HasChange("ssl_policy") { - obj := make(map[string]interface{}) - - getUrl, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/targetHttpsProxies/{{name}}") - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - getRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: getUrl, - UserAgent: userAgent, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionTargetHttpsProxy %q", d.Id())) - } - - obj["fingerprint"] = getRes["fingerprint"] - - sslPolicyProp, err := expandComputeRegionTargetHttpsProxySslPolicy(d.Get("ssl_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ssl_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, sslPolicyProp)) { - obj["sslPolicy"] = sslPolicyProp - } - - obj, err = resourceComputeRegionTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/regions/{{region}}/targetHttpsProxies/{{name}}") - if err != nil { - return err - } - - headers := make(http.Header) - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating RegionTargetHttpsProxy %q: %s", d.Id(), err) @@ -599,8 +483,6 @@ func resourceComputeRegionTargetHttpsProxyDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionTargetHttpsProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -610,7 +492,6 @@ func resourceComputeRegionTargetHttpsProxyDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionTargetHttpsProxy") @@ -703,13 +584,6 @@ func flattenComputeRegionTargetHttpsProxyUrlMap(v interface{}, d *schema.Resourc return tpgresource.ConvertSelfLinkToV1(v.(string)) } -func flattenComputeRegionTargetHttpsProxyServerTlsPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - func flattenComputeRegionTargetHttpsProxyRegion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -782,10 +656,6 @@ func expandComputeRegionTargetHttpsProxyUrlMap(v interface{}, d tpgresource.Terr return f.RelativeLink(), nil } -func expandComputeRegionTargetHttpsProxyServerTlsPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeRegionTargetHttpsProxyRegion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { f, err := tpgresource.ParseGlobalFieldValue("regions", v.(string), "project", d, config, true) if err != nil { @@ -807,19 +677,6 @@ func resourceComputeRegionTargetHttpsProxyEncoder(d *schema.ResourceData, meta i return obj, nil } -func resourceComputeRegionTargetHttpsProxyUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - - if _, ok := obj["certificateManagerCertificates"]; ok { - // The field certificateManagerCertificates should not be included in the API request, and it should be renamed to `sslCertificates` - // The API does not allow using both certificate manager certificates and sslCertificates. If that changes - // in the future, the encoder logic should change accordingly because this will mean that both fields are no longer mutual exclusive. - log.Printf("[DEBUG] converting the field CertificateManagerCertificates to sslCertificates before sending the request") - obj["sslCertificates"] = obj["certificateManagerCertificates"] - delete(obj, "certificateManagerCertificates") - } - return obj, nil -} - func resourceComputeRegionTargetHttpsProxyDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { // Since both sslCertificates and certificateManagerCertificates maps to the same API field (sslCertificates), we need to check the types // of certificates that exist in the array and decide whether to change the field to certificateManagerCertificate or not. diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_tcp_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_tcp_proxy.go index ad83397e575..f59a9dd3706 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_tcp_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_target_tcp_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -192,7 +191,6 @@ func resourceComputeRegionTargetTcpProxyCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -201,7 +199,6 @@ func resourceComputeRegionTargetTcpProxyCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionTargetTcpProxy: %s", err) @@ -254,14 +251,12 @@ func resourceComputeRegionTargetTcpProxyRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionTargetTcpProxy %q", d.Id())) @@ -329,8 +324,6 @@ func resourceComputeRegionTargetTcpProxyDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionTargetTcpProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -340,7 +333,6 @@ func resourceComputeRegionTargetTcpProxyDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionTargetTcpProxy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_url_map.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_url_map.go index 7683c96792f..048f6b7aa10 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_url_map.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_region_url_map.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -945,7 +944,7 @@ less than one second are represented with a 0 'seconds' field and a positive - 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, -for example: disconnects, reset, read timeout, connection failure, and refused +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. @@ -1515,19 +1514,6 @@ the provided metadata. Possible values: ["MATCH_ALL", "MATCH_ANY"]`, }, }, }, - "path_template_match": { - Type: schema.TypeString, - Optional: true, - Description: `For satisfying the matchRule condition, the path of the request -must match the wildcard pattern specified in pathTemplateMatch -after removing any query parameters and anchor that may be part -of the original URL. - -pathTemplateMatch must be between 1 and 255 characters -(inclusive). The pattern specified by pathTemplateMatch may -have at most 5 wildcard operators and at most 5 variable -captures in total.`, - }, "prefix_match": { Type: schema.TypeString, Optional: true, @@ -1815,7 +1801,7 @@ less than one second are represented with a 0 'seconds' field and a positive * 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, - for example: disconnects, reset, read timeout, connection failure, and refused + 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. @@ -1888,24 +1874,6 @@ header is replaced with contents of hostRewrite. The value must be between 1 and portion of the request's path is replaced by pathPrefixRewrite. The value must be between 1 and 1024 characters.`, }, - "path_template_rewrite": { - Type: schema.TypeString, - Optional: true, - Description: `Prior to forwarding the request to the selected origin, if the -request matched a pathTemplateMatch, the matching portion of the -request's path is replaced re-written using the pattern specified -by pathTemplateRewrite. - -pathTemplateRewrite must be between 1 and 255 characters -(inclusive), must start with a '/', and must only use variables -captured by the route's pathTemplate matchers. - -pathTemplateRewrite may only be used when all of a route's -MatchRules specify pathTemplate. - -Only one of pathPrefixRewrite and pathTemplateRewrite may be -specified.`, - }, }, }, }, @@ -2310,7 +2278,6 @@ func resourceComputeRegionUrlMapCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -2319,7 +2286,6 @@ func resourceComputeRegionUrlMapCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RegionUrlMap: %s", err) @@ -2372,14 +2338,12 @@ func resourceComputeRegionUrlMapRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRegionUrlMap %q", d.Id())) @@ -2515,7 +2479,6 @@ func resourceComputeRegionUrlMapUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating RegionUrlMap %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -2530,7 +2493,6 @@ func resourceComputeRegionUrlMapUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -2577,8 +2539,6 @@ func resourceComputeRegionUrlMapDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RegionUrlMap %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -2588,7 +2548,6 @@ func resourceComputeRegionUrlMapDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RegionUrlMap") @@ -2898,7 +2857,6 @@ func flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRules(v interface{}, d "prefix_match": flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRulesPrefixMatch(original["prefixMatch"], d, config), "query_parameter_matches": flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRulesQueryParameterMatches(original["queryParameterMatches"], d, config), "regex_match": flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRulesRegexMatch(original["regexMatch"], d, config), - "path_template_match": flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRulesPathTemplateMatch(original["pathTemplateMatch"], d, config), }) } return transformed @@ -3108,10 +3066,6 @@ func flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRulesRegexMatch(v inter return v } -func flattenComputeRegionUrlMapPathMatcherRouteRulesMatchRulesPathTemplateMatch(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenComputeRegionUrlMapPathMatcherRouteRulesRouteAction(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -3458,8 +3412,6 @@ func flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewrite(v inte flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewriteHostRewrite(original["hostRewrite"], d, config) transformed["path_prefix_rewrite"] = flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathPrefixRewrite(original["pathPrefixRewrite"], d, config) - transformed["path_template_rewrite"] = - flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathTemplateRewrite(original["pathTemplateRewrite"], d, config) return []interface{}{transformed} } func flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewriteHostRewrite(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -3470,10 +3422,6 @@ func flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathPre return v } -func flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathTemplateRewrite(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenComputeRegionUrlMapPathMatcherRouteRulesRouteActionWeightedBackendServices(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -5276,13 +5224,6 @@ func expandComputeRegionUrlMapPathMatcherRouteRulesMatchRules(v interface{}, d t transformed["regexMatch"] = transformedRegexMatch } - transformedPathTemplateMatch, err := expandComputeRegionUrlMapPathMatcherRouteRulesMatchRulesPathTemplateMatch(original["path_template_match"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPathTemplateMatch); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pathTemplateMatch"] = transformedPathTemplateMatch - } - req = append(req, transformed) } return req, nil @@ -5566,10 +5507,6 @@ func expandComputeRegionUrlMapPathMatcherRouteRulesMatchRulesRegexMatch(v interf return v, nil } -func expandComputeRegionUrlMapPathMatcherRouteRulesMatchRulesPathTemplateMatch(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeRegionUrlMapPathMatcherRouteRulesRouteAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -6014,13 +5951,6 @@ func expandComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewrite(v inter transformed["pathPrefixRewrite"] = transformedPathPrefixRewrite } - transformedPathTemplateRewrite, err := expandComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathTemplateRewrite(original["path_template_rewrite"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPathTemplateRewrite); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pathTemplateRewrite"] = transformedPathTemplateRewrite - } - return transformed, nil } @@ -6032,10 +5962,6 @@ func expandComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathPref return v, nil } -func expandComputeRegionUrlMapPathMatcherRouteRulesRouteActionUrlRewritePathTemplateRewrite(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeRegionUrlMapPathMatcherRouteRulesRouteActionWeightedBackendServices(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) req := make([]interface{}, 0, len(l)) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_reservation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_reservation.go index 5152a49ae77..ed0c61693e0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_reservation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_reservation.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "net/url" "reflect" "strconv" @@ -213,7 +212,6 @@ for information on available CPU platforms.`, Type: schema.TypeString, Computed: true, Optional: true, - ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"LOCAL", "SPECIFIC_PROJECTS", ""}), Description: `Type of sharing for this shared-reservation Possible values: ["LOCAL", "SPECIFIC_PROJECTS"]`, }, @@ -324,7 +322,6 @@ func resourceComputeReservationCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -333,7 +330,6 @@ func resourceComputeReservationCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Reservation: %s", err) @@ -386,14 +382,12 @@ func resourceComputeReservationRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeReservation %q", d.Id())) @@ -468,7 +462,6 @@ func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Reservation %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("share_settings") { @@ -507,7 +500,6 @@ func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -546,7 +538,6 @@ func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) return err } - headers := make(http.Header) if d.HasChange("share_settings") { url, err = tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/zones/{{zone}}/reservations/{{name}}") if err != nil { @@ -572,7 +563,6 @@ func resourceComputeReservationUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Reservation %q: %s", d.Id(), err) @@ -620,8 +610,6 @@ func resourceComputeReservationDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Reservation %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -631,7 +619,6 @@ func resourceComputeReservationDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Reservation") @@ -1129,27 +1116,10 @@ func resourceComputeReservationUpdateEncoder(d *schema.ResourceData, meta interf // Set project_map. projectMap := make(map[string]interface{}) old, new := d.GetChange("share_settings") - - var before *schema.Set - if oldSlice, ok := old.([]interface{}); ok && len(oldSlice) > 0 { - if oldMap, ok := oldSlice[0].(map[string]interface{})["project_map"]; ok { - before = oldMap.(*schema.Set) - } else { - before = schema.NewSet(schema.HashString, []interface{}{}) - } - } else { - before = schema.NewSet(schema.HashString, []interface{}{}) - } - var after *schema.Set - if newSlice, ok := new.([]interface{}); ok && len(newSlice) > 0 { - if newMap, ok := newSlice[0].(map[string]interface{})["project_map"]; ok { - after = newMap.(*schema.Set) - } else { - after = schema.NewSet(schema.HashString, []interface{}{}) - } - } else { - after = schema.NewSet(schema.HashString, []interface{}{}) - } + oldMap := old.([]interface{})[0].(map[string]interface{})["project_map"] + newMap := new.([]interface{})[0].(map[string]interface{})["project_map"] + before := oldMap.(*schema.Set) + after := newMap.(*schema.Set) for _, raw := range after.Difference(before).List() { original := raw.(map[string]interface{}) @@ -1165,10 +1135,10 @@ func resourceComputeReservationUpdateEncoder(d *schema.ResourceData, meta interf } projectMap[transformedId] = singleProject // add added projects to updateMask - if !firstProject { - maskId = fmt.Sprintf("%s%s", "&paths=shareSettings.projectMap.", original["id"]) + if firstProject != true { + maskId = fmt.Sprintf("%s%s", "&paths=shareSettings.projectMap.", original["project_id"]) } else { - maskId = fmt.Sprintf("%s%s", "?paths=shareSettings.projectMap.", original["id"]) + maskId = fmt.Sprintf("%s%s", "?paths=shareSettings.projectMap.", original["project_id"]) firstProject = false } decodedPath, _ := url.QueryUnescape(maskId) @@ -1195,7 +1165,7 @@ func resourceComputeReservationUpdateEncoder(d *schema.ResourceData, meta interf projectNum := project.ProjectNumber projectIdOrNum = fmt.Sprintf("%d", projectNum) } - if !firstProject { + if firstProject != true { maskId = fmt.Sprintf("%s%s", "&paths=shareSettings.projectMap.", projectIdOrNum) } else { maskId = fmt.Sprintf("%s%s", "?paths=shareSettings.projectMap.", projectIdOrNum) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_resource_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_resource_policy.go index 5469836089c..5bfe755968a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_resource_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_resource_policy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -265,7 +264,8 @@ both 13:00-5 and 08:00 are valid.`, ValidateFunc: verify.ValidateHourlyOnly, Description: `Time within the window to start the operations. It must be in an hourly format "HH:MM", -where HH : [00-23] and MM : [00] GMT. eg: 21:00`, +where HH : [00-23] and MM : [00] GMT. +eg: 21:00`, }, }, }, @@ -479,7 +479,6 @@ func resourceComputeResourcePolicyCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -488,7 +487,6 @@ func resourceComputeResourcePolicyCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ResourcePolicy: %s", err) @@ -541,14 +539,12 @@ func resourceComputeResourcePolicyRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeResourcePolicy %q", d.Id())) @@ -618,8 +614,6 @@ func resourceComputeResourcePolicyDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ResourcePolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -629,7 +623,6 @@ func resourceComputeResourcePolicyDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ResourcePolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_route.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_route.go index 2455fe90063..512c4e6eae7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_route.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_route.go @@ -20,8 +20,6 @@ package compute import ( "fmt" "log" - "net" - "net/http" "reflect" "time" @@ -33,19 +31,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/verify" ) -// Use this method when the field accepts either an IP address or a -// self_link referencing a resource (such as google_compute_route's -// next_hop_ilb) -func CompareIpAddressOrSelfLinkOrResourceName(_, old, new string, _ *schema.ResourceData) bool { - // if we can parse `new` as an IP address, then compare as strings - if net.ParseIP(new) != nil { - return new == old - } - - // otherwise compare as self links - return tpgresource.CompareSelfLinkOrResourceName("", old, new, nil) -} - func ResourceComputeRoute() *schema.Resource { return &schema.Resource{ Create: resourceComputeRouteCreate, @@ -118,7 +103,7 @@ partial valid URL: Type: schema.TypeString, Optional: true, ForceNew: true, - DiffSuppressFunc: CompareIpAddressOrSelfLinkOrResourceName, + DiffSuppressFunc: tpgresource.CompareIpAddressOrSelfLinkOrResourceName, Description: `The IP address or URL to a forwarding rule of type loadBalancingScheme=INTERNAL that should handle matching packets. @@ -317,7 +302,6 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -326,7 +310,6 @@ func resourceComputeRouteCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsPeeringOperationInProgress}, }) if err != nil { @@ -380,14 +363,12 @@ func resourceComputeRouteRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsPeeringOperationInProgress}, }) if err != nil { @@ -487,8 +468,6 @@ func resourceComputeRouteDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Route %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -498,7 +477,6 @@ func resourceComputeRouteDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsPeeringOperationInProgress}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router.go index bc0cd9801ee..a0f92e9594f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -154,16 +153,6 @@ CIDR-formatted string.`, }, }, }, - "identifier_range": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `Explicitly specifies a range of valid BGP Identifiers for this Router. -It is provided as a link-local IPv4 range (from 169.254.0.0/16), of -size at least /30, even if the BGP sessions are over IPv6. It must -not overlap with any IPv4 BGP session ranges. Other vendors commonly -call this router ID.`, - }, "keepalive_interval": { Type: schema.TypeInt, Optional: true, @@ -293,7 +282,6 @@ func resourceComputeRouterCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -302,7 +290,6 @@ func resourceComputeRouterCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Router: %s", err) @@ -355,14 +342,12 @@ func resourceComputeRouterRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRouter %q", d.Id())) @@ -442,7 +427,6 @@ func resourceComputeRouterUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Router %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -457,7 +441,6 @@ func resourceComputeRouterUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -511,8 +494,6 @@ func resourceComputeRouterDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Router %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -522,7 +503,6 @@ func resourceComputeRouterDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Router") @@ -599,8 +579,6 @@ func flattenComputeRouterBgp(v interface{}, d *schema.ResourceData, config *tran flattenComputeRouterBgpAdvertisedIpRanges(original["advertisedIpRanges"], d, config) transformed["keepalive_interval"] = flattenComputeRouterBgpKeepaliveInterval(original["keepaliveInterval"], d, config) - transformed["identifier_range"] = - flattenComputeRouterBgpIdentifierRange(original["identifierRange"], d, config) return []interface{}{transformed} } func flattenComputeRouterBgpAsn(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -633,30 +611,26 @@ func flattenComputeRouterBgpAdvertisedIpRanges(v interface{}, d *schema.Resource return v } l := v.([]interface{}) - apiData := make([]map[string]interface{}, 0, len(l)) + transformed := make([]interface{}, 0, len(l)) for _, raw := range l { original := raw.(map[string]interface{}) if len(original) < 1 { // Do not include empty json objects coming back from the api continue } - apiData = append(apiData, map[string]interface{}{ - "description": original["description"], - "range": original["range"], + transformed = append(transformed, map[string]interface{}{ + "range": flattenComputeRouterBgpAdvertisedIpRangesRange(original["range"], d, config), + "description": flattenComputeRouterBgpAdvertisedIpRangesDescription(original["description"], d, config), }) } - configData := []map[string]interface{}{} - if v, ok := d.GetOk("advertised_ip_ranges"); ok { - for _, item := range v.([]interface{}) { - configData = append(configData, item.(map[string]interface{})) - } - } - sorted, err := tpgresource.SortMapsByConfigOrder(configData, apiData, "range") - if err != nil { - log.Printf("[ERROR] Could not support API response for advertisedIpRanges.0.range: %s", err) - return apiData - } - return sorted + return transformed +} +func flattenComputeRouterBgpAdvertisedIpRangesRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenComputeRouterBgpAdvertisedIpRangesDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v } func flattenComputeRouterBgpKeepaliveInterval(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -676,10 +650,6 @@ func flattenComputeRouterBgpKeepaliveInterval(v interface{}, d *schema.ResourceD return v // let terraform core handle it otherwise } -func flattenComputeRouterBgpIdentifierRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenComputeRouterEncryptedInterconnectRouter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -751,13 +721,6 @@ func expandComputeRouterBgp(v interface{}, d tpgresource.TerraformResourceData, transformed["keepaliveInterval"] = transformedKeepaliveInterval } - transformedIdentifierRange, err := expandComputeRouterBgpIdentifierRange(original["identifier_range"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedIdentifierRange); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["identifierRange"] = transformedIdentifierRange - } - return transformed, nil } @@ -814,10 +777,6 @@ func expandComputeRouterBgpKeepaliveInterval(v interface{}, d tpgresource.Terraf return v, nil } -func expandComputeRouterBgpIdentifierRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeRouterEncryptedInterconnectRouter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_interface.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_interface.go index 7a0833fb66d..a2b504821d8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_interface.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_interface.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/verify" "google.golang.org/api/googleapi" "google.golang.org/api/compute/v1" @@ -78,14 +77,6 @@ func ResourceComputeRouterInterface() *schema.Resource { AtLeastOneOf: []string{"ip_range", "interconnect_attachment", "subnetwork", "vpn_tunnel"}, Description: `The IP address and range of the interface. The IP range must be in the RFC3927 link-local IP space. Changing this forces a new interface to be created.`, }, - "ip_version": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, - ValidateFunc: verify.ValidateEnum([]string{"IPV4", "IPV6"}), - Description: `IP version of this interface.`, - }, "private_ip_address": { Type: schema.TypeString, Optional: true, @@ -184,10 +175,6 @@ func resourceComputeRouterInterfaceCreate(d *schema.ResourceData, meta interface iface.IpRange = ipRangeVal.(string) } - if ipVersionVal, ok := d.GetOk("ip_version"); ok { - iface.IpVersion = ipVersionVal.(string) - } - if privateIpVal, ok := d.GetOk("private_ip_address"); ok { iface.PrivateIpAddress = privateIpVal.(string) } @@ -279,9 +266,6 @@ func resourceComputeRouterInterfaceRead(d *schema.ResourceData, meta interface{} if err := d.Set("ip_range", iface.IpRange); err != nil { return fmt.Errorf("Error setting ip_range: %s", err) } - if err := d.Set("ip_version", iface.IpVersion); err != nil { - return fmt.Errorf("Error setting ip_version: %s", err) - } if err := d.Set("private_ip_address", iface.PrivateIpAddress); err != nil { return fmt.Errorf("Error setting private_ip_address: %s", err) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_nat.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_nat.go index fb758357e47..35bc528e35e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_nat.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_nat.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -219,15 +218,6 @@ ranges in every Subnetwork are allowed to Nat. contains ALL_SUBNETWORKS_ALL_IP_RANGES or ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES, then there should not be any other RouterNat section in any Router for this network in this region. Possible values: ["ALL_SUBNETWORKS_ALL_IP_RANGES", "ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES", "LIST_OF_SUBNETWORKS"]`, - }, - "auto_network_tier": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"PREMIUM", "STANDARD", ""}), - Description: `The network tier to use when automatically reserving NAT IP addresses. -Must be one of: PREMIUM, STANDARD. If not specified, then the current -project-level default tier is used. Possible values: ["PREMIUM", "STANDARD"]`, }, "drain_nat_ips": { Type: schema.TypeSet, @@ -259,20 +249,6 @@ Mutually exclusive with enableEndpointIndependentMapping.`, Description: `Enable endpoint independent mapping. For more information see the [official documentation](https://cloud.google.com/nat/docs/overview#specs-rfcs).`, }, - "endpoint_types": { - Type: schema.TypeList, - Computed: true, - Optional: true, - ForceNew: true, - Description: `Specifies the endpoint Types supported by the NAT Gateway. -Supported values include: - 'ENDPOINT_TYPE_VM', 'ENDPOINT_TYPE_SWG', - 'ENDPOINT_TYPE_MANAGED_PROXY_LB'.`, - MinItems: 1, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, "icmp_idle_timeout_sec": { Type: schema.TypeInt, Optional: true, @@ -599,12 +575,6 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er } else if v, ok := d.GetOkExists("log_config"); ok || !reflect.DeepEqual(v, logConfigProp) { obj["logConfig"] = logConfigProp } - endpointTypesProp, err := expandNestedComputeRouterNatEndpointTypes(d.Get("endpoint_types"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("endpoint_types"); !tpgresource.IsEmptyValue(reflect.ValueOf(endpointTypesProp)) && (ok || !reflect.DeepEqual(v, endpointTypesProp)) { - obj["endpointTypes"] = endpointTypesProp - } rulesProp, err := expandNestedComputeRouterNatRules(d.Get("rules"), d, config) if err != nil { return err @@ -617,12 +587,6 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er } else if v, ok := d.GetOkExists("enable_endpoint_independent_mapping"); ok || !reflect.DeepEqual(v, enableEndpointIndependentMappingProp) { obj["enableEndpointIndependentMapping"] = enableEndpointIndependentMappingProp } - autoNetworkTierProp, err := expandNestedComputeRouterNatAutoNetworkTier(d.Get("auto_network_tier"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("auto_network_tier"); !tpgresource.IsEmptyValue(reflect.ValueOf(autoNetworkTierProp)) && (ok || !reflect.DeepEqual(v, autoNetworkTierProp)) { - obj["autoNetworkTier"] = autoNetworkTierProp - } lockName, err := tpgresource.ReplaceVars(d, config, "router/{{region}}/{{router}}") if err != nil { @@ -655,7 +619,6 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -664,7 +627,6 @@ func resourceComputeRouterNatCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RouterNat: %s", err) @@ -717,14 +679,12 @@ func resourceComputeRouterNatRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeRouterNat %q", d.Id())) @@ -791,18 +751,12 @@ func resourceComputeRouterNatRead(d *schema.ResourceData, meta interface{}) erro if err := d.Set("log_config", flattenNestedComputeRouterNatLogConfig(res["logConfig"], d, config)); err != nil { return fmt.Errorf("Error reading RouterNat: %s", err) } - if err := d.Set("endpoint_types", flattenNestedComputeRouterNatEndpointTypes(res["endpointTypes"], d, config)); err != nil { - return fmt.Errorf("Error reading RouterNat: %s", err) - } if err := d.Set("rules", flattenNestedComputeRouterNatRules(res["rules"], d, config)); err != nil { return fmt.Errorf("Error reading RouterNat: %s", err) } if err := d.Set("enable_endpoint_independent_mapping", flattenNestedComputeRouterNatEnableEndpointIndependentMapping(res["enableEndpointIndependentMapping"], d, config)); err != nil { return fmt.Errorf("Error reading RouterNat: %s", err) } - if err := d.Set("auto_network_tier", flattenNestedComputeRouterNatAutoNetworkTier(res["autoNetworkTier"], d, config)); err != nil { - return fmt.Errorf("Error reading RouterNat: %s", err) - } return nil } @@ -919,12 +873,6 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er } else if v, ok := d.GetOkExists("enable_endpoint_independent_mapping"); ok || !reflect.DeepEqual(v, enableEndpointIndependentMappingProp) { obj["enableEndpointIndependentMapping"] = enableEndpointIndependentMappingProp } - autoNetworkTierProp, err := expandNestedComputeRouterNatAutoNetworkTier(d.Get("auto_network_tier"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("auto_network_tier"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, autoNetworkTierProp)) { - obj["autoNetworkTier"] = autoNetworkTierProp - } lockName, err := tpgresource.ReplaceVars(d, config, "router/{{region}}/{{router}}") if err != nil { @@ -939,7 +887,6 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating RouterNat %q: %#v", d.Id(), obj) - headers := make(http.Header) obj, err = resourceComputeRouterNatPatchUpdateEncoder(d, meta, obj) if err != nil { @@ -959,7 +906,6 @@ func resourceComputeRouterNatUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1018,8 +964,6 @@ func resourceComputeRouterNatDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RouterNat %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1029,7 +973,6 @@ func resourceComputeRouterNatDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RouterNat") @@ -1266,10 +1209,6 @@ func flattenNestedComputeRouterNatLogConfigFilter(v interface{}, d *schema.Resou return v } -func flattenNestedComputeRouterNatEndpointTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenNestedComputeRouterNatRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -1349,10 +1288,6 @@ func flattenNestedComputeRouterNatEnableEndpointIndependentMapping(v interface{} return v } -func flattenNestedComputeRouterNatAutoNetworkTier(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandNestedComputeRouterNatName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1520,10 +1455,6 @@ func expandNestedComputeRouterNatLogConfigFilter(v interface{}, d tpgresource.Te return v, nil } -func expandNestedComputeRouterNatEndpointTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandNestedComputeRouterNatRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { v = v.(*schema.Set).List() l := v.([]interface{}) @@ -1644,10 +1575,6 @@ func expandNestedComputeRouterNatEnableEndpointIndependentMapping(v interface{}, return v, nil } -func expandNestedComputeRouterNatAutoNetworkTier(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func flattenNestedComputeRouterNat(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { var v interface{} var ok bool diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_peer.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_peer.go index 42ef6ade516..4720875616a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_peer.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_router_peer.go @@ -208,12 +208,6 @@ The default is true.`, Description: `Enable IPv6 traffic over BGP Peer. If not specified, it is disabled by default.`, Default: false, }, - "enable_ipv4": { - Type: schema.TypeBool, - Optional: true, - Description: `Enable IPv4 traffic over BGP Peer. It is enabled by default if the peerIpAddress is version 4.`, - Computed: true, - }, "ip_address": { Type: schema.TypeString, Computed: true, @@ -232,13 +226,6 @@ The address must be in the range 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64. If you do not specify the next hop addresses, Google Cloud automatically assigns unused addresses from the 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64 range for you.`, }, - "ipv4_nexthop_address": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: verify.ValidateIpAddress, - Description: `IPv4 address of the interface inside Google Cloud Platform.`, - }, "peer_ip_address": { Type: schema.TypeString, Computed: true, @@ -257,13 +244,6 @@ The address must be in the range 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64. If you do not specify the next hop addresses, Google Cloud automatically assigns unused addresses from the 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64 range for you.`, }, - "peer_ipv4_nexthop_address": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: verify.ValidateIpAddress, - Description: `IPv4 address of the BGP interface outside Google Cloud Platform.`, - }, "region": { Type: schema.TypeString, Computed: true, @@ -416,24 +396,6 @@ func resourceComputeRouterBgpPeerCreate(d *schema.ResourceData, meta interface{} } else if v, ok := d.GetOkExists("enable_ipv6"); ok || !reflect.DeepEqual(v, enableIpv6Prop) { obj["enableIpv6"] = enableIpv6Prop } - enableIpv4Prop, err := expandNestedComputeRouterBgpPeerEnableIpv4(d.Get("enable_ipv4"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enable_ipv4"); ok || !reflect.DeepEqual(v, enableIpv4Prop) { - obj["enableIpv4"] = enableIpv4Prop - } - ipv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv4NexthopAddress(d.Get("ipv4_nexthop_address"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ipv4_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipv4NexthopAddressProp)) && (ok || !reflect.DeepEqual(v, ipv4NexthopAddressProp)) { - obj["ipv4NexthopAddress"] = ipv4NexthopAddressProp - } - peerIpv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(d.Get("peer_ipv4_nexthop_address"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("peer_ipv6_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(peerIpv4NexthopAddressProp)) && (ok || !reflect.DeepEqual(v, peerIpv4NexthopAddressProp)) { - obj["peerIpv4NexthopAddress"] = peerIpv4NexthopAddressProp - } ipv6NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv6NexthopAddress(d.Get("ipv6_nexthop_address"), d, config) if err != nil { return err @@ -625,15 +587,6 @@ func resourceComputeRouterBgpPeerRead(d *schema.ResourceData, meta interface{}) if err := d.Set("enable_ipv6", flattenNestedComputeRouterBgpPeerEnableIpv6(res["enableIpv6"], d, config)); err != nil { return fmt.Errorf("Error reading RouterBgpPeer: %s", err) } - if err := d.Set("enable_ipv4", flattenNestedComputeRouterBgpPeerEnableIpv4(res["enableIpv4"], d, config)); err != nil { - return fmt.Errorf("Error reading RouterBgpPeer: %s", err) - } - if err := d.Set("ipv4_nexthop_address", flattenNestedComputeRouterBgpPeerIpv4NexthopAddress(res["ipv4NexthopAddress"], d, config)); err != nil { - return fmt.Errorf("Error reading RouterBgpPeer: %s", err) - } - if err := d.Set("peer_ipv4_nexthop_address", flattenNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(res["peerIpv4NexthopAddress"], d, config)); err != nil { - return fmt.Errorf("Error reading RouterBgpPeer: %s", err) - } if err := d.Set("ipv6_nexthop_address", flattenNestedComputeRouterBgpPeerIpv6NexthopAddress(res["ipv6NexthopAddress"], d, config)); err != nil { return fmt.Errorf("Error reading RouterBgpPeer: %s", err) } @@ -729,24 +682,6 @@ func resourceComputeRouterBgpPeerUpdate(d *schema.ResourceData, meta interface{} } else if v, ok := d.GetOkExists("enable_ipv6"); ok || !reflect.DeepEqual(v, enableIpv6Prop) { obj["enableIpv6"] = enableIpv6Prop } - enableIpv4Prop, err := expandNestedComputeRouterBgpPeerEnableIpv4(d.Get("enable_ipv4"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enable_ipv4"); ok || !reflect.DeepEqual(v, enableIpv4Prop) { - obj["enableIpv4"] = enableIpv4Prop - } - ipv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv4NexthopAddress(d.Get("ipv4_nexthop_address"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ipv4_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipv4NexthopAddressProp)) && (ok || !reflect.DeepEqual(v, ipv4NexthopAddressProp)) { - obj["ipv4NexthopAddress"] = ipv4NexthopAddressProp - } - peerIpv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(d.Get("peer_ipv4_nexthop_address"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("peer_ipv4_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, peerIpv4NexthopAddressProp)) { - obj["peerIpv4NexthopAddress"] = peerIpv4NexthopAddressProp - } ipv6NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv6NexthopAddress(d.Get("ipv6_nexthop_address"), d, config) if err != nil { return err @@ -1120,18 +1055,6 @@ func flattenNestedComputeRouterBgpPeerEnableIpv6(v interface{}, d *schema.Resour return v } -func flattenNestedComputeRouterBgpPeerEnableIpv4(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNestedComputeRouterBgpPeerIpv4NexthopAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenNestedComputeRouterBgpPeerIpv6NexthopAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1319,18 +1242,6 @@ func expandNestedComputeRouterBgpPeerEnableIpv6(v interface{}, d tpgresource.Ter return v, nil } -func expandNestedComputeRouterBgpPeerEnableIpv4(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNestedComputeRouterBgpPeerIpv4NexthopAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandNestedComputeRouterBgpPeerIpv6NexthopAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy.go index bba70fd5ad6..7fc1d1bb7ac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy.go @@ -37,9 +37,9 @@ func ResourceComputeSecurityPolicy() *schema.Resource { ), Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), + Create: schema.DefaultTimeout(8 * time.Minute), + Update: schema.DefaultTimeout(8 * time.Minute), + Delete: schema.DefaultTimeout(8 * time.Minute), }, Schema: map[string]*schema.Schema{ @@ -152,45 +152,6 @@ func ResourceComputeSecurityPolicy() *schema.Resource { }, Description: `User defined CEVAL expression. A CEVAL expression is used to specify match criteria such as origin.ip, source.region_code and contents in the request header.`, }, - - "expr_options": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Description: `The configuration options available when specifying a user defined CEVAL expression (i.e., 'expr').`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "recaptcha_options": { - Type: schema.TypeList, - Required: true, - MaxItems: 1, - Description: `reCAPTCHA configuration options to be applied for the rule. If the rule does not evaluate reCAPTCHA tokens, this field has no effect.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action_token_site_keys": { - Type: schema.TypeList, - Optional: true, - Description: `A list of site keys to be used during the validation of reCAPTCHA action-tokens. The provided site keys need to be created from reCAPTCHA API under the same project where the security policy is created`, - MinItems: 1, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "session_token_site_keys": { - Type: schema.TypeList, - Optional: true, - Description: `A list of site keys to be used during the validation of reCAPTCHA session-tokens. The provided site keys need to be created from reCAPTCHA API under the same project where the security policy is created.`, - MinItems: 1, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, }, }, Description: `A match condition that incoming traffic is evaluated against. If it evaluates to true, the corresponding action is enforced.`, @@ -257,7 +218,7 @@ func ResourceComputeSecurityPolicy() *schema.Resource { Type: schema.TypeString, Optional: true, Description: `Determines the key to enforce the rateLimitThreshold on`, - ValidateFunc: validation.StringInSlice([]string{"ALL", "IP", "HTTP_HEADER", "XFF_IP", "HTTP_COOKIE", "HTTP_PATH", "SNI", "REGION_CODE", "TLS_JA3_FINGERPRINT", "USER_IP", ""}, false), + ValidateFunc: validation.StringInSlice([]string{"ALL", "IP", "HTTP_HEADER", "XFF_IP", "HTTP_COOKIE", "HTTP_PATH", "SNI", "REGION_CODE", ""}, false), }, "enforce_on_key_name": { @@ -459,7 +420,7 @@ func ResourceComputeSecurityPolicy() *schema.Resource { "rule_visibility": { Type: schema.TypeString, Optional: true, - Computed: true, + Default: "STANDARD", ValidateFunc: validation.StringInSlice([]string{"STANDARD", "PREMIUM"}, false), Description: `Rule visibility. Supported values include: "STANDARD", "PREMIUM".`, }, @@ -819,7 +780,6 @@ func expandSecurityPolicyMatch(configured []interface{}) *compute.SecurityPolicy VersionedExpr: data["versioned_expr"].(string), Config: expandSecurityPolicyMatchConfig(data["config"].([]interface{})), Expr: expandSecurityPolicyMatchExpr(data["expr"].([]interface{})), - ExprOptions: expandSecurityPolicyMatchExprOptions(data["expr_options"].([]interface{})), } } @@ -849,42 +809,6 @@ func expandSecurityPolicyMatchExpr(expr []interface{}) *compute.Expr { } } -func expandSecurityPolicyMatchExprOptions(exprOptions []interface{}) *compute.SecurityPolicyRuleMatcherExprOptions { - if len(exprOptions) == 0 || exprOptions[0] == nil { - return nil - } - - data := exprOptions[0].(map[string]interface{}) - return &compute.SecurityPolicyRuleMatcherExprOptions{ - RecaptchaOptions: expandSecurityPolicyMatchExprOptionsRecaptchaOptions(data["recaptcha_options"].([]interface{})), - } -} - -func expandSecurityPolicyMatchExprOptionsRecaptchaOptions(recaptchaOptions []interface{}) *compute.SecurityPolicyRuleMatcherExprOptionsRecaptchaOptions { - if len(recaptchaOptions) == 0 || recaptchaOptions[0] == nil { - return nil - } - - data := recaptchaOptions[0].(map[string]interface{}) - - actionTokenKeysInterface := data["action_token_site_keys"].([]interface{}) - actionTokenKeys := make([]string, len(actionTokenKeysInterface)) - for i, v := range actionTokenKeysInterface { - actionTokenKeys[i] = v.(string) - } - - sessionTokenKeysInterface := data["session_token_site_keys"].([]interface{}) - sessionTokenKeys := make([]string, len(sessionTokenKeysInterface)) - for i, v := range sessionTokenKeysInterface { - sessionTokenKeys[i] = v.(string) - } - - return &compute.SecurityPolicyRuleMatcherExprOptionsRecaptchaOptions{ - ActionTokenSiteKeys: actionTokenKeys, - SessionTokenSiteKeys: sessionTokenKeys, - } -} - func flattenSecurityPolicyRules(rules []*compute.SecurityPolicyRule) []map[string]interface{} { rulesSchema := make([]map[string]interface{}, 0, len(rules)) for _, rule := range rules { @@ -912,7 +836,6 @@ func flattenMatch(match *compute.SecurityPolicyRuleMatcher) []map[string]interfa "versioned_expr": match.VersionedExpr, "config": flattenMatchConfig(match.Config), "expr": flattenMatchExpr(match), - "expr_options": flattenMatchExprOptions(match.ExprOptions), } return []map[string]interface{}{data} @@ -930,31 +853,6 @@ func flattenMatchConfig(conf *compute.SecurityPolicyRuleMatcherConfig) []map[str return []map[string]interface{}{data} } -func flattenMatchExprOptions(exprOptions *compute.SecurityPolicyRuleMatcherExprOptions) []map[string]interface{} { - if exprOptions == nil { - return nil - } - - data := map[string]interface{}{ - "recaptcha_options": flattenMatchExprOptionsRecaptchaOptions(exprOptions.RecaptchaOptions), - } - - return []map[string]interface{}{data} -} - -func flattenMatchExprOptionsRecaptchaOptions(recaptchaOptions *compute.SecurityPolicyRuleMatcherExprOptionsRecaptchaOptions) []map[string]interface{} { - if recaptchaOptions == nil { - return nil - } - - data := map[string]interface{}{ - "action_token_site_keys": recaptchaOptions.ActionTokenSiteKeys, - "session_token_site_keys": recaptchaOptions.SessionTokenSiteKeys, - } - - return []map[string]interface{}{data} -} - func flattenMatchExpr(match *compute.SecurityPolicyRuleMatcher) []map[string]interface{} { if match.Expr == nil { return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy_rule.go deleted file mode 100644 index 80aff5dde81..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy_rule.go +++ /dev/null @@ -1,1990 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceComputeSecurityPolicyRule() *schema.Resource { - return &schema.Resource{ - Create: resourceComputeSecurityPolicyRuleCreate, - Read: resourceComputeSecurityPolicyRuleRead, - Update: resourceComputeSecurityPolicyRuleUpdate, - Delete: resourceComputeSecurityPolicyRuleDelete, - - Importer: &schema.ResourceImporter{ - State: resourceComputeSecurityPolicyRuleImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeString, - Required: true, - Description: `The Action to perform when the rule is matched. The following are the valid actions: - -* allow: allow access to target. - -* deny(STATUS): deny access to target, returns the HTTP response code specified. Valid values for STATUS are 403, 404, and 502. - -* rate_based_ban: limit client traffic to the configured threshold and ban the client if the traffic exceeds the threshold. Configure parameters for this action in RateLimitOptions. Requires rateLimitOptions to be set. - -* redirect: redirect to a different target. This can either be an internal reCAPTCHA redirect, or an external URL-based redirect via a 302 response. Parameters for this action can be configured via redirectOptions. This action is only supported in Global Security Policies of type CLOUD_ARMOR. - -* throttle: limit client traffic to the configured threshold. Configure parameters for this action in rateLimitOptions. Requires rateLimitOptions to be set for this.`, - }, - "priority": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: `An integer indicating the priority of a rule in the list. -The priority must be a positive value between 0 and 2147483647. -Rules are evaluated from highest to lowest priority where 0 is the highest priority and 2147483647 is the lowest priority.`, - }, - "security_policy": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the security policy this rule belongs to.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `An optional description of this resource. Provide this property when you create the resource.`, - }, - "match": { - Type: schema.TypeList, - Optional: true, - Description: `A match condition that incoming traffic is evaluated against. -If it evaluates to true, the corresponding 'action' is enforced.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "config": { - Type: schema.TypeList, - Optional: true, - Description: `The configuration options available when specifying versionedExpr. -This field must be specified if versionedExpr is specified and cannot be specified if versionedExpr is not specified.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "src_ip_ranges": { - Type: schema.TypeList, - Optional: true, - Description: `CIDR IP address range. Maximum number of srcIpRanges allowed is 10.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "expr": { - Type: schema.TypeList, - Optional: true, - Description: `User defined CEVAL expression. A CEVAL expression is used to specify match criteria such as origin.ip, source.region_code and contents in the request header.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax. The application context of the containing message determines which well-known feature set of CEL is supported.`, - }, - }, - }, - }, - "expr_options": { - Type: schema.TypeList, - Optional: true, - Description: `The configuration options available when specifying a user defined CEVAL expression (i.e., 'expr').`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "recaptcha_options": { - Type: schema.TypeList, - Required: true, - Description: `reCAPTCHA configuration options to be applied for the rule. If the rule does not evaluate reCAPTCHA tokens, this field has no effect.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action_token_site_keys": { - Type: schema.TypeList, - Optional: true, - Description: `A list of site keys to be used during the validation of reCAPTCHA action-tokens. The provided site keys need to be created from reCAPTCHA API under the same project where the security policy is created.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "session_token_site_keys": { - Type: schema.TypeList, - Optional: true, - Description: `A list of site keys to be used during the validation of reCAPTCHA session-tokens. The provided site keys need to be created from reCAPTCHA API under the same project where the security policy is created.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "versioned_expr": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"SRC_IPS_V1", ""}), - Description: `Preconfigured versioned expression. If this field is specified, config must also be specified. -Available preconfigured expressions along with their requirements are: SRC_IPS_V1 - must specify the corresponding srcIpRange field in config. Possible values: ["SRC_IPS_V1"]`, - }, - }, - }, - }, - "preconfigured_waf_config": { - Type: schema.TypeList, - Optional: true, - Description: `Preconfigured WAF configuration to be applied for the rule. -If the rule does not evaluate preconfigured WAF rules, i.e., if evaluatePreconfiguredWaf() is not used, this field will have no effect.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "exclusion": { - Type: schema.TypeList, - Optional: true, - Description: `An exclusion to apply during preconfigured WAF evaluation.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "target_rule_set": { - Type: schema.TypeString, - Required: true, - Description: `Target WAF rule set to apply the preconfigured WAF exclusion.`, - }, - "request_cookie": { - Type: schema.TypeList, - Optional: true, - Description: `Request cookie whose value will be excluded from inspection during preconfigured WAF evaluation.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "operator": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "EQUALS_ANY"}, false), - Description: `You can specify an exact match or a partial match by using a field operator and a field value. -Available options: -EQUALS: The operator matches if the field value equals the specified value. -STARTS_WITH: The operator matches if the field value starts with the specified value. -ENDS_WITH: The operator matches if the field value ends with the specified value. -CONTAINS: The operator matches if the field value contains the specified value. -EQUALS_ANY: The operator matches if the field value is any value.`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - Description: `A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. -The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY.`, - }, - }, - }, - }, - "request_header": { - Type: schema.TypeList, - Optional: true, - Description: `Request header whose value will be excluded from inspection during preconfigured WAF evaluation.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "operator": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "EQUALS_ANY"}, false), - Description: `You can specify an exact match or a partial match by using a field operator and a field value. -Available options: -EQUALS: The operator matches if the field value equals the specified value. -STARTS_WITH: The operator matches if the field value starts with the specified value. -ENDS_WITH: The operator matches if the field value ends with the specified value. -CONTAINS: The operator matches if the field value contains the specified value. -EQUALS_ANY: The operator matches if the field value is any value.`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - Description: `A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. -The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY.`, - }, - }, - }, - }, - "request_query_param": { - Type: schema.TypeList, - Optional: true, - Description: `Request query parameter whose value will be excluded from inspection during preconfigured WAF evaluation. -Note that the parameter can be in the query string or in the POST body.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "operator": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "EQUALS_ANY"}, false), - Description: `You can specify an exact match or a partial match by using a field operator and a field value. -Available options: -EQUALS: The operator matches if the field value equals the specified value. -STARTS_WITH: The operator matches if the field value starts with the specified value. -ENDS_WITH: The operator matches if the field value ends with the specified value. -CONTAINS: The operator matches if the field value contains the specified value. -EQUALS_ANY: The operator matches if the field value is any value.`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - Description: `A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. -The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY.`, - }, - }, - }, - }, - "request_uri": { - Type: schema.TypeList, - Optional: true, - Description: `Request URI from the request line to be excluded from inspection during preconfigured WAF evaluation. -When specifying this field, the query or fragment part should be excluded.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "operator": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{"EQUALS", "STARTS_WITH", "ENDS_WITH", "CONTAINS", "EQUALS_ANY"}, false), - Description: `You can specify an exact match or a partial match by using a field operator and a field value. -Available options: -EQUALS: The operator matches if the field value equals the specified value. -STARTS_WITH: The operator matches if the field value starts with the specified value. -ENDS_WITH: The operator matches if the field value ends with the specified value. -CONTAINS: The operator matches if the field value contains the specified value. -EQUALS_ANY: The operator matches if the field value is any value.`, - }, - "value": { - Type: schema.TypeString, - Optional: true, - Description: `A request field matching the specified value will be excluded from inspection during preconfigured WAF evaluation. -The field value must be given if the field operator is not EQUALS_ANY, and cannot be given if the field operator is EQUALS_ANY.`, - }, - }, - }, - }, - "target_rule_ids": { - Type: schema.TypeList, - Optional: true, - Description: `A list of target rule IDs under the WAF rule set to apply the preconfigured WAF exclusion. -If omitted, it refers to all the rule IDs under the WAF rule set.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "preview": { - Type: schema.TypeBool, - Optional: true, - Description: `If set to true, the specified action is not enforced.`, - }, - "rate_limit_options": { - Type: schema.TypeList, - Optional: true, - Description: `Must be specified if the action is "rate_based_ban" or "throttle". Cannot be specified for any other actions.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ban_duration_sec": { - Type: schema.TypeInt, - Optional: true, - Description: `Can only be specified if the action for the rule is "rate_based_ban". -If specified, determines the time (in seconds) the traffic will continue to be banned by the rate limit after the rate falls below the threshold.`, - }, - "ban_threshold": { - Type: schema.TypeList, - Optional: true, - Description: `Can only be specified if the action for the rule is "rate_based_ban". -If specified, the key will be banned for the configured 'banDurationSec' when the number of requests that exceed the 'rateLimitThreshold' also exceed this 'banThreshold'.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "count": { - Type: schema.TypeInt, - Optional: true, - Description: `Number of HTTP(S) requests for calculating the threshold.`, - }, - "interval_sec": { - Type: schema.TypeInt, - Optional: true, - Description: `Interval over which the threshold is computed.`, - }, - }, - }, - }, - "conform_action": { - Type: schema.TypeString, - Optional: true, - Description: `Action to take for requests that are under the configured rate limit threshold. -Valid option is "allow" only.`, - }, - "enforce_on_key": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"ALL", "IP", "HTTP_HEADER", "XFF_IP", "HTTP_COOKIE", "HTTP_PATH", "SNI", "REGION_CODE", "TLS_JA3_FINGERPRINT", "USER_IP", ""}), - Description: `Determines the key to enforce the rateLimitThreshold on. Possible values are: -* ALL: A single rate limit threshold is applied to all the requests matching this rule. This is the default value if "enforceOnKey" is not configured. -* IP: The source IP address of the request is the key. Each IP has this limit enforced separately. -* HTTP_HEADER: The value of the HTTP header whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the header value. If no such header is present in the request, the key type defaults to ALL. -* XFF_IP: The first IP address (i.e. the originating client IP address) specified in the list of IPs under X-Forwarded-For HTTP header. If no such header is present or the value is not a valid IP, the key defaults to the source IP address of the request i.e. key type IP. -* HTTP_COOKIE: The value of the HTTP cookie whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the cookie value. If no such cookie is present in the request, the key type defaults to ALL. -* HTTP_PATH: The URL path of the HTTP request. The key value is truncated to the first 128 bytes. -* SNI: Server name indication in the TLS session of the HTTPS request. The key value is truncated to the first 128 bytes. The key type defaults to ALL on a HTTP session. -* REGION_CODE: The country/region from which the request originates. -* TLS_JA3_FINGERPRINT: JA3 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or HTTP/3. If not available, the key type defaults to ALL. -* USER_IP: The IP address of the originating client, which is resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, the key type defaults to IP. Possible values: ["ALL", "IP", "HTTP_HEADER", "XFF_IP", "HTTP_COOKIE", "HTTP_PATH", "SNI", "REGION_CODE", "TLS_JA3_FINGERPRINT", "USER_IP"]`, - }, - "enforce_on_key_configs": { - Type: schema.TypeList, - Optional: true, - Description: `If specified, any combination of values of enforceOnKeyType/enforceOnKeyName is treated as the key on which ratelimit threshold/action is enforced. -You can specify up to 3 enforceOnKeyConfigs. -If enforceOnKeyConfigs is specified, enforceOnKey must not be specified.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enforce_on_key_name": { - Type: schema.TypeString, - Optional: true, - Description: `Rate limit key name applicable only for the following key types: -HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. -HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value.`, - }, - "enforce_on_key_type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"ALL", "IP", "HTTP_HEADER", "XFF_IP", "HTTP_COOKIE", "HTTP_PATH", "SNI", "REGION_CODE", "TLS_JA3_FINGERPRINT", "USER_IP", ""}), - Description: `Determines the key to enforce the rateLimitThreshold on. Possible values are: -* ALL: A single rate limit threshold is applied to all the requests matching this rule. This is the default value if "enforceOnKeyConfigs" is not configured. -* IP: The source IP address of the request is the key. Each IP has this limit enforced separately. -* HTTP_HEADER: The value of the HTTP header whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the header value. If no such header is present in the request, the key type defaults to ALL. -* XFF_IP: The first IP address (i.e. the originating client IP address) specified in the list of IPs under X-Forwarded-For HTTP header. If no such header is present or the value is not a valid IP, the key defaults to the source IP address of the request i.e. key type IP. -* HTTP_COOKIE: The value of the HTTP cookie whose name is configured under "enforceOnKeyName". The key value is truncated to the first 128 bytes of the cookie value. If no such cookie is present in the request, the key type defaults to ALL. -* HTTP_PATH: The URL path of the HTTP request. The key value is truncated to the first 128 bytes. -* SNI: Server name indication in the TLS session of the HTTPS request. The key value is truncated to the first 128 bytes. The key type defaults to ALL on a HTTP session. -* REGION_CODE: The country/region from which the request originates. -* TLS_JA3_FINGERPRINT: JA3 TLS/SSL fingerprint if the client connects using HTTPS, HTTP/2 or HTTP/3. If not available, the key type defaults to ALL. -* USER_IP: The IP address of the originating client, which is resolved based on "userIpRequestHeaders" configured with the security policy. If there is no "userIpRequestHeaders" configuration or an IP address cannot be resolved from it, the key type defaults to IP. Possible values: ["ALL", "IP", "HTTP_HEADER", "XFF_IP", "HTTP_COOKIE", "HTTP_PATH", "SNI", "REGION_CODE", "TLS_JA3_FINGERPRINT", "USER_IP"]`, - }, - }, - }, - }, - "enforce_on_key_name": { - Type: schema.TypeString, - Optional: true, - Description: `Rate limit key name applicable only for the following key types: -HTTP_HEADER -- Name of the HTTP header whose value is taken as the key value. -HTTP_COOKIE -- Name of the HTTP cookie whose value is taken as the key value.`, - }, - "exceed_action": { - Type: schema.TypeString, - Optional: true, - Description: `Action to take for requests that are above the configured rate limit threshold, to either deny with a specified HTTP response code, or redirect to a different endpoint. -Valid options are deny(STATUS), where valid values for STATUS are 403, 404, 429, and 502.`, - }, - "exceed_redirect_options": { - Type: schema.TypeList, - Optional: true, - Description: `Parameters defining the redirect action that is used as the exceed action. Cannot be specified if the exceed action is not redirect. This field is only supported in Global Security Policies of type CLOUD_ARMOR.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "target": { - Type: schema.TypeString, - Optional: true, - Description: `Target for the redirect action. This is required if the type is EXTERNAL_302 and cannot be specified for GOOGLE_RECAPTCHA.`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: `Type of the redirect action.`, - }, - }, - }, - }, - "rate_limit_threshold": { - Type: schema.TypeList, - Optional: true, - Description: `Threshold at which to begin ratelimiting.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "count": { - Type: schema.TypeInt, - Optional: true, - Description: `Number of HTTP(S) requests for calculating the threshold.`, - }, - "interval_sec": { - Type: schema.TypeInt, - Optional: true, - Description: `Interval over which the threshold is computed.`, - }, - }, - }, - }, - }, - }, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceComputeSecurityPolicyRuleCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandComputeSecurityPolicyRuleDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - priorityProp, err := expandComputeSecurityPolicyRulePriority(d.Get("priority"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("priority"); !tpgresource.IsEmptyValue(reflect.ValueOf(priorityProp)) && (ok || !reflect.DeepEqual(v, priorityProp)) { - obj["priority"] = priorityProp - } - matchProp, err := expandComputeSecurityPolicyRuleMatch(d.Get("match"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("match"); !tpgresource.IsEmptyValue(reflect.ValueOf(matchProp)) && (ok || !reflect.DeepEqual(v, matchProp)) { - obj["match"] = matchProp - } - preconfiguredWafConfigProp, err := expandComputeSecurityPolicyRulePreconfiguredWafConfig(d.Get("preconfigured_waf_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("preconfigured_waf_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(preconfiguredWafConfigProp)) && (ok || !reflect.DeepEqual(v, preconfiguredWafConfigProp)) { - obj["preconfiguredWafConfig"] = preconfiguredWafConfigProp - } - actionProp, err := expandComputeSecurityPolicyRuleAction(d.Get("action"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("action"); !tpgresource.IsEmptyValue(reflect.ValueOf(actionProp)) && (ok || !reflect.DeepEqual(v, actionProp)) { - obj["action"] = actionProp - } - rateLimitOptionsProp, err := expandComputeSecurityPolicyRuleRateLimitOptions(d.Get("rate_limit_options"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("rate_limit_options"); !tpgresource.IsEmptyValue(reflect.ValueOf(rateLimitOptionsProp)) && (ok || !reflect.DeepEqual(v, rateLimitOptionsProp)) { - obj["rateLimitOptions"] = rateLimitOptionsProp - } - previewProp, err := expandComputeSecurityPolicyRulePreview(d.Get("preview"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("preview"); !tpgresource.IsEmptyValue(reflect.ValueOf(previewProp)) && (ok || !reflect.DeepEqual(v, previewProp)) { - obj["preview"] = previewProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/securityPolicies/{{security_policy}}/addRule?priority={{priority}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new SecurityPolicyRule: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for SecurityPolicyRule: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating SecurityPolicyRule: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/global/securityPolicies/{{security_policy}}/priority/{{priority}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = ComputeOperationWaitTime( - config, res, project, "Creating SecurityPolicyRule", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create SecurityPolicyRule: %s", err) - } - - log.Printf("[DEBUG] Finished creating SecurityPolicyRule %q: %#v", d.Id(), res) - - return resourceComputeSecurityPolicyRuleRead(d, meta) -} - -func resourceComputeSecurityPolicyRuleRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/securityPolicies/{{security_policy}}/getRule?priority={{priority}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for SecurityPolicyRule: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeSecurityPolicyRule %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - - if err := d.Set("description", flattenComputeSecurityPolicyRuleDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - if err := d.Set("priority", flattenComputeSecurityPolicyRulePriority(res["priority"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - if err := d.Set("match", flattenComputeSecurityPolicyRuleMatch(res["match"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - if err := d.Set("preconfigured_waf_config", flattenComputeSecurityPolicyRulePreconfiguredWafConfig(res["preconfiguredWafConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - if err := d.Set("action", flattenComputeSecurityPolicyRuleAction(res["action"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - if err := d.Set("rate_limit_options", flattenComputeSecurityPolicyRuleRateLimitOptions(res["rateLimitOptions"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - if err := d.Set("preview", flattenComputeSecurityPolicyRulePreview(res["preview"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityPolicyRule: %s", err) - } - - return nil -} - -func resourceComputeSecurityPolicyRuleUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for SecurityPolicyRule: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandComputeSecurityPolicyRuleDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - priorityProp, err := expandComputeSecurityPolicyRulePriority(d.Get("priority"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("priority"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, priorityProp)) { - obj["priority"] = priorityProp - } - matchProp, err := expandComputeSecurityPolicyRuleMatch(d.Get("match"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("match"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, matchProp)) { - obj["match"] = matchProp - } - preconfiguredWafConfigProp, err := expandComputeSecurityPolicyRulePreconfiguredWafConfig(d.Get("preconfigured_waf_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("preconfigured_waf_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, preconfiguredWafConfigProp)) { - obj["preconfiguredWafConfig"] = preconfiguredWafConfigProp - } - actionProp, err := expandComputeSecurityPolicyRuleAction(d.Get("action"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("action"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, actionProp)) { - obj["action"] = actionProp - } - rateLimitOptionsProp, err := expandComputeSecurityPolicyRuleRateLimitOptions(d.Get("rate_limit_options"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("rate_limit_options"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, rateLimitOptionsProp)) { - obj["rateLimitOptions"] = rateLimitOptionsProp - } - previewProp, err := expandComputeSecurityPolicyRulePreview(d.Get("preview"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("preview"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, previewProp)) { - obj["preview"] = previewProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/securityPolicies/{{security_policy}}/patchRule?priority={{priority}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating SecurityPolicyRule %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("priority") { - updateMask = append(updateMask, "priority") - } - - if d.HasChange("match") { - updateMask = append(updateMask, "match") - } - - if d.HasChange("preconfigured_waf_config") { - updateMask = append(updateMask, "preconfiguredWafConfig") - } - - if d.HasChange("action") { - updateMask = append(updateMask, "action") - } - - if d.HasChange("rate_limit_options") { - updateMask = append(updateMask, "rateLimitOptions.rateLimitThreshold", - "rateLimitOptions.conformAction", - "rateLimitOptions.exceedRedirectOptions", - "rateLimitOptions.exceedAction", - "rateLimitOptions.enforceOnKey", - "rateLimitOptions.enforceOnKeyName", - "rateLimitOptions.enforceOnKeyConfigs", - "rateLimitOptions.banThreshold", - "rateLimitOptions.banDurationSec") - } - - if d.HasChange("preview") { - updateMask = append(updateMask, "preview") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating SecurityPolicyRule %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating SecurityPolicyRule %q: %#v", d.Id(), res) - } - - err = ComputeOperationWaitTime( - config, res, project, "Updating SecurityPolicyRule", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceComputeSecurityPolicyRuleRead(d, meta) -} - -func resourceComputeSecurityPolicyRuleDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for SecurityPolicyRule: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/securityPolicies/{{security_policy}}/removeRule?priority={{priority}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting SecurityPolicyRule %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "SecurityPolicyRule") - } - - err = ComputeOperationWaitTime( - config, res, project, "Deleting SecurityPolicyRule", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting SecurityPolicyRule %q: %#v", d.Id(), res) - return nil -} - -func resourceComputeSecurityPolicyRuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/global/securityPolicies/(?P[^/]+)/priority/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/global/securityPolicies/{{security_policy}}/priority/{{priority}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenComputeSecurityPolicyRuleDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePriority(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeSecurityPolicyRuleMatch(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["versioned_expr"] = - flattenComputeSecurityPolicyRuleMatchVersionedExpr(original["versionedExpr"], d, config) - transformed["expr"] = - flattenComputeSecurityPolicyRuleMatchExpr(original["expr"], d, config) - transformed["expr_options"] = - flattenComputeSecurityPolicyRuleMatchExprOptions(original["exprOptions"], d, config) - transformed["config"] = - flattenComputeSecurityPolicyRuleMatchConfig(original["config"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleMatchVersionedExpr(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleMatchExpr(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenComputeSecurityPolicyRuleMatchExprExpression(original["expression"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleMatchExprExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleMatchExprOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["recaptcha_options"] = - flattenComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptions(original["recaptchaOptions"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["action_token_site_keys"] = - flattenComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsActionTokenSiteKeys(original["actionTokenSiteKeys"], d, config) - transformed["session_token_site_keys"] = - flattenComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsSessionTokenSiteKeys(original["sessionTokenSiteKeys"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsActionTokenSiteKeys(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsSessionTokenSiteKeys(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleMatchConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["src_ip_ranges"] = - flattenComputeSecurityPolicyRuleMatchConfigSrcIpRanges(original["srcIpRanges"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleMatchConfigSrcIpRanges(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["exclusion"] = - flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusion(original["exclusions"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "request_header": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeader(original["requestHeadersToExclude"], d, config), - "request_cookie": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookie(original["requestCookiesToExclude"], d, config), - "request_uri": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUri(original["requestUrisToExclude"], d, config), - "request_query_param": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParam(original["requestQueryParamsToExclude"], d, config), - "target_rule_set": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleSet(original["targetRuleSet"], d, config), - "target_rule_ids": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleIds(original["targetRuleIds"], d, config), - }) - } - return transformed -} -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "operator": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderOperator(original["op"], d, config), - "value": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderValue(original["val"], d, config), - }) - } - return transformed -} -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderOperator(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookie(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "operator": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieOperator(original["op"], d, config), - "value": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieValue(original["val"], d, config), - }) - } - return transformed -} -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieOperator(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "operator": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriOperator(original["op"], d, config), - "value": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriValue(original["val"], d, config), - }) - } - return transformed -} -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriOperator(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParam(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "operator": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamOperator(original["op"], d, config), - "value": flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamValue(original["val"], d, config), - }) - } - return transformed -} -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamOperator(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleSet(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleIds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleAction(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["rate_limit_threshold"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsRateLimitThreshold(original["rateLimitThreshold"], d, config) - transformed["conform_action"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsConformAction(original["conformAction"], d, config) - transformed["exceed_redirect_options"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptions(original["exceedRedirectOptions"], d, config) - transformed["exceed_action"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsExceedAction(original["exceedAction"], d, config) - transformed["enforce_on_key"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKey(original["enforceOnKey"], d, config) - transformed["enforce_on_key_name"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyName(original["enforceOnKeyName"], d, config) - transformed["enforce_on_key_configs"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigs(original["enforceOnKeyConfigs"], d, config) - transformed["ban_threshold"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsBanThreshold(original["banThreshold"], d, config) - transformed["ban_duration_sec"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsBanDurationSec(original["banDurationSec"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleRateLimitOptionsRateLimitThreshold(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["count"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdCount(original["count"], d, config) - transformed["interval_sec"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdIntervalSec(original["intervalSec"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdIntervalSec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsConformAction(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["type"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsType(original["type"], d, config) - transformed["target"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsTarget(original["target"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsTarget(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsExceedAction(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "enforce_on_key_type": flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyType(original["enforceOnKeyType"], d, config), - "enforce_on_key_name": flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyName(original["enforceOnKeyName"], d, config), - }) - } - return transformed -} -func flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsBanThreshold(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["count"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsBanThresholdCount(original["count"], d, config) - transformed["interval_sec"] = - flattenComputeSecurityPolicyRuleRateLimitOptionsBanThresholdIntervalSec(original["intervalSec"], d, config) - return []interface{}{transformed} -} -func flattenComputeSecurityPolicyRuleRateLimitOptionsBanThresholdCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsBanThresholdIntervalSec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeSecurityPolicyRuleRateLimitOptionsBanDurationSec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenComputeSecurityPolicyRulePreview(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandComputeSecurityPolicyRuleDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePriority(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleMatch(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedVersionedExpr, err := expandComputeSecurityPolicyRuleMatchVersionedExpr(original["versioned_expr"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedVersionedExpr); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["versionedExpr"] = transformedVersionedExpr - } - - transformedExpr, err := expandComputeSecurityPolicyRuleMatchExpr(original["expr"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpr); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expr"] = transformedExpr - } - - transformedExprOptions, err := expandComputeSecurityPolicyRuleMatchExprOptions(original["expr_options"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExprOptions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["exprOptions"] = transformedExprOptions - } - - transformedConfig, err := expandComputeSecurityPolicyRuleMatchConfig(original["config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["config"] = transformedConfig - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleMatchVersionedExpr(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleMatchExpr(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandComputeSecurityPolicyRuleMatchExprExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleMatchExprExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleMatchExprOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedRecaptchaOptions, err := expandComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptions(original["recaptcha_options"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRecaptchaOptions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["recaptchaOptions"] = transformedRecaptchaOptions - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedActionTokenSiteKeys, err := expandComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsActionTokenSiteKeys(original["action_token_site_keys"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedActionTokenSiteKeys); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["actionTokenSiteKeys"] = transformedActionTokenSiteKeys - } - - transformedSessionTokenSiteKeys, err := expandComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsSessionTokenSiteKeys(original["session_token_site_keys"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSessionTokenSiteKeys); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sessionTokenSiteKeys"] = transformedSessionTokenSiteKeys - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsActionTokenSiteKeys(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleMatchExprOptionsRecaptchaOptionsSessionTokenSiteKeys(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleMatchConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSrcIpRanges, err := expandComputeSecurityPolicyRuleMatchConfigSrcIpRanges(original["src_ip_ranges"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSrcIpRanges); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["srcIpRanges"] = transformedSrcIpRanges - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleMatchConfigSrcIpRanges(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExclusion, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusion(original["exclusion"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExclusion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["exclusions"] = transformedExclusion - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedRequestHeader, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeader(original["request_header"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequestHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requestHeadersToExclude"] = transformedRequestHeader - } - - transformedRequestCookie, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookie(original["request_cookie"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequestCookie); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requestCookiesToExclude"] = transformedRequestCookie - } - - transformedRequestUri, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUri(original["request_uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequestUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requestUrisToExclude"] = transformedRequestUri - } - - transformedRequestQueryParam, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParam(original["request_query_param"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequestQueryParam); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requestQueryParamsToExclude"] = transformedRequestQueryParam - } - - transformedTargetRuleSet, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleSet(original["target_rule_set"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTargetRuleSet); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["targetRuleSet"] = transformedTargetRuleSet - } - - transformedTargetRuleIds, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleIds(original["target_rule_ids"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTargetRuleIds); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["targetRuleIds"] = transformedTargetRuleIds - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedOperator, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderOperator(original["operator"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOperator); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["op"] = transformedOperator - } - - transformedValue, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["val"] = transformedValue - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderOperator(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestHeaderValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookie(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedOperator, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieOperator(original["operator"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOperator); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["op"] = transformedOperator - } - - transformedValue, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["val"] = transformedValue - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieOperator(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestCookieValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedOperator, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriOperator(original["operator"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOperator); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["op"] = transformedOperator - } - - transformedValue, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["val"] = transformedValue - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriOperator(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestUriValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParam(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedOperator, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamOperator(original["operator"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOperator); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["op"] = transformedOperator - } - - transformedValue, err := expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["val"] = transformedValue - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamOperator(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionRequestQueryParamValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleSet(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreconfiguredWafConfigExclusionTargetRuleIds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedRateLimitThreshold, err := expandComputeSecurityPolicyRuleRateLimitOptionsRateLimitThreshold(original["rate_limit_threshold"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRateLimitThreshold); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["rateLimitThreshold"] = transformedRateLimitThreshold - } - - transformedConformAction, err := expandComputeSecurityPolicyRuleRateLimitOptionsConformAction(original["conform_action"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConformAction); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["conformAction"] = transformedConformAction - } - - transformedExceedRedirectOptions, err := expandComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptions(original["exceed_redirect_options"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExceedRedirectOptions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["exceedRedirectOptions"] = transformedExceedRedirectOptions - } - - transformedExceedAction, err := expandComputeSecurityPolicyRuleRateLimitOptionsExceedAction(original["exceed_action"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExceedAction); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["exceedAction"] = transformedExceedAction - } - - transformedEnforceOnKey, err := expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKey(original["enforce_on_key"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnforceOnKey); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enforceOnKey"] = transformedEnforceOnKey - } - - transformedEnforceOnKeyName, err := expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyName(original["enforce_on_key_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnforceOnKeyName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enforceOnKeyName"] = transformedEnforceOnKeyName - } - - transformedEnforceOnKeyConfigs, err := expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigs(original["enforce_on_key_configs"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnforceOnKeyConfigs); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enforceOnKeyConfigs"] = transformedEnforceOnKeyConfigs - } - - transformedBanThreshold, err := expandComputeSecurityPolicyRuleRateLimitOptionsBanThreshold(original["ban_threshold"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBanThreshold); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["banThreshold"] = transformedBanThreshold - } - - transformedBanDurationSec, err := expandComputeSecurityPolicyRuleRateLimitOptionsBanDurationSec(original["ban_duration_sec"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBanDurationSec); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["banDurationSec"] = transformedBanDurationSec - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsRateLimitThreshold(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCount, err := expandComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdCount(original["count"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["count"] = transformedCount - } - - transformedIntervalSec, err := expandComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdIntervalSec(original["interval_sec"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedIntervalSec); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["intervalSec"] = transformedIntervalSec - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsRateLimitThresholdIntervalSec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsConformAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedType, err := expandComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - transformedTarget, err := expandComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsTarget(original["target"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTarget); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["target"] = transformedTarget - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsExceedRedirectOptionsTarget(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsExceedAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKey(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEnforceOnKeyType, err := expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyType(original["enforce_on_key_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnforceOnKeyType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enforceOnKeyType"] = transformedEnforceOnKeyType - } - - transformedEnforceOnKeyName, err := expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyName(original["enforce_on_key_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnforceOnKeyName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enforceOnKeyName"] = transformedEnforceOnKeyName - } - - req = append(req, transformed) - } - return req, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsEnforceOnKeyConfigsEnforceOnKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsBanThreshold(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCount, err := expandComputeSecurityPolicyRuleRateLimitOptionsBanThresholdCount(original["count"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["count"] = transformedCount - } - - transformedIntervalSec, err := expandComputeSecurityPolicyRuleRateLimitOptionsBanThresholdIntervalSec(original["interval_sec"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedIntervalSec); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["intervalSec"] = transformedIntervalSec - } - - return transformed, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsBanThresholdCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsBanThresholdIntervalSec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRuleRateLimitOptionsBanDurationSec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandComputeSecurityPolicyRulePreview(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy_rule_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy_rule_sweeper.go deleted file mode 100644 index e245c5fedba..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_security_policy_rule_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package compute - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("ComputeSecurityPolicyRule", testSweepComputeSecurityPolicyRule) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepComputeSecurityPolicyRule(region string) error { - resourceName := "ComputeSecurityPolicyRule" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/securityPolicies/{{security_policy}}", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["securityPolicyRules"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/securityPolicies/{{security_policy}}/removeRule?priority={{priority}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_service_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_service_attachment.go index 80b164f1f73..92c34d02ab7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_service_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_service_attachment.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "time" @@ -351,7 +350,6 @@ func resourceComputeServiceAttachmentCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -360,7 +358,6 @@ func resourceComputeServiceAttachmentCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServiceAttachment: %s", err) @@ -413,14 +410,12 @@ func resourceComputeServiceAttachmentRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeServiceAttachment %q", d.Id())) @@ -557,7 +552,6 @@ func resourceComputeServiceAttachmentUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating ServiceAttachment %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -572,7 +566,6 @@ func resourceComputeServiceAttachmentUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -619,8 +612,6 @@ func resourceComputeServiceAttachmentDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServiceAttachment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -630,7 +621,6 @@ func resourceComputeServiceAttachmentDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServiceAttachment") @@ -901,6 +891,7 @@ func expandComputeServiceAttachmentRegion(v interface{}, d tpgresource.Terraform } func resourceComputeServiceAttachmentUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { + // need to send value in PATCH due to validation bug on api b/198329756 nameProp := d.Get("name") if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, nameProp)) { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_snapshot.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_snapshot.go index d5d234fe5bd..c24cac3316c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_snapshot.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_snapshot.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -227,7 +226,8 @@ can be because the original image had licenses attached (such as a Windows image). snapshotEncryptionKey nested object Encrypts the snapshot using a customer-supplied encryption key.`, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, }, }, "snapshot_id": { @@ -352,8 +352,6 @@ func resourceComputeSnapshotCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - url = regexp.MustCompile("PRE_CREATE_REPLACE_ME").ReplaceAllLiteralString(url, sourceDiskProp.(string)) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -363,7 +361,6 @@ func resourceComputeSnapshotCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Snapshot: %s", err) @@ -416,14 +413,12 @@ func resourceComputeSnapshotRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeSnapshot %q", d.Id())) @@ -535,8 +530,6 @@ func resourceComputeSnapshotUpdate(d *schema.ResourceData, meta interface{}) err return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -550,7 +543,6 @@ func resourceComputeSnapshotUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Snapshot %q: %s", d.Id(), err) @@ -598,8 +590,6 @@ func resourceComputeSnapshotDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Snapshot %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -609,7 +599,6 @@ func resourceComputeSnapshotDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Snapshot") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_certificate.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_certificate.go index a8bde8eb789..1e052cbff6e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_certificate.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_certificate.go @@ -20,12 +20,11 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -66,7 +65,7 @@ The chain must include at least one intermediate cert.`, Type: schema.TypeString, Required: true, ForceNew: true, - DiffSuppressFunc: sha256DiffSuppress, + DiffSuppressFunc: tpgresource.Sha256DiffSuppress, Description: `The write-only private key in PEM format.`, Sensitive: true, }, @@ -90,6 +89,7 @@ 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. + These are in the same namespace as the managed SSL certificates.`, }, "certificate_id": { @@ -192,7 +192,6 @@ func resourceComputeSslCertificateCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -201,7 +200,6 @@ func resourceComputeSslCertificateCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SslCertificate: %s", err) @@ -254,14 +252,12 @@ func resourceComputeSslCertificateRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeSslCertificate %q", d.Id())) @@ -323,8 +319,6 @@ func resourceComputeSslCertificateDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting SslCertificate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -334,7 +328,6 @@ func resourceComputeSslCertificateDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SslCertificate") @@ -422,9 +415,9 @@ func expandComputeSslCertificateName(v interface{}, d tpgresource.TerraformResou if v, ok := d.GetOk("name"); ok { certName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - certName = id.PrefixedUniqueId(v.(string)) + certName = resource.PrefixedUniqueId(v.(string)) } else { - certName = id.UniqueId() + certName = resource.UniqueId() } // We need to get the {{name}} into schema to set the ID using tpgresource.ReplaceVars diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_policy.go index 3e289d1e460..b0b9f9515cc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_ssl_policy.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -228,7 +227,6 @@ func resourceComputeSslPolicyCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -237,7 +235,6 @@ func resourceComputeSslPolicyCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SslPolicy: %s", err) @@ -290,14 +287,12 @@ func resourceComputeSslPolicyRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeSslPolicy %q", d.Id())) @@ -384,7 +379,6 @@ func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating SslPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -399,7 +393,6 @@ func resourceComputeSslPolicyUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -446,8 +439,6 @@ func resourceComputeSslPolicyDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting SslPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -457,7 +448,6 @@ func resourceComputeSslPolicyDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SslPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_subnetwork.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_subnetwork.go index 71f30340b0c..8065bd7c898 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_subnetwork.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_subnetwork.go @@ -22,7 +22,6 @@ import ( "fmt" "log" "net" - "net/http" "reflect" "time" @@ -482,7 +481,6 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -491,7 +489,6 @@ func resourceComputeSubnetworkCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Subnetwork: %s", err) @@ -544,14 +541,12 @@ func resourceComputeSubnetworkRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeSubnetwork %q", d.Id())) @@ -654,8 +649,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -669,7 +662,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) @@ -699,8 +691,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -714,7 +704,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) @@ -779,8 +768,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -794,7 +781,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) @@ -847,8 +833,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -862,7 +846,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) @@ -915,8 +898,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -930,7 +911,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) @@ -983,8 +963,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -998,7 +976,6 @@ func resourceComputeSubnetworkUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Subnetwork %q: %s", d.Id(), err) @@ -1046,8 +1023,6 @@ func resourceComputeSubnetworkDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Subnetwork %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1057,7 +1032,6 @@ func resourceComputeSubnetworkDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Subnetwork") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_grpc_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_grpc_proxy.go index d09ce63a223..6cdaea5404d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_grpc_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_grpc_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -188,7 +187,6 @@ func resourceComputeTargetGrpcProxyCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -197,7 +195,6 @@ func resourceComputeTargetGrpcProxyCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetGrpcProxy: %s", err) @@ -250,14 +247,12 @@ func resourceComputeTargetGrpcProxyRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeTargetGrpcProxy %q", d.Id())) @@ -330,7 +325,6 @@ func resourceComputeTargetGrpcProxyUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating TargetGrpcProxy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -345,7 +339,6 @@ func resourceComputeTargetGrpcProxyUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -392,8 +385,6 @@ func resourceComputeTargetGrpcProxyDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetGrpcProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -403,7 +394,6 @@ func resourceComputeTargetGrpcProxyDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetGrpcProxy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_http_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_http_proxy.go index 027890a208f..5def200f988 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_http_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_http_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -180,7 +179,6 @@ func resourceComputeTargetHttpProxyCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -189,7 +187,6 @@ func resourceComputeTargetHttpProxyCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetHttpProxy: %s", err) @@ -242,14 +239,12 @@ func resourceComputeTargetHttpProxyRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeTargetHttpProxy %q", d.Id())) @@ -319,8 +314,6 @@ func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -334,7 +327,6 @@ func resourceComputeTargetHttpProxyUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetHttpProxy %q: %s", d.Id(), err) @@ -382,8 +374,6 @@ func resourceComputeTargetHttpProxyDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetHttpProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -393,7 +383,6 @@ func resourceComputeTargetHttpProxyDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetHttpProxy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_https_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_https_proxy.go index 7a4ebe74f7e..3c9693e2372 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_https_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_https_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -80,8 +79,7 @@ to the BackendService.`, Optional: true, DiffSuppressFunc: tpgresource.CompareResourceNames, Description: `URLs to certificate manager certificate resources that are used to authenticate connections between users and the load balancer. -Certificate manager certificates only apply when the load balancing scheme is set to INTERNAL_MANAGED. -For EXTERNAL and EXTERNAL_MANAGED, use certificate_map instead. +Currently, you may specify up to 15 certificates. Certificate manager certificates do not apply when the load balancing scheme is set to INTERNAL_SELF_MANAGED. sslCertificates and certificateManagerCertificates fields can not be defined together. Accepted format is '//certificatemanager.googleapis.com/projects/{project}/locations/{location}/certificates/{resourceName}' or just the self_link 'projects/{project}/locations/{location}/certificates/{resourceName}'`, Elem: &schema.Schema{ @@ -93,8 +91,7 @@ Accepted format is '//certificatemanager.googleapis.com/projects/{project}/locat Type: schema.TypeString, Optional: true, Description: `A reference to the CertificateMap resource uri that identifies a certificate map -associated with the given target proxy. This field is only supported for EXTERNAL and EXTERNAL_MANAGED load balancing schemes. -For INTERNAL_MANAGED, use certificate_manager_certificates instead. +associated with the given target proxy. This field can only be set for global target proxies. Accepted format is '//certificatemanager.googleapis.com/projects/{project}/locations/{location}/certificateMaps/{resourceName}'.`, }, "description": { @@ -166,17 +163,6 @@ sslCertificates and certificateManagerCertificates can not be defined together.` Description: `A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy resource. If not set, the TargetHttpsProxy resource will not have any SSL policy configured.`, - }, - "tls_early_data": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"STRICT", "PERMISSIVE", "DISABLED", ""}), - Description: `Specifies whether TLS 1.3 0-RTT Data (“Early Data”) should be accepted for this service. -Early Data allows a TLS resumption handshake to include the initial application payload -(a HTTP request) alongside the handshake, reducing the effective round trips to “zero”. -This applies to TLS 1.3 connections over TCP (HTTP/2) as well as over UDP (QUIC/h3). Possible values: ["STRICT", "PERMISSIVE", "DISABLED"]`, }, "creation_timestamp": { Type: schema.TypeString, @@ -229,12 +215,6 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac } else if v, ok := d.GetOkExists("quic_override"); !tpgresource.IsEmptyValue(reflect.ValueOf(quicOverrideProp)) && (ok || !reflect.DeepEqual(v, quicOverrideProp)) { obj["quicOverride"] = quicOverrideProp } - tlsEarlyDataProp, err := expandComputeTargetHttpsProxyTlsEarlyData(d.Get("tls_early_data"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("tls_early_data"); !tpgresource.IsEmptyValue(reflect.ValueOf(tlsEarlyDataProp)) && (ok || !reflect.DeepEqual(v, tlsEarlyDataProp)) { - obj["tlsEarlyData"] = tlsEarlyDataProp - } certificateManagerCertificatesProp, err := expandComputeTargetHttpsProxyCertificateManagerCertificates(d.Get("certificate_manager_certificates"), d, config) if err != nil { return err @@ -308,7 +288,6 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -317,7 +296,6 @@ func resourceComputeTargetHttpsProxyCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetHttpsProxy: %s", err) @@ -370,14 +348,12 @@ func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeTargetHttpsProxy %q", d.Id())) @@ -414,9 +390,6 @@ func resourceComputeTargetHttpsProxyRead(d *schema.ResourceData, meta interface{ if err := d.Set("quic_override", flattenComputeTargetHttpsProxyQuicOverride(res["quicOverride"], d, config)); err != nil { return fmt.Errorf("Error reading TargetHttpsProxy: %s", err) } - if err := d.Set("tls_early_data", flattenComputeTargetHttpsProxyTlsEarlyData(res["tlsEarlyData"], d, config)); err != nil { - return fmt.Errorf("Error reading TargetHttpsProxy: %s", err) - } if err := d.Set("certificate_manager_certificates", flattenComputeTargetHttpsProxyCertificateManagerCertificates(res["certificateManagerCertificates"], d, config)); err != nil { return fmt.Errorf("Error reading TargetHttpsProxy: %s", err) } @@ -475,18 +448,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac obj["quicOverride"] = quicOverrideProp } - obj, err = resourceComputeTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies/{{name}}/setQuicOverride") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -500,7 +466,6 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) @@ -531,18 +496,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac obj["sslCertificates"] = sslCertificatesProp } - obj, err = resourceComputeTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/targetHttpsProxies/{{name}}/setSslCertificates") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -556,7 +514,6 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) @@ -581,18 +538,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac obj["certificateMap"] = certificateMapProp } - obj, err = resourceComputeTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies/{{name}}/setCertificateMap") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -606,7 +556,6 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) @@ -631,18 +580,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac obj["sslPolicy"] = sslPolicyProp } - obj, err = resourceComputeTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/global/targetHttpsProxies/{{name}}/setSslPolicy") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -656,7 +598,6 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) @@ -681,18 +622,11 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac obj["urlMap"] = urlMapProp } - obj, err = resourceComputeTargetHttpsProxyUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}projects/{{project}}/targetHttpsProxies/{{name}}/setUrlMap") if err != nil { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -706,7 +640,6 @@ func resourceComputeTargetHttpsProxyUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetHttpsProxy %q: %s", d.Id(), err) @@ -754,8 +687,6 @@ func resourceComputeTargetHttpsProxyDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetHttpsProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -765,7 +696,6 @@ func resourceComputeTargetHttpsProxyDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetHttpsProxy") @@ -840,10 +770,6 @@ func flattenComputeTargetHttpsProxyQuicOverride(v interface{}, d *schema.Resourc return v } -func flattenComputeTargetHttpsProxyTlsEarlyData(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenComputeTargetHttpsProxyCertificateManagerCertificates(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -913,10 +839,6 @@ func expandComputeTargetHttpsProxyQuicOverride(v interface{}, d tpgresource.Terr return v, nil } -func expandComputeTargetHttpsProxyTlsEarlyData(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandComputeTargetHttpsProxyCertificateManagerCertificates(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { if v == nil { return nil, nil @@ -1003,19 +925,6 @@ func resourceComputeTargetHttpsProxyEncoder(d *schema.ResourceData, meta interfa return obj, nil } -func resourceComputeTargetHttpsProxyUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - - if _, ok := obj["certificateManagerCertificates"]; ok { - // The field certificateManagerCertificates should not be included in the API request, and it should be renamed to `sslCertificates` - // The API does not allow using both certificate manager certificates and sslCertificates. If that changes - // in the future, the encoder logic should change accordingly because this will mean that both fields are no longer mutual exclusive. - log.Printf("[DEBUG] converting the field CertificateManagerCertificates to sslCertificates before sending the request") - obj["sslCertificates"] = obj["certificateManagerCertificates"] - delete(obj, "certificateManagerCertificates") - } - return obj, nil -} - func resourceComputeTargetHttpsProxyDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { // Since both sslCertificates and certificateManagerCertificates maps to the same API field (sslCertificates), we need to check the types // of certificates that exist in the array and decide whether to change the field to certificateManagerCertificate or not. diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_instance.go index 1830da5d60f..9639c6f408a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_instance.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -178,7 +177,6 @@ func resourceComputeTargetInstanceCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -187,7 +185,6 @@ func resourceComputeTargetInstanceCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetInstance: %s", err) @@ -240,14 +237,12 @@ func resourceComputeTargetInstanceRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeTargetInstance %q", d.Id())) @@ -309,8 +304,6 @@ func resourceComputeTargetInstanceDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetInstance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -320,7 +313,6 @@ func resourceComputeTargetInstanceDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetInstance") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_pool_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_pool_sweeper.go deleted file mode 100644 index b781a2e0587..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_pool_sweeper.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package compute - -import ( - "context" - "log" - - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" -) - -// This will sweep GCE Target Pool resources -func init() { - sweeper.AddTestSweepers("ComputeTargetPool", testSweepTargetPool) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepTargetPool(region string) error { - resourceName := "ComputeTargetPool" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - found, err := config.NewComputeClient(config.UserAgent).TargetPools.AggregatedList(config.Project).Do() - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request: %s", err) - return nil - } - - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for zone, itemList := range found.Items { - for _, tp := range itemList.TargetPools { - if !sweeper.IsSweepableTestResource(tp.Name) { - nonPrefixCount++ - continue - } - - // Don't wait on operations as we may have a lot to delete - _, err := config.NewComputeClient(config.UserAgent).TargetPools.Delete(config.Project, tpgresource.GetResourceNameFromSelfLink(zone), tp.Name).Do() - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting %s resource %s : %s", resourceName, tp.Name, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, tp.Name) - } - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_ssl_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_ssl_proxy.go index 4b182f1735f..98cc7b17ba8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_ssl_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_ssl_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -209,7 +208,6 @@ func resourceComputeTargetSslProxyCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -218,7 +216,6 @@ func resourceComputeTargetSslProxyCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetSslProxy: %s", err) @@ -271,14 +268,12 @@ func resourceComputeTargetSslProxyRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeTargetSslProxy %q", d.Id())) @@ -354,8 +349,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -369,7 +362,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) @@ -399,8 +391,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -414,7 +404,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) @@ -444,8 +433,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -459,7 +446,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) @@ -489,8 +475,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -504,7 +488,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) @@ -534,8 +517,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -549,7 +530,6 @@ func resourceComputeTargetSslProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetSslProxy %q: %s", d.Id(), err) @@ -597,8 +577,6 @@ func resourceComputeTargetSslProxyDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetSslProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -608,7 +586,6 @@ func resourceComputeTargetSslProxyDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetSslProxy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_tcp_proxy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_tcp_proxy.go index cecc4a4ce68..2bebef16a38 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_tcp_proxy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_target_tcp_proxy.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -177,7 +176,6 @@ func resourceComputeTargetTcpProxyCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -186,7 +184,6 @@ func resourceComputeTargetTcpProxyCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TargetTcpProxy: %s", err) @@ -239,14 +236,12 @@ func resourceComputeTargetTcpProxyRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeTargetTcpProxy %q", d.Id())) @@ -316,8 +311,6 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -331,7 +324,6 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetTcpProxy %q: %s", d.Id(), err) @@ -361,8 +353,6 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -376,7 +366,6 @@ func resourceComputeTargetTcpProxyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating TargetTcpProxy %q: %s", d.Id(), err) @@ -424,8 +413,6 @@ func resourceComputeTargetTcpProxyDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TargetTcpProxy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -435,7 +422,6 @@ func resourceComputeTargetTcpProxyDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TargetTcpProxy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_url_map.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_url_map.go index 2294eae9203..a218f7673ad 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_url_map.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_url_map.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -1552,7 +1551,7 @@ less than one second are represented with a 0 'seconds' field and a positive * 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, -for example: disconnects, reset, read timeout, connection failure, and refused +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. @@ -2412,7 +2411,7 @@ less than one second are represented with a 0 'seconds' field and a positive * 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, - for example: disconnects, reset, read timeout, connection failure, and refused + 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. @@ -2889,7 +2888,6 @@ func resourceComputeUrlMapCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -2898,7 +2896,6 @@ func resourceComputeUrlMapCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating UrlMap: %s", err) @@ -2951,14 +2948,12 @@ func resourceComputeUrlMapRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeUrlMap %q", d.Id())) @@ -3094,7 +3089,6 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating UrlMap %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -3109,7 +3103,6 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -3156,8 +3149,6 @@ func resourceComputeUrlMapDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting UrlMap %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -3167,7 +3158,6 @@ func resourceComputeUrlMapDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "UrlMap") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_gateway.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_gateway.go index a837f99ced8..d1500476960 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_gateway.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_gateway.go @@ -20,7 +20,6 @@ package compute import ( "fmt" "log" - "net/http" "reflect" "time" @@ -161,7 +160,6 @@ func resourceComputeVpnGatewayCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -170,7 +168,6 @@ func resourceComputeVpnGatewayCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VpnGateway: %s", err) @@ -223,14 +220,12 @@ func resourceComputeVpnGatewayRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeVpnGateway %q", d.Id())) @@ -292,8 +287,6 @@ func resourceComputeVpnGatewayDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting VpnGateway %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -303,7 +296,6 @@ func resourceComputeVpnGatewayDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VpnGateway") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_tunnel.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_tunnel.go index 9ada67b24ba..1c74131cedf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_tunnel.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/compute/resource_compute_vpn_tunnel.go @@ -22,7 +22,6 @@ import ( "fmt" "log" "net" - "net/http" "reflect" "strings" "time" @@ -490,7 +489,6 @@ func resourceComputeVpnTunnelCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -499,7 +497,6 @@ func resourceComputeVpnTunnelCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VpnTunnel: %s", err) @@ -612,14 +609,12 @@ func resourceComputeVpnTunnelRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ComputeVpnTunnel %q", d.Id())) @@ -740,8 +735,6 @@ func resourceComputeVpnTunnelUpdate(d *schema.ResourceData, meta interface{}) er return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -755,7 +748,6 @@ func resourceComputeVpnTunnelUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating VpnTunnel %q: %s", d.Id(), err) @@ -803,8 +795,6 @@ func resourceComputeVpnTunnelDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting VpnTunnel %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -814,7 +804,6 @@ func resourceComputeVpnTunnelDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VpnTunnel") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/node_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/node_config.go index 241355bbbaa..2c168f55b3e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/node_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/node_config.go @@ -21,56 +21,6 @@ var defaultOauthScopes = []string{ "https://www.googleapis.com/auth/trace.append", } -func schemaContainerdConfig() *schema.Schema { - return &schema.Schema{ - Type: schema.TypeList, - Optional: true, - Description: "Parameters for containerd configuration.", - MaxItems: 1, - Elem: &schema.Resource{Schema: map[string]*schema.Schema{ - "private_registry_access_config": { - Type: schema.TypeList, - Optional: true, - Description: "Parameters for private container registries configuration.", - MaxItems: 1, - Elem: &schema.Resource{Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Required: true, - Description: "Whether or not private registries are configured.", - }, - "certificate_authority_domain_config": { - Type: schema.TypeList, - Optional: true, - Description: "Parameters for configuring CA certificate and domains.", - Elem: &schema.Resource{Schema: map[string]*schema.Schema{ - "fqdns": { - Type: schema.TypeList, - Required: true, - Description: "List of fully-qualified-domain-names. IPv4s and port specification are supported.", - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "gcp_secret_manager_certificate_config": { - Type: schema.TypeList, - Required: true, - Description: "Parameters for configuring a certificate hosted in GCP SecretManager.", - MaxItems: 1, - Elem: &schema.Resource{Schema: map[string]*schema.Schema{ - "secret_uri": { - Type: schema.TypeString, - Required: true, - Description: "URI for the secret that hosts a certificate. Must be in the format 'projects/PROJECT_NUM/secrets/SECRET_NAME/versions/VERSION_OR_LATEST'.", - }, - }}, - }, - }}, - }, - }}, - }, - }}, - } -} - func schemaLoggingVariant() *schema.Schema { return &schema.Schema{ Type: schema.TypeString, @@ -111,7 +61,6 @@ func schemaNodeConfig() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "containerd_config": schemaContainerdConfig(), "disk_size_gb": { Type: schema.TypeInt, Optional: true, @@ -277,30 +226,6 @@ func schemaNodeConfig() *schema.Schema { }, }, - "secondary_boot_disks": { - Type: schema.TypeList, - Optional: true, - MaxItems: 127, - Description: `Secondary boot disks for preloading data or container images.`, - ForceNew: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "disk_image": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Disk image to create the secondary boot disk from`, - }, - "mode": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Mode for how the secondary boot disk is used.`, - }, - }, - }, - }, - "gcfs_config": schemaGcfsConfig(true), "gvnic": { @@ -605,12 +530,6 @@ func schemaNodeConfig() *schema.Schema { ForceNew: true, Description: `The number of threads per physical core. To disable simultaneous multithreading (SMT) set this to 1. If unset, the maximum number of threads supported per core by the underlying processor is assumed.`, }, - "enable_nested_virtualization": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Whether the node should have nested virtualization enabled.`, - }, }, }, }, @@ -730,7 +649,6 @@ func expandNodeConfigDefaults(configured interface{}) *container.NodeConfigDefau config := configs[0].(map[string]interface{}) nodeConfigDefaults := &container.NodeConfigDefaults{} - nodeConfigDefaults.ContainerdConfig = expandContainerdConfig(config["containerd_config"]) if variant, ok := config["logging_variant"]; ok { nodeConfigDefaults.LoggingConfig = &container.NodePoolLoggingConfig{ VariantConfig: &container.LoggingVariantConfig{ @@ -753,10 +671,6 @@ func expandNodeConfig(v interface{}) *container.NodeConfig { nodeConfig := nodeConfigs[0].(map[string]interface{}) - if v, ok := nodeConfig["containerd_config"]; ok { - nc.ContainerdConfig = expandContainerdConfig(v) - } - if v, ok := nodeConfig["machine_type"]; ok { nc.MachineType = v.(string) } @@ -829,28 +743,6 @@ func expandNodeConfig(v interface{}) *container.NodeConfig { } } - if v, ok := nodeConfig["secondary_boot_disks"]; ok && len(v.([]interface{})) > 0 { - conf, confOK := v.([]interface{})[0].(map[string]interface{}) - if confOK { - modeValue, modeOK := conf["mode"] - diskImage := conf["disk_image"].(string) - if modeOK { - nc.SecondaryBootDisks = append(nc.SecondaryBootDisks, &container.SecondaryBootDisk{ - DiskImage: diskImage, - Mode: modeValue.(string), - }) - } else { - nc.SecondaryBootDisks = append(nc.SecondaryBootDisks, &container.SecondaryBootDisk{ - DiskImage: diskImage, - }) - } - } else { - nc.SecondaryBootDisks = append(nc.SecondaryBootDisks, &container.SecondaryBootDisk{ - DiskImage: "", - }) - } - } - if v, ok := nodeConfig["gcfs_config"]; ok && len(v.([]interface{})) > 0 { conf := v.([]interface{})[0].(map[string]interface{}) nc.GcfsConfig = &container.GcfsConfig{ @@ -1002,8 +894,7 @@ func expandNodeConfig(v interface{}) *container.NodeConfig { if v, ok := nodeConfig["advanced_machine_features"]; ok && len(v.([]interface{})) > 0 { advanced_machine_features := v.([]interface{})[0].(map[string]interface{}) nc.AdvancedMachineFeatures = &container.AdvancedMachineFeatures{ - ThreadsPerCore: int64(advanced_machine_features["threads_per_core"].(int)), - EnableNestedVirtualization: advanced_machine_features["enable_nested_virtualization"].(bool), + ThreadsPerCore: int64(advanced_machine_features["threads_per_core"].(int)), } } @@ -1127,92 +1018,6 @@ func expandCgroupMode(cfg map[string]interface{}) string { return cgroupMode.(string) } -func expandContainerdConfig(v interface{}) *container.ContainerdConfig { - if v == nil { - return nil - } - ls := v.([]interface{}) - if len(ls) == 0 { - return nil - } - if ls[0] == nil { - return &container.ContainerdConfig{} - } - cfg := ls[0].(map[string]interface{}) - - cc := &container.ContainerdConfig{} - cc.PrivateRegistryAccessConfig = expandPrivateRegistryAccessConfig(cfg["private_registry_access_config"]) - return cc -} - -func expandPrivateRegistryAccessConfig(v interface{}) *container.PrivateRegistryAccessConfig { - if v == nil { - return nil - } - ls := v.([]interface{}) - if len(ls) == 0 { - return nil - } - if ls[0] == nil { - return &container.PrivateRegistryAccessConfig{} - } - cfg := ls[0].(map[string]interface{}) - - pracc := &container.PrivateRegistryAccessConfig{} - if enabled, ok := cfg["enabled"]; ok { - pracc.Enabled = enabled.(bool) - } - if caCfgRaw, ok := cfg["certificate_authority_domain_config"]; ok { - ls := caCfgRaw.([]interface{}) - pracc.CertificateAuthorityDomainConfig = make([]*container.CertificateAuthorityDomainConfig, len(ls)) - for i, caCfg := range ls { - pracc.CertificateAuthorityDomainConfig[i] = expandCADomainConfig(caCfg) - } - } - - return pracc -} - -func expandCADomainConfig(v interface{}) *container.CertificateAuthorityDomainConfig { - if v == nil { - return nil - } - cfg := v.(map[string]interface{}) - - caConfig := &container.CertificateAuthorityDomainConfig{} - if v, ok := cfg["fqdns"]; ok { - fqdns := v.([]interface{}) - caConfig.Fqdns = make([]string, len(fqdns)) - for i, dn := range fqdns { - caConfig.Fqdns[i] = dn.(string) - } - } - - caConfig.GcpSecretManagerCertificateConfig = expandGCPSecretManagerCertificateConfig(cfg["gcp_secret_manager_certificate_config"]) - - return caConfig -} - -func expandGCPSecretManagerCertificateConfig(v interface{}) *container.GCPSecretManagerCertificateConfig { - if v == nil { - return nil - } - ls := v.([]interface{}) - if len(ls) == 0 { - return nil - } - if ls[0] == nil { - return &container.GCPSecretManagerCertificateConfig{} - } - cfg := ls[0].(map[string]interface{}) - - gcpSMConfig := &container.GCPSecretManagerCertificateConfig{} - if v, ok := cfg["secret_uri"]; ok { - gcpSMConfig.SecretUri = v.(string) - } - return gcpSMConfig -} - func expandSoleTenantConfig(v interface{}) *container.SoleTenantConfig { if v == nil { return nil @@ -1261,8 +1066,6 @@ func flattenNodeConfigDefaults(c *container.NodeConfigDefaults) []map[string]int result = append(result, map[string]interface{}{}) - result[0]["containerd_config"] = flattenContainerdConfig(c.ContainerdConfig) - result[0]["logging_variant"] = flattenLoggingVariant(c.LoggingConfig) return result @@ -1288,7 +1091,6 @@ func flattenNodeConfig(c *container.NodeConfig, v interface{}) []map[string]inte config = append(config, map[string]interface{}{ "machine_type": c.MachineType, - "containerd_config": flattenContainerdConfig(c.ContainerdConfig), "disk_size_gb": c.DiskSizeGb, "disk_type": c.DiskType, "guest_accelerator": flattenContainerGuestAccelerators(c.Accelerators), @@ -1306,7 +1108,6 @@ func flattenNodeConfig(c *container.NodeConfig, v interface{}) []map[string]inte "resource_labels": c.ResourceLabels, "tags": c.Tags, "preemptible": c.Preemptible, - "secondary_boot_disks": flattenSecondaryBootDisks(c.SecondaryBootDisks), "spot": c.Spot, "min_cpu_platform": c.MinCpuPlatform, "shielded_instance_config": flattenShieldedInstanceConfig(c.ShieldedInstanceConfig), @@ -1339,6 +1140,7 @@ func flattenResourceManagerTags(c *container.ResourceManagerTags) map[string]int for k, v := range c.Tags { rmt[k] = v } + } return rmt @@ -1348,8 +1150,7 @@ func flattenAdvancedMachineFeaturesConfig(c *container.AdvancedMachineFeatures) result := []map[string]interface{}{} if c != nil { result = append(result, map[string]interface{}{ - "threads_per_core": c.ThreadsPerCore, - "enable_nested_virtualization": c.EnableNestedVirtualization, + "threads_per_core": c.ThreadsPerCore, }) } return result @@ -1414,20 +1215,6 @@ func flattenEphemeralStorageLocalSsdConfig(c *container.EphemeralStorageLocalSsd return result } -func flattenSecondaryBootDisks(c []*container.SecondaryBootDisk) []map[string]interface{} { - result := []map[string]interface{}{} - if c != nil { - for _, disk := range c { - secondaryBootDisk := map[string]interface{}{ - "disk_image": disk.DiskImage, - "mode": disk.Mode, - } - result = append(result, secondaryBootDisk) - } - } - return result -} - func flattenLoggingVariant(c *container.NodePoolLoggingConfig) string { variant := "DEFAULT" if c != nil && c.VariantConfig != nil && c.VariantConfig.Variant != "" { @@ -1539,74 +1326,6 @@ func flattenLinuxNodeConfig(c *container.LinuxNodeConfig) []map[string]interface return result } -func flattenContainerdConfig(c *container.ContainerdConfig) []map[string]interface{} { - result := []map[string]interface{}{} - if c == nil { - return result - } - r := map[string]interface{}{} - if c.PrivateRegistryAccessConfig != nil { - r["private_registry_access_config"] = flattenPrivateRegistryAccessConfig(c.PrivateRegistryAccessConfig) - } - return append(result, r) -} - -func flattenPrivateRegistryAccessConfig(c *container.PrivateRegistryAccessConfig) []map[string]interface{} { - result := []map[string]interface{}{} - if c == nil { - return result - } - r := map[string]interface{}{ - "enabled": c.Enabled, - } - if c.CertificateAuthorityDomainConfig != nil { - caConfigs := make([]interface{}, len(c.CertificateAuthorityDomainConfig)) - for i, caCfg := range c.CertificateAuthorityDomainConfig { - caConfigs[i] = flattenCADomainConfig(caCfg) - } - r["certificate_authority_domain_config"] = caConfigs - } - return append(result, r) -} - -// func flattenCADomainConfig(c *container.CertificateAuthorityDomainConfig) []map[string]interface{} { -// result := []map[string]interface{}{} -// if c == nil { -// return result -// } -// r := map[string]interface{}{ -// "fqdns": c.Fqdns, -// } -// if c.GcpSecretManagerCertificateConfig != nil { -// r["gcp_secret_manager_certificate_config"] = flattenGCPSecretManagerCertificateConfig(c.GcpSecretManagerCertificateConfig) -// } -// return append(result, r) -// } - -func flattenCADomainConfig(c *container.CertificateAuthorityDomainConfig) map[string]interface{} { - if c == nil { - return nil - } - r := map[string]interface{}{ - "fqdns": c.Fqdns, - } - if c.GcpSecretManagerCertificateConfig != nil { - r["gcp_secret_manager_certificate_config"] = flattenGCPSecretManagerCertificateConfig(c.GcpSecretManagerCertificateConfig) - } - return r -} - -func flattenGCPSecretManagerCertificateConfig(c *container.GCPSecretManagerCertificateConfig) []map[string]interface{} { - result := []map[string]interface{}{} - if c == nil { - return result - } - r := map[string]interface{}{ - "secret_uri": c.SecretUri, - } - return append(result, r) -} - func flattenConfidentialNodes(c *container.ConfidentialNodes) []map[string]interface{} { result := []map[string]interface{}{} if c != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster.go index 2b4b499ac70..92c79af573f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/errwrap" "github.com/hashicorp/go-version" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -25,15 +25,6 @@ import ( "google.golang.org/api/container/v1" ) -// Single-digit hour is equivalent to hour with leading zero e.g. suppress diff 1:00 => 01:00. -// Assume either value could be in either format. -func Rfc3339TimeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - if (len(old) == 4 && "0"+old == new) || (len(new) == 4 && "0"+new == old) { - return true - } - return false -} - var ( instanceGroupManagerURL = regexp.MustCompile(fmt.Sprintf("projects/(%s)/zones/([a-z0-9-]*)/instanceGroupManagers/([^/]*)", verify.ProjectRegex)) @@ -52,7 +43,7 @@ var ( Type: schema.TypeBool, Optional: true, Computed: true, - Description: `Whether Kubernetes master is accessible via Google Compute Engine Public IPs.`, + Description: `Whether master is accessbile via Google Compute Engine Public IP addresses.`, }, }, } @@ -86,7 +77,6 @@ var ( "addons_config.0.gke_backup_agent_config", "addons_config.0.config_connector_config", "addons_config.0.gcs_fuse_csi_driver_config", - "addons_config.0.stateful_ha_config", } privateClusterConfigKeys = []string{ @@ -150,8 +140,7 @@ func clusterSchemaNodePoolDefaults() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "containerd_config": schemaContainerdConfig(), - "logging_variant": schemaLoggingVariant(), + "logging_variant": schemaLoggingVariant(), }, }, }, @@ -281,7 +270,7 @@ func ResourceContainerCluster() *schema.Resource { Type: schema.TypeBool, Optional: true, Default: true, - Description: `When the field is set to true or unset in Terraform state, a terraform apply or terraform destroy that would delete the cluster will fail. When the field is set to false, deleting the cluster is allowed.`, + Description: `Whether or not to allow Terraform to destroy the instance. Defaults to true. Unless this field is set to false in Terraform state, a terraform destroy or terraform apply that would delete the cluster will fail.`, }, "addons_config": { @@ -460,23 +449,6 @@ func ResourceContainerCluster() *schema.Resource { }, }, }, - "stateful_ha_config": { - Type: schema.TypeList, - Optional: true, - Computed: true, - AtLeastOneOf: addonsConfigKeys, - MaxItems: 1, - Description: `The status of the Stateful HA addon, which provides automatic configurable failover for stateful applications. Defaults to disabled; set enabled = true to enable.`, - ConflictsWith: []string{"enable_autopilot"}, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Required: true, - }, - }, - }, - }, }, }, }, @@ -936,7 +908,7 @@ func ResourceContainerCluster() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: verify.ValidateRFC3339Time, - DiffSuppressFunc: Rfc3339TimeDiffSuppress, + DiffSuppressFunc: tpgresource.Rfc3339TimeDiffSuppress, }, "duration": { Type: schema.TypeString, @@ -1030,8 +1002,8 @@ func ResourceContainerCluster() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ValidateFunc: validation.StringInSlice([]string{"DISABLED", "BASIC", "ENTERPRISE", "MODE_UNSPECIFIED"}, false), - Description: `Sets the mode of the Kubernetes security posture API's off-cluster features. Available options include DISABLED, BASIC, and ENTERPRISE.`, + ValidateFunc: validation.StringInSlice([]string{"DISABLED", "BASIC", "MODE_UNSPECIFIED"}, false), + Description: `Sets the mode of the Kubernetes security posture API's off-cluster features. Available options include DISABLED and BASIC.`, DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("MODE_UNSPECIFIED"), }, "vulnerability_mode": { @@ -1057,7 +1029,7 @@ func ResourceContainerCluster() *schema.Resource { Type: schema.TypeList, Optional: true, Computed: true, - Description: `GKE components exposing metrics. Valid values include SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET, KUBELET, CADVISOR and DCGM.`, + Description: `GKE components exposing metrics. Valid values include SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT and STATEFULSET.`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -1329,11 +1301,6 @@ func ResourceContainerCluster() *schema.Resource { }, }, }, - "resource_manager_tags": { - Type: schema.TypeMap, - Optional: true, - Description: `A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored (both PUT & PATCH) when empty.`, - }, }, }, }, @@ -1551,7 +1518,7 @@ func ResourceContainerCluster() *schema.Resource { Optional: true, ForceNew: true, AtLeastOneOf: privateClusterConfigKeys, - DiffSuppressFunc: containerClusterPrivateClusterConfigSuppress, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `Subnetwork in cluster's network where master's endpoint will be provisioned.`, }, "public_endpoint": { @@ -1625,8 +1592,9 @@ func ResourceContainerCluster() *schema.Resource { // Computed is unsafe to remove- this API may return `"workloadIdentityConfig": {},` or omit the key entirely // and both will be valid. Note that we don't handle the case where the API returns nothing & the user has defined // workload_identity_config today. - Computed: true, - Description: `Configuration for the use of Kubernetes Service Accounts in GCP IAM policies.`, + Computed: true, + Description: `Configuration for the use of Kubernetes Service Accounts in GCP IAM policies.`, + ConflictsWith: []string{"enable_autopilot"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "workload_pool": { @@ -1666,7 +1634,7 @@ func ResourceContainerCluster() *schema.Resource { "enabled": { Type: schema.TypeBool, Required: true, - Description: `When enabled, services with external ips specified will be allowed.`, + Description: `When enabled, services with exterenal ips specified will be allowed.`, }, }, }, @@ -1766,12 +1734,7 @@ func ResourceContainerCluster() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{"DATAPATH_PROVIDER_UNSPECIFIED", "LEGACY_DATAPATH", "ADVANCED_DATAPATH"}, false), DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("DATAPATH_PROVIDER_UNSPECIFIED"), }, - "enable_cilium_clusterwide_network_policy": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether Cilium cluster-wide network policy is enabled on this cluster.`, - Default: false, - }, + "enable_intranode_visibility": { Type: schema.TypeBool, Optional: true, @@ -2064,14 +2027,13 @@ func resourceContainerClusterCreate(d *schema.ResourceData, meta interface{}) er ReleaseChannel: expandReleaseChannel(d.Get("release_channel")), EnableTpu: d.Get("enable_tpu").(bool), NetworkConfig: &container.NetworkConfig{ - EnableIntraNodeVisibility: d.Get("enable_intranode_visibility").(bool), - DefaultSnatStatus: expandDefaultSnatStatus(d.Get("default_snat_status")), - DatapathProvider: d.Get("datapath_provider").(string), - EnableCiliumClusterwideNetworkPolicy: d.Get("enable_cilium_clusterwide_network_policy").(bool), - PrivateIpv6GoogleAccess: d.Get("private_ipv6_google_access").(string), - EnableL4ilbSubsetting: d.Get("enable_l4_ilb_subsetting").(bool), - DnsConfig: expandDnsConfig(d.Get("dns_config")), - GatewayApiConfig: expandGatewayApiConfig(d.Get("gateway_api_config")), + EnableIntraNodeVisibility: d.Get("enable_intranode_visibility").(bool), + DefaultSnatStatus: expandDefaultSnatStatus(d.Get("default_snat_status")), + DatapathProvider: d.Get("datapath_provider").(string), + PrivateIpv6GoogleAccess: d.Get("private_ipv6_google_access").(string), + EnableL4ilbSubsetting: d.Get("enable_l4_ilb_subsetting").(bool), + DnsConfig: expandDnsConfig(d.Get("dns_config")), + GatewayApiConfig: expandGatewayApiConfig(d.Get("gateway_api_config")), }, MasterAuth: expandMasterAuth(d.Get("master_auth")), NotificationConfig: expandNotificationConfig(d.Get("notification_config")), @@ -2584,9 +2546,6 @@ func resourceContainerClusterRead(d *schema.ResourceData, meta interface{}) erro if err := d.Set("datapath_provider", cluster.NetworkConfig.DatapathProvider); err != nil { return fmt.Errorf("Error setting datapath_provider: %s", err) } - if err := d.Set("enable_cilium_clusterwide_network_policy", cluster.NetworkConfig.EnableCiliumClusterwideNetworkPolicy); err != nil { - return fmt.Errorf("Error setting enable_cilium_clusterwide_network_policy: %s", err) - } if err := d.Set("default_snat_status", flattenDefaultSnatStatus(cluster.NetworkConfig.DefaultSnatStatus)); err != nil { return err } @@ -3042,22 +3001,6 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er log.Printf("[INFO] GKE cluster %s L4 ILB Subsetting has been updated to %v", d.Id(), enabled) } - if d.HasChange("enable_cilium_clusterwide_network_policy") { - enabled := d.Get("enable_cilium_clusterwide_network_policy").(bool) - req := &container.UpdateClusterRequest{ - Update: &container.ClusterUpdate{ - DesiredEnableCiliumClusterwideNetworkPolicy: enabled, - }, - } - updateF := updateFunc(req, "updating cilium clusterwide network policy") - // Call update serially. - if err := transport_tpg.LockedCall(lockKey, updateF); err != nil { - return err - } - - log.Printf("[INFO] GKE cluster %s Cilium Clusterwide Network Policy has been updated to %v", d.Id(), enabled) - } - if d.HasChange("cost_management_config") { c := d.Get("cost_management_config") req := &container.UpdateClusterRequest{ @@ -3854,21 +3797,6 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er log.Printf("[INFO] GKE cluster %s Security Posture Config has been updated to %#v", d.Id(), req.Update.DesiredSecurityPostureConfig) } - if d.HasChange("node_pool_defaults") && d.HasChange("node_pool_defaults.0.node_config_defaults.0.containerd_config") { - if v, ok := d.GetOk("node_pool_defaults.0.node_config_defaults.0.containerd_config"); ok { - req := &container.UpdateClusterRequest{ - Update: &container.ClusterUpdate{ - DesiredContainerdConfig: expandContainerdConfig(v), - }, - } - updateF := updateFunc(req, "updating GKE cluster containerd config") - if err := transport_tpg.LockedCall(lockKey, updateF); err != nil { - return err - } - log.Printf("[INFO] GKE cluster %s containerd config has been updated to %#v", d.Id(), req.Update.DesiredContainerdConfig) - } - } - if d.HasChange("node_pool_auto_config.0.network_tags.0.tags") { tags := d.Get("node_pool_auto_config.0.network_tags.0.tags").([]interface{}) @@ -3890,24 +3818,6 @@ func resourceContainerClusterUpdate(d *schema.ResourceData, meta interface{}) er log.Printf("[INFO] GKE cluster %s node pool auto config network tags have been updated", d.Id()) } - if d.HasChange("node_pool_auto_config.0.resource_manager_tags") { - rmtags := d.Get("node_pool_auto_config.0.resource_manager_tags") - - req := &container.UpdateClusterRequest{ - Update: &container.ClusterUpdate{ - DesiredNodePoolAutoConfigResourceManagerTags: expandResourceManagerTags(rmtags), - }, - } - - updateF := updateFunc(req, "updating GKE cluster node pool auto config resource manager tags") - // Call update serially. - if err := transport_tpg.LockedCall(lockKey, updateF); err != nil { - return err - } - - log.Printf("[INFO] GKE cluster %s node pool auto config resource manager tags have been updated", d.Id()) - } - d.Partial(false) if _, err := containerClusterAwaitRestingState(config, project, location, clusterName, userAgent, d.Timeout(schema.TimeoutUpdate)); err != nil { @@ -3953,7 +3863,7 @@ func resourceContainerClusterDelete(d *schema.ResourceData, meta interface{}) er var op *container.Operation var count = 0 - err = retry.Retry(30*time.Second, func() *retry.RetryError { + err = resource.Retry(30*time.Second, func() *resource.RetryError { count++ name := containerClusterFullName(project, location, clusterName) @@ -3965,11 +3875,11 @@ func resourceContainerClusterDelete(d *schema.ResourceData, meta interface{}) er if err != nil { log.Printf("[WARNING] Cluster is still not ready to delete, retrying %s", clusterName) - return retry.RetryableError(err) + return resource.RetryableError(err) } if count == 15 { - return retry.NonRetryableError(fmt.Errorf("Error retrying to delete cluster %s", clusterName)) + return resource.NonRetryableError(fmt.Errorf("Error retrying to delete cluster %s", clusterName)) } return nil }) @@ -3999,7 +3909,7 @@ var containerClusterRestingStates = RestingStates{ // returns a state with no error if the state is a resting state, and the last state with an error otherwise func containerClusterAwaitRestingState(config *transport_tpg.Config, project, location, clusterName, userAgent string, timeout time.Duration) (state string, err error) { - err = retry.Retry(timeout, func() *retry.RetryError { + err = resource.Retry(timeout, func() *resource.RetryError { name := containerClusterFullName(project, location, clusterName) clusterGetCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.Get(name) if config.UserProjectOverride { @@ -4007,7 +3917,7 @@ func containerClusterAwaitRestingState(config *transport_tpg.Config, project, lo } cluster, gErr := clusterGetCall.Do() if gErr != nil { - return retry.NonRetryableError(gErr) + return resource.NonRetryableError(gErr) } state = cluster.Status @@ -4020,7 +3930,7 @@ func containerClusterAwaitRestingState(config *transport_tpg.Config, project, lo log.Printf("[DEBUG] Cluster %q has error state %q with message %q.", clusterName, state, cluster.StatusMessage) return nil default: - return retry.RetryableError(fmt.Errorf("Cluster %q has state %q with message %q", clusterName, state, cluster.StatusMessage)) + return resource.RetryableError(fmt.Errorf("Cluster %q has state %q with message %q", clusterName, state, cluster.StatusMessage)) } }) @@ -4116,14 +4026,6 @@ func expandClusterAddonsConfig(configured interface{}) *container.AddonsConfig { } } - if v, ok := config["stateful_ha_config"]; ok && len(v.([]interface{})) > 0 { - addon := v.([]interface{})[0].(map[string]interface{}) - ac.StatefulHaConfig = &container.StatefulHAConfig{ - Enabled: addon["enabled"].(bool), - ForceSendFields: []string{"Enabled"}, - } - } - return ac } @@ -5001,10 +4903,6 @@ func expandNodePoolAutoConfig(configured interface{}) *container.NodePoolAutoCon npac.NetworkTags = expandNodePoolAutoConfigNetworkTags(v) } - if v, ok := config["resource_manager_tags"]; ok && len(v.(map[string]interface{})) > 0 { - npac.ResourceManagerTags = expandResourceManagerTags(v) - } - return npac } @@ -5170,13 +5068,6 @@ func flattenClusterAddonsConfig(c *container.AddonsConfig) []map[string]interfac }, } } - if c.StatefulHaConfig != nil { - result["stateful_ha_config"] = []map[string]interface{}{ - { - "enabled": c.StatefulHaConfig.Enabled, - }, - } - } return []map[string]interface{}{result} } @@ -5755,9 +5646,6 @@ func flattenNodePoolAutoConfig(c *container.NodePoolAutoConfig) []map[string]int if c.NetworkTags != nil { result["network_tags"] = flattenNodePoolAutoConfigNetworkTags(c.NetworkTags) } - if c.ResourceManagerTags != nil { - result["resource_manager_tags"] = flattenResourceManagerTags(c.ResourceManagerTags) - } return []map[string]interface{}{result} } @@ -5898,14 +5786,6 @@ func containerClusterPrivateClusterConfigSuppress(k, old, new string, d *schema. return suppressNodes && !hasSubnet } else if k == "private_cluster_config.#" { return suppressEndpoint && suppressNodes && !hasSubnet && !hasGlobalAccessConfig - } else if k == "private_cluster_config.0.private_endpoint_subnetwork" { - // Before regular compare, for the sake of private flexible cluster, - // suppress diffs in private_endpoint_subnetwork when - // master_ipv4_cidr_block is set - // && private_endpoint_subnetwork is unset in terraform (new value == "") - // && private_endpoint_subnetwork is returned from resource (old value != "") - _, hasMasterCidr := d.GetOk("private_cluster_config.0.master_ipv4_cidr_block") - return (hasMasterCidr && new == "" && old != "") || tpgresource.CompareSelfLinkOrResourceName(k, old, new, d) } return false } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster_migratev1.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster_migratev1.go index c3562aafa61..d22abc4e424 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster_migratev1.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_cluster_migratev1.go @@ -700,7 +700,7 @@ func resourceContainerClusterResourceV1() *schema.Resource { Type: schema.TypeString, Required: true, ValidateFunc: verify.ValidateRFC3339Time, - DiffSuppressFunc: Rfc3339TimeDiffSuppress, + DiffSuppressFunc: tpgresource.Rfc3339TimeDiffSuppress, }, "duration": { Type: schema.TypeString, @@ -794,8 +794,8 @@ func resourceContainerClusterResourceV1() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ValidateFunc: validation.StringInSlice([]string{"DISABLED", "BASIC", "ENTERPRISE", "MODE_UNSPECIFIED"}, false), - Description: `Sets the mode of the Kubernetes security posture API's off-cluster features. Available options include DISABLED, BASIC, and ENTERPRISE.`, + ValidateFunc: validation.StringInSlice([]string{"DISABLED", "BASIC", "MODE_UNSPECIFIED"}, false), + Description: `Sets the mode of the Kubernetes security posture API's off-cluster features. Available options include DISABLED and BASIC.`, DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("MODE_UNSPECIFIED"), }, "vulnerability_mode": { @@ -821,7 +821,7 @@ func resourceContainerClusterResourceV1() *schema.Resource { Type: schema.TypeList, Optional: true, Computed: true, - Description: `GKE components exposing metrics. Valid values include SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT, STATEFULSET and DCGM.`, + Description: `GKE components exposing metrics. Valid values include SYSTEM_COMPONENTS, APISERVER, SCHEDULER, CONTROLLER_MANAGER, STORAGE, HPA, POD, DAEMONSET, DEPLOYMENT and STATEFULSET.`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -1421,7 +1421,7 @@ func resourceContainerClusterResourceV1() *schema.Resource { "enabled": { Type: schema.TypeBool, Required: true, - Description: `When enabled, services with external ips specified will be allowed.`, + Description: `When enabled, services with exterenal ips specified will be allowed.`, }, }, }, diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_node_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_node_pool.go index bd07346c2bb..569499ae63d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_node_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/container/resource_container_node_pool.go @@ -10,8 +10,7 @@ import ( "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -549,7 +548,7 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e } var operation *container.Operation - err = retry.Retry(timeout, func() *retry.RetryError { + err = resource.Retry(timeout, func() *resource.RetryError { clusterNodePoolsCreateCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.NodePools.Create(nodePoolInfo.parent(), req) if config.UserProjectOverride { clusterNodePoolsCreateCall.Header().Add("X-Goog-User-Project", nodePoolInfo.project) @@ -562,9 +561,9 @@ func resourceContainerNodePoolCreate(d *schema.ResourceData, meta interface{}) e // while we try to add the node pool. // We get quota errors if there the number of running concurrent // operations reaches the quota. - return retry.RetryableError(err) + return resource.RetryableError(err) } - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } return nil }) @@ -756,7 +755,7 @@ func resourceContainerNodePoolDelete(d *schema.ResourceData, meta interface{}) e startTime := time.Now() var operation *container.Operation - err = retry.Retry(timeout, func() *retry.RetryError { + err = resource.Retry(timeout, func() *resource.RetryError { clusterNodePoolsDeleteCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.NodePools.Delete(nodePoolInfo.fullyQualifiedName(name)) if config.UserProjectOverride { clusterNodePoolsDeleteCall.Header().Add("X-Goog-User-Project", nodePoolInfo.project) @@ -769,9 +768,9 @@ func resourceContainerNodePoolDelete(d *schema.ResourceData, meta interface{}) e // while we try to delete the node pool. // We get quota errors if there the number of running concurrent // operations reaches the quota. - return retry.RetryableError(err) + return resource.RetryableError(err) } - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } return nil @@ -875,9 +874,9 @@ func expandNodePool(d *schema.ResourceData, prefix string) (*container.NodePool, } name = v.(string) } else if v, ok := d.GetOk(prefix + "name_prefix"); ok { - name = id.PrefixedUniqueId(v.(string)) + name = resource.PrefixedUniqueId(v.(string)) } else { - name = id.UniqueId() + name = resource.UniqueId() } nodeCount := 0 @@ -2004,14 +2003,14 @@ var containerNodePoolRestingStates = RestingStates{ // takes in a config object, full node pool name, project name and the current CRUD action timeout // returns a state with no error if the state is a resting state, and the last state with an error otherwise func containerNodePoolAwaitRestingState(config *transport_tpg.Config, name, project, userAgent string, timeout time.Duration) (state string, err error) { - err = retry.Retry(timeout, func() *retry.RetryError { + err = resource.Retry(timeout, func() *resource.RetryError { clusterNodePoolsGetCall := config.NewContainerClient(userAgent).Projects.Locations.Clusters.NodePools.Get(name) if config.UserProjectOverride { clusterNodePoolsGetCall.Header().Add("X-Goog-User-Project", project) } nodePool, gErr := clusterNodePoolsGetCall.Do() if gErr != nil { - return retry.NonRetryableError(gErr) + return resource.NonRetryableError(gErr) } state = nodePool.Status @@ -2023,7 +2022,7 @@ func containerNodePoolAwaitRestingState(config *transport_tpg.Config, name, proj log.Printf("[DEBUG] NodePool %q has error state %q with message %q.", name, state, nodePool.StatusMessage) return nil default: - return retry.RetryableError(fmt.Errorf("NodePool %q has state %q with message %q", name, state, nodePool.StatusMessage)) + return resource.RetryableError(fmt.Errorf("NodePool %q has state %q with message %q", name, state, nodePool.StatusMessage)) } }) @@ -2037,12 +2036,12 @@ func containerNodePoolAwaitRestingState(config *transport_tpg.Config, name, proj // retried until the incompatible operation completes, and the newly // requested operation can begin. func retryWhileIncompatibleOperation(timeout time.Duration, lockKey string, f func() error) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := transport_tpg.LockedCall(lockKey, f); err != nil { if tpgresource.IsFailedPreconditionError(err) || tpgresource.IsQuotaError(err) { - return retry.RetryableError(err) + return resource.RetryableError(err) } - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } return nil }) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_note.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_note.go index 7d99f305099..6cb836ed859 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_note.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_note.go @@ -20,7 +20,6 @@ package containeranalysis import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -257,7 +256,6 @@ func resourceContainerAnalysisNoteCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -266,7 +264,6 @@ func resourceContainerAnalysisNoteCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Note: %s", err) @@ -309,14 +306,12 @@ func resourceContainerAnalysisNoteRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ContainerAnalysisNote %q", d.Id())) @@ -443,7 +438,6 @@ func resourceContainerAnalysisNoteUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating Note %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("short_description") { @@ -491,7 +485,6 @@ func resourceContainerAnalysisNoteUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -539,8 +532,6 @@ func resourceContainerAnalysisNoteDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Note %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -550,7 +541,6 @@ func resourceContainerAnalysisNoteDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Note") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_occurrence.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_occurrence.go index eb219817125..b5fd3409d8e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_occurrence.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containeranalysis/resource_container_analysis_occurrence.go @@ -20,7 +20,6 @@ package containeranalysis import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -239,7 +238,6 @@ func resourceContainerAnalysisOccurrenceCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -248,7 +246,6 @@ func resourceContainerAnalysisOccurrenceCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Occurrence: %s", err) @@ -294,14 +291,12 @@ func resourceContainerAnalysisOccurrenceRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ContainerAnalysisOccurrence %q", d.Id())) @@ -398,7 +393,6 @@ func resourceContainerAnalysisOccurrenceUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating Occurrence %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("remediation") { @@ -430,7 +424,6 @@ func resourceContainerAnalysisOccurrenceUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -478,8 +471,6 @@ func resourceContainerAnalysisOccurrenceDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Occurrence %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -489,7 +480,6 @@ func resourceContainerAnalysisOccurrenceDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Occurrence") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containerattached/resource_container_attached_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containerattached/resource_container_attached_cluster.go index 2bd53b039f1..c590f81f4c3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containerattached/resource_container_attached_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/containerattached/resource_container_attached_cluster.go @@ -20,7 +20,6 @@ package containerattached import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -509,7 +508,6 @@ func resourceContainerAttachedClusterCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -518,7 +516,6 @@ func resourceContainerAttachedClusterCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Cluster: %s", err) @@ -585,14 +582,12 @@ func resourceContainerAttachedClusterRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ContainerAttachedCluster %q", d.Id())) @@ -761,7 +756,6 @@ func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating Cluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -858,7 +852,6 @@ func resourceContainerAttachedClusterUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -906,7 +899,6 @@ func resourceContainerAttachedClusterDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) if v, ok := d.GetOk("deletion_policy"); ok { if v == "DELETE_IGNORE_ERRORS" { url, err = transport_tpg.AddQueryParams(url, map[string]string{"ignore_errors": "true"}) @@ -925,7 +917,6 @@ func resourceContainerAttachedClusterDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Cluster") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/corebilling/resource_billing_project_info.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/corebilling/resource_billing_project_info.go index 18f54ab2854..8d317564000 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/corebilling/resource_billing_project_info.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/corebilling/resource_billing_project_info.go @@ -20,7 +20,6 @@ package corebilling import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -111,7 +110,6 @@ func resourceCoreBillingProjectInfoCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PUT", @@ -120,7 +118,6 @@ func resourceCoreBillingProjectInfoCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ProjectInfo: %s", err) @@ -163,14 +160,12 @@ func resourceCoreBillingProjectInfoRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("CoreBillingProjectInfo %q", d.Id())) @@ -233,7 +228,6 @@ func resourceCoreBillingProjectInfoUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating ProjectInfo %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -248,7 +242,6 @@ func resourceCoreBillingProjectInfoUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -287,8 +280,6 @@ func resourceCoreBillingProjectInfoDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ProjectInfo %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -298,7 +289,6 @@ func resourceCoreBillingProjectInfoDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ProjectInfo") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go index 7ca53663197..67d85d42815 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_connection_profile.go @@ -20,7 +20,6 @@ package databasemigrationservice import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -850,7 +849,6 @@ func resourceDatabaseMigrationServiceConnectionProfileCreate(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -859,7 +857,6 @@ func resourceDatabaseMigrationServiceConnectionProfileCreate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ConnectionProfile: %s", err) @@ -912,14 +909,12 @@ func resourceDatabaseMigrationServiceConnectionProfileRead(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DatabaseMigrationServiceConnectionProfile %q", d.Id())) @@ -1040,7 +1035,6 @@ func resourceDatabaseMigrationServiceConnectionProfileUpdate(d *schema.ResourceD } log.Printf("[DEBUG] Updating ConnectionProfile %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -1092,7 +1086,6 @@ func resourceDatabaseMigrationServiceConnectionProfileUpdate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1140,8 +1133,6 @@ func resourceDatabaseMigrationServiceConnectionProfileDelete(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ConnectionProfile %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1151,7 +1142,6 @@ func resourceDatabaseMigrationServiceConnectionProfileDelete(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ConnectionProfile") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go index 9bae92c4205..386a6586fd6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/databasemigrationservice/resource_database_migration_service_private_connection.go @@ -20,7 +20,6 @@ package databasemigrationservice import ( "fmt" "log" - "net/http" "reflect" "time" @@ -208,7 +207,6 @@ func resourceDatabaseMigrationServicePrivateConnectionCreate(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -217,7 +215,6 @@ func resourceDatabaseMigrationServicePrivateConnectionCreate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PrivateConnection: %s", err) @@ -270,14 +267,12 @@ func resourceDatabaseMigrationServicePrivateConnectionRead(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DatabaseMigrationServicePrivateConnection %q", d.Id())) @@ -347,8 +342,6 @@ func resourceDatabaseMigrationServicePrivateConnectionDelete(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PrivateConnection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -358,7 +351,6 @@ func resourceDatabaseMigrationServicePrivateConnectionDelete(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PrivateConnection") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry.go index 687d54fd13e..42af1da6dd7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -337,7 +336,6 @@ func resourceDataCatalogEntryCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -346,7 +344,6 @@ func resourceDataCatalogEntryCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Entry: %s", err) @@ -390,14 +387,12 @@ func resourceDataCatalogEntryRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataCatalogEntry %q", d.Id())) @@ -502,7 +497,6 @@ func resourceDataCatalogEntryUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Entry %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("linked_resource") { @@ -557,7 +551,6 @@ func resourceDataCatalogEntryUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -595,8 +588,6 @@ func resourceDataCatalogEntryDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Entry %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -606,7 +597,6 @@ func resourceDataCatalogEntryDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Entry") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry_group.go index 3185ea52c26..14a03287700 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_entry_group.go @@ -20,7 +20,6 @@ package datacatalog import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -138,7 +137,6 @@ func resourceDataCatalogEntryGroupCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -147,7 +145,6 @@ func resourceDataCatalogEntryGroupCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EntryGroup: %s", err) @@ -193,14 +190,12 @@ func resourceDataCatalogEntryGroupRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataCatalogEntryGroup %q", d.Id())) @@ -266,7 +261,6 @@ func resourceDataCatalogEntryGroupUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating EntryGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -298,7 +292,6 @@ func resourceDataCatalogEntryGroupUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -339,8 +332,6 @@ func resourceDataCatalogEntryGroupDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EntryGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -350,7 +341,6 @@ func resourceDataCatalogEntryGroupDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EntryGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_policy_tag.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_policy_tag.go index 7985efd2852..3ec28ada197 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_policy_tag.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_policy_tag.go @@ -20,7 +20,6 @@ package datacatalog import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -136,7 +135,6 @@ func resourceDataCatalogPolicyTagCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -145,7 +143,6 @@ func resourceDataCatalogPolicyTagCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PolicyTag: %s", err) @@ -185,14 +182,12 @@ func resourceDataCatalogPolicyTagRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataCatalogPolicyTag %q", d.Id())) @@ -252,7 +247,6 @@ func resourceDataCatalogPolicyTagUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating PolicyTag %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -288,7 +282,6 @@ func resourceDataCatalogPolicyTagUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -323,8 +316,6 @@ func resourceDataCatalogPolicyTagDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PolicyTag %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -334,7 +325,6 @@ func resourceDataCatalogPolicyTagDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PolicyTag") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag.go index e05437130b4..870a54a7d70 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag.go @@ -20,7 +20,6 @@ package datacatalog import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -189,7 +188,6 @@ func resourceDataCatalogTagCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -198,7 +196,6 @@ func resourceDataCatalogTagCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Tag: %s", err) @@ -238,14 +235,12 @@ func resourceDataCatalogTagRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataCatalogTag %q", d.Id())) @@ -316,7 +311,6 @@ func resourceDataCatalogTagUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Tag %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("fields") { @@ -348,7 +342,6 @@ func resourceDataCatalogTagUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -383,8 +376,6 @@ func resourceDataCatalogTagDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Tag %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -394,7 +385,6 @@ func resourceDataCatalogTagDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Tag") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag_template.go index 63c2c8d3f5b..17d98074a2f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_tag_template.go @@ -20,7 +20,6 @@ package datacatalog import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -294,7 +293,6 @@ func resourceDataCatalogTagTemplateCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -303,7 +301,6 @@ func resourceDataCatalogTagTemplateCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TagTemplate: %s", err) @@ -349,14 +346,12 @@ func resourceDataCatalogTagTemplateRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataCatalogTagTemplate %q", d.Id())) @@ -422,7 +417,6 @@ func resourceDataCatalogTagTemplateUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating TagTemplate %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -451,7 +445,6 @@ func resourceDataCatalogTagTemplateUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -622,8 +615,6 @@ func resourceDataCatalogTagTemplateDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TagTemplate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -633,7 +624,6 @@ func resourceDataCatalogTagTemplateDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TagTemplate") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy.go index 5a5e8bbacac..68d20414187 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy.go @@ -20,7 +20,6 @@ package datacatalog import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -152,7 +151,6 @@ func resourceDataCatalogTaxonomyCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -161,7 +159,6 @@ func resourceDataCatalogTaxonomyCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Taxonomy: %s", err) @@ -207,14 +204,12 @@ func resourceDataCatalogTaxonomyRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataCatalogTaxonomy %q", d.Id())) @@ -281,7 +276,6 @@ func resourceDataCatalogTaxonomyUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Taxonomy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -317,7 +311,6 @@ func resourceDataCatalogTaxonomyUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -358,8 +351,6 @@ func resourceDataCatalogTaxonomyDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Taxonomy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -369,7 +360,6 @@ func resourceDataCatalogTaxonomyDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Taxonomy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy_sweeper.go index 9408c937ff4..8f3e8e9cdac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datacatalog/resource_data_catalog_taxonomy_sweeper.go @@ -1,20 +1,5 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - package datacatalog import ( @@ -103,12 +88,12 @@ func testSweepDataCatalogTaxonomy(region string) error { name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(obj["displayName"].(string)) { + if !sweeper.IsSweepableTestResource(name) { nonPrefixCount++ continue } - deleteTemplate := "https://datacatalog.googleapis.com/v1/{{name}}" + deleteTemplate := "https://datacatalog.googleapis.com/v1/{{display_name}}" deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataflow/resource_dataflow_job.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataflow/resource_dataflow_job.go index 197761c6950..cb6eff0b0c6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataflow/resource_dataflow_job.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataflow/resource_dataflow_job.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" dataflow "google.golang.org/api/dataflow/v1b3" "google.golang.org/api/googleapi" ) @@ -499,7 +499,7 @@ func resourceDataflowJobDelete(d *schema.ResourceData, meta interface{}) error { } // Retry updating the state while the job is not ready to be canceled/drained. - err = retry.Retry(time.Minute*time.Duration(15), func() *retry.RetryError { + err = resource.Retry(time.Minute*time.Duration(15), func() *resource.RetryError { // To terminate a dataflow job, we update the job with a requested // terminal state. job := &dataflow.Job{ @@ -511,14 +511,14 @@ func resourceDataflowJobDelete(d *schema.ResourceData, meta interface{}) error { gerr, isGoogleErr := updateErr.(*googleapi.Error) if !isGoogleErr { // If we have an error and it's not a google-specific error, we should go ahead and return. - return retry.NonRetryableError(updateErr) + return resource.NonRetryableError(updateErr) } if strings.Contains(gerr.Message, "not yet ready for canceling") { // Retry cancelling job if it's not ready. // Sleep to avoid hitting update quota with repeated attempts. time.Sleep(5 * time.Second) - return retry.RetryableError(updateErr) + return resource.RetryableError(updateErr) } if strings.Contains(gerr.Message, "Job has terminated") { @@ -684,31 +684,31 @@ func jobHasUpdate(d *schema.ResourceData, resourceSchema map[string]*schema.Sche } func waitForDataflowJobToBeUpdated(d *schema.ResourceData, config *transport_tpg.Config, replacementJobID, userAgent string, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { project, err := tpgresource.GetProject(d, config) if err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } region, err := tpgresource.GetRegion(d, config) if err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } replacementJob, err := resourceDataflowJobGetJob(config, project, region, userAgent, replacementJobID) if err != nil { if transport_tpg.IsRetryableError(err, nil, nil) { - return retry.RetryableError(err) + return resource.RetryableError(err) } - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } state := replacementJob.CurrentState switch state { case "", "JOB_STATE_PENDING": - return retry.RetryableError(fmt.Errorf("the replacement job with ID %q has pending state %q.", replacementJobID, state)) + return resource.RetryableError(fmt.Errorf("the replacement job with ID %q has pending state %q.", replacementJobID, state)) case "JOB_STATE_FAILED": - return retry.NonRetryableError(fmt.Errorf("the replacement job with ID %q failed with state %q.", replacementJobID, state)) + return resource.NonRetryableError(fmt.Errorf("the replacement job with ID %q failed with state %q.", replacementJobID, state)) default: log.Printf("[DEBUG] the replacement job with ID %q has state %q.", replacementJobID, state) return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datafusion/resource_data_fusion_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datafusion/resource_data_fusion_instance.go index 939f4416594..42c889464b9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datafusion/resource_data_fusion_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datafusion/resource_data_fusion_instance.go @@ -20,7 +20,6 @@ package datafusion import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -215,65 +214,21 @@ Please refer to the field 'effective_labels' for all of the labels present on th MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "connection_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"VPC_PEERING", "PRIVATE_SERVICE_CONNECT_INTERFACES", ""}), - Description: `Optional. Type of connection for establishing private IP connectivity between the Data Fusion customer project VPC and -the corresponding tenant project from a predefined list of available connection modes. -If this field is unspecified for a private instance, VPC peering is used. Possible values: ["VPC_PEERING", "PRIVATE_SERVICE_CONNECT_INTERFACES"]`, - }, "ip_allocation": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, Description: `The IP range in CIDR notation to use for the managed Data Fusion instance nodes. This range must not overlap with any other ranges used in the Data Fusion instance network.`, }, "network": { Type: schema.TypeString, - Optional: true, + Required: true, ForceNew: true, Description: `Name of the network in the project with which the tenant project will be peered for executing pipelines. In case of shared VPC where the network resides in another host project the network should specified in the form of projects/{host-project-id}/global/networks/{network}`, }, - "private_service_connect_config": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Optional. Configuration for Private Service Connect. -This is required only when using connection type PRIVATE_SERVICE_CONNECT_INTERFACES.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "network_attachment": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Optional. The reference to the network attachment used to establish private connectivity. -It will be of the form projects/{project-id}/regions/{region}/networkAttachments/{network-attachment-id}. -This is required only when using connection type PRIVATE_SERVICE_CONNECT_INTERFACES.`, - }, - "unreachable_cidr_block": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Optional. Input only. The CIDR block to which the CDF instance can't route traffic to in the consumer project VPC. -The size of this block should be at least /25. This range should not overlap with the primary address range of any subnetwork used by the network attachment. -This range can be used for other purposes in the consumer VPC as long as there is no requirement for CDF to reach destinations using these addresses. -If this value is not provided, the server chooses a non RFC 1918 address range. The format of this field is governed by RFC 4632.`, - }, - "effective_unreachable_cidr_block": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The CIDR block to which the CDF instance can't route traffic to in the consumer project VPC. -The size of this block is /25. The format of this field is governed by RFC 4632.`, - }, - }, - }, - }, }, }, }, @@ -519,7 +474,6 @@ func resourceDataFusionInstanceCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -528,7 +482,6 @@ func resourceDataFusionInstanceCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -595,14 +548,12 @@ func resourceDataFusionInstanceRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataFusionInstance %q", d.Id())) @@ -773,7 +724,6 @@ func resourceDataFusionInstanceUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enable_stackdriver_logging") { @@ -809,7 +759,6 @@ func resourceDataFusionInstanceUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -856,8 +805,6 @@ func resourceDataFusionInstanceDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -867,7 +814,6 @@ func resourceDataFusionInstanceDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") @@ -1005,10 +951,6 @@ func flattenDataFusionInstanceNetworkConfig(v interface{}, d *schema.ResourceDat flattenDataFusionInstanceNetworkConfigIpAllocation(original["ipAllocation"], d, config) transformed["network"] = flattenDataFusionInstanceNetworkConfigNetwork(original["network"], d, config) - transformed["connection_type"] = - flattenDataFusionInstanceNetworkConfigConnectionType(original["connectionType"], d, config) - transformed["private_service_connect_config"] = - flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfig(original["privateServiceConnectConfig"], d, config) return []interface{}{transformed} } func flattenDataFusionInstanceNetworkConfigIpAllocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1019,39 +961,6 @@ func flattenDataFusionInstanceNetworkConfigNetwork(v interface{}, d *schema.Reso return v } -func flattenDataFusionInstanceNetworkConfigConnectionType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["network_attachment"] = - flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfigNetworkAttachment(original["networkAttachment"], d, config) - transformed["unreachable_cidr_block"] = - flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfigUnreachableCidrBlock(original["unreachableCidrBlock"], d, config) - transformed["effective_unreachable_cidr_block"] = - flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfigEffectiveUnreachableCidrBlock(original["effectiveUnreachableCidrBlock"], d, config) - return []interface{}{transformed} -} -func flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfigNetworkAttachment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfigUnreachableCidrBlock(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return d.Get("network_config.0.private_service_connect_config.0.unreachable_cidr_block") -} - -func flattenDataFusionInstanceNetworkConfigPrivateServiceConnectConfigEffectiveUnreachableCidrBlock(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenDataFusionInstanceZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1224,20 +1133,6 @@ func expandDataFusionInstanceNetworkConfig(v interface{}, d tpgresource.Terrafor transformed["network"] = transformedNetwork } - transformedConnectionType, err := expandDataFusionInstanceNetworkConfigConnectionType(original["connection_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConnectionType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["connectionType"] = transformedConnectionType - } - - transformedPrivateServiceConnectConfig, err := expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfig(original["private_service_connect_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPrivateServiceConnectConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["privateServiceConnectConfig"] = transformedPrivateServiceConnectConfig - } - return transformed, nil } @@ -1249,55 +1144,6 @@ func expandDataFusionInstanceNetworkConfigNetwork(v interface{}, d tpgresource.T return v, nil } -func expandDataFusionInstanceNetworkConfigConnectionType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedNetworkAttachment, err := expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfigNetworkAttachment(original["network_attachment"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedNetworkAttachment); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["networkAttachment"] = transformedNetworkAttachment - } - - transformedUnreachableCidrBlock, err := expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfigUnreachableCidrBlock(original["unreachable_cidr_block"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUnreachableCidrBlock); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["unreachableCidrBlock"] = transformedUnreachableCidrBlock - } - - transformedEffectiveUnreachableCidrBlock, err := expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfigEffectiveUnreachableCidrBlock(original["effective_unreachable_cidr_block"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEffectiveUnreachableCidrBlock); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["effectiveUnreachableCidrBlock"] = transformedEffectiveUnreachableCidrBlock - } - - return transformed, nil -} - -func expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfigNetworkAttachment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfigUnreachableCidrBlock(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataFusionInstanceNetworkConfigPrivateServiceConnectConfigEffectiveUnreachableCidrBlock(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandDataFusionInstanceZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go index 5220791dd01..84549a3a829 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_deidentify_template.go @@ -20,7 +20,6 @@ package datalossprevention import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -4254,7 +4253,6 @@ func resourceDataLossPreventionDeidentifyTemplateCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -4263,7 +4261,6 @@ func resourceDataLossPreventionDeidentifyTemplateCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DeidentifyTemplate: %s", err) @@ -4303,14 +4300,12 @@ func resourceDataLossPreventionDeidentifyTemplateRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataLossPreventionDeidentifyTemplate %q", d.Id())) @@ -4390,7 +4385,6 @@ func resourceDataLossPreventionDeidentifyTemplateUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating DeidentifyTemplate %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -4426,7 +4420,6 @@ func resourceDataLossPreventionDeidentifyTemplateUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -4461,8 +4454,6 @@ func resourceDataLossPreventionDeidentifyTemplateDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DeidentifyTemplate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -4472,7 +4463,6 @@ func resourceDataLossPreventionDeidentifyTemplateDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DeidentifyTemplate") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go deleted file mode 100644 index 22f591fb6ae..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_discovery_config.go +++ /dev/null @@ -1,3063 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package datalossprevention - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceDataLossPreventionDiscoveryConfig() *schema.Resource { - return &schema.Resource{ - Create: resourceDataLossPreventionDiscoveryConfigCreate, - Read: resourceDataLossPreventionDiscoveryConfigRead, - Update: resourceDataLossPreventionDiscoveryConfigUpdate, - Delete: resourceDataLossPreventionDiscoveryConfigDelete, - - Importer: &schema.ResourceImporter{ - State: resourceDataLossPreventionDiscoveryConfigImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Location to create the discovery config in.`, - }, - "parent": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The parent of the discovery config in any of the following formats: - -* 'projects/{{project}}/locations/{{location}}' -* 'organizations/{{organization_id}}/locations/{{location}}'`, - }, - "actions": { - Type: schema.TypeList, - Optional: true, - Description: `Actions to execute at the completion of scanning`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "export_data": { - Type: schema.TypeList, - Optional: true, - Description: `Export data profiles into a provided location`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "profile_table": { - Type: schema.TypeList, - Optional: true, - Description: `Store all table and column profiles in an existing table or a new table in an existing dataset. Each re-generation will result in a new row in BigQuery`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "dataset_id": { - Type: schema.TypeString, - Optional: true, - Description: `Dataset Id of the table`, - }, - "project_id": { - Type: schema.TypeString, - Optional: true, - Description: `The Google Cloud Platform project ID of the project containing the table. If omitted, the project ID is inferred from the API call.`, - }, - "table_id": { - Type: schema.TypeString, - Optional: true, - Description: `Name of the table`, - }, - }, - }, - }, - }, - }, - }, - "pub_sub_notification": { - Type: schema.TypeList, - Optional: true, - Description: `Publish a message into the Pub/Sub topic.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "detail_of_message": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"TABLE_PROFILE", "RESOURCE_NAME", ""}), - Description: `How much data to include in the pub/sub message. Possible values: ["TABLE_PROFILE", "RESOURCE_NAME"]`, - }, - "event": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"NEW_PROFILE", "CHANGED_PROFILE", "SCORE_INCREASED", "ERROR_CHANGED", ""}), - Description: `The type of event that triggers a Pub/Sub. At most one PubSubNotification per EventType is permitted. Possible values: ["NEW_PROFILE", "CHANGED_PROFILE", "SCORE_INCREASED", "ERROR_CHANGED"]`, - }, - "pubsub_condition": { - Type: schema.TypeList, - Optional: true, - Description: `Conditions for triggering pubsub`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expressions": { - Type: schema.TypeList, - Optional: true, - Description: `An expression`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "conditions": { - Type: schema.TypeList, - Optional: true, - Description: `Conditions to apply to the expression`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "minimum_risk_score": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"HIGH", "MEDIUM_OR_HIGH", ""}), - Description: `The minimum data risk score that triggers the condition. Possible values: ["HIGH", "MEDIUM_OR_HIGH"]`, - }, - "minimum_sensitivity_score": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"HIGH", "MEDIUM_OR_HIGH", ""}), - Description: `The minimum sensitivity level that triggers the condition. Possible values: ["HIGH", "MEDIUM_OR_HIGH"]`, - }, - }, - }, - }, - "logical_operator": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"OR", "AND", ""}), - Description: `The operator to apply to the collection of conditions Possible values: ["OR", "AND"]`, - }, - }, - }, - }, - }, - }, - }, - "topic": { - Type: schema.TypeString, - Optional: true, - Description: `Cloud Pub/Sub topic to send notifications to. Format is projects/{project}/topics/{topic}.`, - }, - }, - }, - }, - }, - }, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - Description: `Display Name (max 1000 Chars)`, - }, - "inspect_templates": { - Type: schema.TypeList, - Optional: true, - Description: `Detection logic for profile generation`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "org_config": { - Type: schema.TypeList, - Optional: true, - Description: `A nested object resource`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "location": { - Type: schema.TypeList, - Optional: true, - Description: `The data to scan folder org or project`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "folder_id": { - Type: schema.TypeString, - Optional: true, - Description: `The ID for the folder within an organization to scan`, - }, - "organization_id": { - Type: schema.TypeString, - Optional: true, - Description: `The ID of an organization to scan`, - }, - }, - }, - }, - "project_id": { - Type: schema.TypeString, - Optional: true, - Description: `The project that will run the scan. The DLP service account that exists within this project must have access to all resources that are profiled, and the cloud DLP API must be enabled.`, - }, - }, - }, - }, - "status": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"RUNNING", "PAUSED", ""}), - Description: `Required. A status for this configuration Possible values: ["RUNNING", "PAUSED"]`, - }, - "targets": { - Type: schema.TypeList, - Optional: true, - Description: `Target to match against for determining what to scan and how frequently`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "big_query_target": { - Type: schema.TypeList, - Optional: true, - Description: `BigQuery target for Discovery. The first target to match a table will be the one applied.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cadence": { - Type: schema.TypeList, - Optional: true, - Description: `How often and when to update profiles. New tables that match both the fiter and conditions are scanned as quickly as possible depending on system capacity.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "schema_modified_cadence": { - Type: schema.TypeList, - Optional: true, - Description: `Governs when to update data profiles when a schema is modified`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "frequency": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY", ""}), - Description: `How frequently profiles may be updated when schemas are modified. Default to monthly Possible values: ["UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY"]`, - }, - "types": { - Type: schema.TypeList, - Optional: true, - Description: `The type of events to consider when deciding if the table's schema has been modified and should have the profile updated. Defaults to NEW_COLUMN. Possible values: ["SCHEMA_NEW_COLUMNS", "SCHEMA_REMOVED_COLUMNS"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"SCHEMA_NEW_COLUMNS", "SCHEMA_REMOVED_COLUMNS"}), - }, - }, - }, - }, - }, - "table_modified_cadence": { - Type: schema.TypeList, - Optional: true, - Description: `Governs when to update profile when a table is modified.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "frequency": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY", ""}), - Description: `How frequently data profiles can be updated when tables are modified. Defaults to never. Possible values: ["UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY"]`, - }, - "types": { - Type: schema.TypeList, - Optional: true, - Description: `The type of events to consider when deciding if the table has been modified and should have the profile updated. Defaults to MODIFIED_TIMESTAMP Possible values: ["TABLE_MODIFIED_TIMESTAMP"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"TABLE_MODIFIED_TIMESTAMP"}), - }, - }, - }, - }, - }, - }, - }, - }, - "conditions": { - Type: schema.TypeList, - Optional: true, - Description: `In addition to matching the filter, these conditions must be true before a profile is generated`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "created_after": { - Type: schema.TypeString, - Optional: true, - Description: `A timestamp in RFC3339 UTC "Zulu" format with nanosecond resolution and upto nine fractional digits.`, - }, - "or_conditions": { - Type: schema.TypeList, - Optional: true, - Description: `At least one of the conditions must be true for a table to be scanned.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "min_age": { - Type: schema.TypeString, - Optional: true, - Description: `Duration format. The minimum age a table must have before Cloud DLP can profile it. Value greater than 1.`, - }, - "min_row_count": { - Type: schema.TypeInt, - Optional: true, - Description: `Minimum number of rows that should be present before Cloud DLP profiles as a table.`, - }, - }, - }, - }, - "type_collection": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"BIG_QUERY_COLLECTION_ALL_TYPES", "BIG_QUERY_COLLECTION_ONLY_SUPPORTED_TYPES", ""}), - Description: `Restrict discovery to categories of table types. Currently view, materialized view, snapshot and non-biglake external tables are supported. Possible values: ["BIG_QUERY_COLLECTION_ALL_TYPES", "BIG_QUERY_COLLECTION_ONLY_SUPPORTED_TYPES"]`, - }, - "types": { - Type: schema.TypeList, - Optional: true, - Description: `Restrict discovery to specific table type`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "types": { - Type: schema.TypeList, - Optional: true, - Description: `A set of BiqQuery table types Possible values: ["BIG_QUERY_TABLE_TYPE_TABLE", "BIG_QUERY_TABLE_TYPE_EXTERNAL_BIG_LAKE"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"BIG_QUERY_TABLE_TYPE_TABLE", "BIG_QUERY_TABLE_TYPE_EXTERNAL_BIG_LAKE"}), - }, - }, - }, - }, - }, - }, - }, - }, - "disabled": { - Type: schema.TypeList, - Optional: true, - Description: `Tables that match this filter will not have profiles created.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "filter": { - Type: schema.TypeList, - Optional: true, - Description: `Required. The tables the discovery cadence applies to. The first target with a matching filter will be the one to apply to a table`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "other_tables": { - Type: schema.TypeList, - Optional: true, - Description: `Catch-all. This should always be the last filter in the list because anything above it will apply first.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "table_reference": { - Type: schema.TypeList, - Optional: true, - Description: `The table to scan. Discovery configurations including this can only include one DiscoveryTarget (the DiscoveryTarget with this TableReference).`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "dataset_id": { - Type: schema.TypeString, - Required: true, - Description: `Dataset ID of the table.`, - }, - "table_id": { - Type: schema.TypeString, - Required: true, - Description: `Name of the table.`, - }, - }, - }, - }, - "tables": { - Type: schema.TypeList, - Optional: true, - Description: `A specific set of tables for this filter to apply to. A table collection must be specified in only one filter per config.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "include_regexes": { - Type: schema.TypeList, - Optional: true, - Description: `A collection of regular expressions to match a BQ table against.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "patterns": { - Type: schema.TypeList, - Optional: true, - Description: `A single BigQuery regular expression pattern to match against one or more tables, datasets, or projects that contain BigQuery tables.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "dataset_id_regex": { - Type: schema.TypeString, - Optional: true, - Description: `if unset, this property matches all datasets`, - }, - "project_id_regex": { - Type: schema.TypeString, - Optional: true, - Description: `For organizations, if unset, will match all projects. Has no effect for data profile configurations created within a project.`, - }, - "table_id_regex": { - Type: schema.TypeString, - Optional: true, - Description: `if unset, this property matches all tables`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "cloud_sql_target": { - Type: schema.TypeList, - Optional: true, - Description: `Cloud SQL target for Discovery. The first target to match a table will be the one applied.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "filter": { - Type: schema.TypeList, - Required: true, - Description: `Required. The tables the discovery cadence applies to. The first target with a matching filter will be the one to apply to a table.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "collection": { - Type: schema.TypeList, - Optional: true, - Description: `A specific set of database resources for this filter to apply to.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "include_regexes": { - Type: schema.TypeList, - Optional: true, - Description: `A collection of regular expressions to match a database resource against.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "patterns": { - Type: schema.TypeList, - Optional: true, - Description: `A group of regular expression patterns to match against one or more database resources. Maximum of 100 entries. The sum of all regular expressions' length can't exceed 10 KiB.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database_regex": { - Type: schema.TypeString, - Optional: true, - Description: `Regex to test the database name against. If empty, all databases match.`, - }, - "database_resource_name_regex": { - Type: schema.TypeString, - Optional: true, - Description: `Regex to test the database resource's name against. An example of a database resource name is a table's name. Other database resource names like view names could be included in the future. If empty, all database resources match.'`, - }, - "instance_regex": { - Type: schema.TypeString, - Optional: true, - Description: `Regex to test the instance name against. If empty, all instances match.`, - }, - "project_id_regex": { - Type: schema.TypeString, - Optional: true, - Description: `For organizations, if unset, will match all projects. Has no effect for data profile configurations created within a project.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "database_resource_reference": { - Type: schema.TypeList, - Optional: true, - Description: `The database resource to scan. Targets including this can only include one target (the target with this database resource reference).`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database": { - Type: schema.TypeString, - Required: true, - Description: `Required. Name of a database within the instance.`, - }, - "database_resource": { - Type: schema.TypeString, - Required: true, - Description: `Required. Name of a database resource, for example, a table within the database.`, - }, - "instance": { - Type: schema.TypeString, - Required: true, - Description: `Required. The instance where this resource is located. For example: Cloud SQL instance ID.`, - }, - "project_id": { - Type: schema.TypeString, - Required: true, - Description: `Required. If within a project-level config, then this must match the config's project ID.`, - }, - }, - }, - }, - "others": { - Type: schema.TypeList, - Optional: true, - Description: `Catch-all. This should always be the last target in the list because anything above it will apply first. Should only appear once in a configuration. If none is specified, a default one will be added automatically.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - }, - }, - }, - "conditions": { - Type: schema.TypeList, - Optional: true, - Description: `In addition to matching the filter, these conditions must be true before a profile is generated.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "database_engines": { - Type: schema.TypeList, - Optional: true, - Description: `Database engines that should be profiled. Optional. Defaults to ALL_SUPPORTED_DATABASE_ENGINES if unspecified. Possible values: ["ALL_SUPPORTED_DATABASE_ENGINES", "MYSQL", "POSTGRES"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"ALL_SUPPORTED_DATABASE_ENGINES", "MYSQL", "POSTGRES"}), - }, - }, - "types": { - Type: schema.TypeList, - Optional: true, - Description: `Data profiles will only be generated for the database resource types specified in this field. If not specified, defaults to [DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES]. Possible values: ["DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES", "DATABASE_RESOURCE_TYPE_TABLE"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"DATABASE_RESOURCE_TYPE_ALL_SUPPORTED_TYPES", "DATABASE_RESOURCE_TYPE_TABLE"}), - }, - }, - }, - }, - }, - "disabled": { - Type: schema.TypeList, - Optional: true, - Description: `Disable profiling for database resources that match this filter.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - "generation_cadence": { - Type: schema.TypeList, - Optional: true, - Description: `How often and when to update profiles. New tables that match both the filter and conditions are scanned as quickly as possible depending on system capacity.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "refresh_frequency": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY", ""}), - Description: `Data changes (non-schema changes) in Cloud SQL tables can't trigger reprofiling. If you set this field, profiles are refreshed at this frequency regardless of whether the underlying tables have changes. Defaults to never. Possible values: ["UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY"]`, - }, - "schema_modified_cadence": { - Type: schema.TypeList, - Optional: true, - Description: `Governs when to update data profiles when a schema is modified`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "frequency": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY", ""}), - Description: `Frequency to regenerate data profiles when the schema is modified. Defaults to monthly. Possible values: ["UPDATE_FREQUENCY_NEVER", "UPDATE_FREQUENCY_DAILY", "UPDATE_FREQUENCY_MONTHLY"]`, - }, - "types": { - Type: schema.TypeList, - Optional: true, - Description: `The types of schema modifications to consider. Defaults to NEW_COLUMNS. Possible values: ["NEW_COLUMNS", "REMOVED_COLUMNS"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"NEW_COLUMNS", "REMOVED_COLUMNS"}), - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "secrets_target": { - Type: schema.TypeList, - Optional: true, - Description: `Discovery target that looks for credentials and secrets stored in cloud resource metadata and reports them as vulnerabilities to Security Command Center. Only one target of this type is allowed.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - }, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The creation timestamp of a DiscoveryConfig.`, - }, - "errors": { - Type: schema.TypeList, - Computed: true, - Description: `Output only. A stream of errors encountered when the config was activated. Repeated errors may result in the config automatically being paused. Output only field. Will return the last 100 errors. Whenever the config is modified this list will be cleared.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "details": { - Type: schema.TypeList, - Optional: true, - Description: `Detailed error codes and messages.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "code": { - Type: schema.TypeInt, - Optional: true, - Description: `The status code, which should be an enum value of google.rpc.Code.`, - }, - "details": { - Type: schema.TypeList, - Optional: true, - Description: `A list of messages that carry the error details.`, - Elem: &schema.Schema{ - Type: schema.TypeMap, - }, - }, - "message": { - Type: schema.TypeString, - Optional: true, - Description: `A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.`, - }, - }, - }, - }, - "timestamp": { - Type: schema.TypeString, - Optional: true, - Description: `The times the error occurred. List includes the oldest timestamp and the last 9 timestamps.`, - }, - }, - }, - }, - "last_run_time": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The timestamp of the last time this config was executed`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `Unique resource name for the DiscoveryConfig, assigned by the service when the DiscoveryConfig is created.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The last update timestamp of a DiscoveryConfig.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceDataLossPreventionDiscoveryConfigCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - displayNameProp, err := expandDataLossPreventionDiscoveryConfigDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - orgConfigProp, err := expandDataLossPreventionDiscoveryConfigOrgConfig(d.Get("org_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("org_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(orgConfigProp)) && (ok || !reflect.DeepEqual(v, orgConfigProp)) { - obj["orgConfig"] = orgConfigProp - } - inspectTemplatesProp, err := expandDataLossPreventionDiscoveryConfigInspectTemplates(d.Get("inspect_templates"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("inspect_templates"); !tpgresource.IsEmptyValue(reflect.ValueOf(inspectTemplatesProp)) && (ok || !reflect.DeepEqual(v, inspectTemplatesProp)) { - obj["inspectTemplates"] = inspectTemplatesProp - } - actionsProp, err := expandDataLossPreventionDiscoveryConfigActions(d.Get("actions"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("actions"); !tpgresource.IsEmptyValue(reflect.ValueOf(actionsProp)) && (ok || !reflect.DeepEqual(v, actionsProp)) { - obj["actions"] = actionsProp - } - targetsProp, err := expandDataLossPreventionDiscoveryConfigTargets(d.Get("targets"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("targets"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetsProp)) && (ok || !reflect.DeepEqual(v, targetsProp)) { - obj["targets"] = targetsProp - } - statusProp, err := expandDataLossPreventionDiscoveryConfigStatus(d.Get("status"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("status"); !tpgresource.IsEmptyValue(reflect.ValueOf(statusProp)) && (ok || !reflect.DeepEqual(v, statusProp)) { - obj["status"] = statusProp - } - - obj, err = resourceDataLossPreventionDiscoveryConfigEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataLossPreventionBasePath}}{{parent}}/discoveryConfigs") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new DiscoveryConfig: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating DiscoveryConfig: %s", err) - } - if err := d.Set("name", flattenDataLossPreventionDiscoveryConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/discoveryConfigs/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating DiscoveryConfig %q: %#v", d.Id(), res) - - return resourceDataLossPreventionDiscoveryConfigRead(d, meta) -} - -func resourceDataLossPreventionDiscoveryConfigRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataLossPreventionBasePath}}{{parent}}/discoveryConfigs/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataLossPreventionDiscoveryConfig %q", d.Id())) - } - - res, err = resourceDataLossPreventionDiscoveryConfigDecoder(d, meta, res) - if err != nil { - return err - } - - if res == nil { - // Decoding the object has resulted in it being gone. It may be marked deleted - log.Printf("[DEBUG] Removing DataLossPreventionDiscoveryConfig because it no longer exists.") - d.SetId("") - return nil - } - - if err := d.Set("name", flattenDataLossPreventionDiscoveryConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("display_name", flattenDataLossPreventionDiscoveryConfigDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("org_config", flattenDataLossPreventionDiscoveryConfigOrgConfig(res["orgConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("inspect_templates", flattenDataLossPreventionDiscoveryConfigInspectTemplates(res["inspectTemplates"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("actions", flattenDataLossPreventionDiscoveryConfigActions(res["actions"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("targets", flattenDataLossPreventionDiscoveryConfigTargets(res["targets"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("errors", flattenDataLossPreventionDiscoveryConfigErrors(res["errors"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("create_time", flattenDataLossPreventionDiscoveryConfigCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("update_time", flattenDataLossPreventionDiscoveryConfigUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("last_run_time", flattenDataLossPreventionDiscoveryConfigLastRunTime(res["lastRunTime"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - if err := d.Set("status", flattenDataLossPreventionDiscoveryConfigStatus(res["status"], d, config)); err != nil { - return fmt.Errorf("Error reading DiscoveryConfig: %s", err) - } - - return nil -} - -func resourceDataLossPreventionDiscoveryConfigUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - displayNameProp, err := expandDataLossPreventionDiscoveryConfigDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - orgConfigProp, err := expandDataLossPreventionDiscoveryConfigOrgConfig(d.Get("org_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("org_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, orgConfigProp)) { - obj["orgConfig"] = orgConfigProp - } - inspectTemplatesProp, err := expandDataLossPreventionDiscoveryConfigInspectTemplates(d.Get("inspect_templates"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("inspect_templates"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, inspectTemplatesProp)) { - obj["inspectTemplates"] = inspectTemplatesProp - } - actionsProp, err := expandDataLossPreventionDiscoveryConfigActions(d.Get("actions"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("actions"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, actionsProp)) { - obj["actions"] = actionsProp - } - targetsProp, err := expandDataLossPreventionDiscoveryConfigTargets(d.Get("targets"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("targets"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetsProp)) { - obj["targets"] = targetsProp - } - statusProp, err := expandDataLossPreventionDiscoveryConfigStatus(d.Get("status"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("status"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, statusProp)) { - obj["status"] = statusProp - } - - obj, err = resourceDataLossPreventionDiscoveryConfigUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataLossPreventionBasePath}}{{parent}}/discoveryConfigs/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating DiscoveryConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("display_name") { - updateMask = append(updateMask, "displayName") - } - - if d.HasChange("org_config") { - updateMask = append(updateMask, "orgConfig") - } - - if d.HasChange("inspect_templates") { - updateMask = append(updateMask, "inspectTemplates") - } - - if d.HasChange("actions") { - updateMask = append(updateMask, "actions") - } - - if d.HasChange("targets") { - updateMask = append(updateMask, "targets") - } - - if d.HasChange("status") { - updateMask = append(updateMask, "status") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating DiscoveryConfig %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating DiscoveryConfig %q: %#v", d.Id(), res) - } - - } - - return resourceDataLossPreventionDiscoveryConfigRead(d, meta) -} - -func resourceDataLossPreventionDiscoveryConfigDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{DataLossPreventionBasePath}}{{parent}}/discoveryConfigs/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting DiscoveryConfig %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "DiscoveryConfig") - } - - log.Printf("[DEBUG] Finished deleting DiscoveryConfig %q: %#v", d.Id(), res) - return nil -} - -func resourceDataLossPreventionDiscoveryConfigImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - - // Custom import to handle parent possibilities - if err := tpgresource.ParseImportId([]string{"(?P.+)"}, d, config); err != nil { - return nil, err - } - parts := strings.Split(d.Get("name").(string), "/") - if len(parts) == 6 { - if err := d.Set("name", parts[5]); err != nil { - return nil, fmt.Errorf("Error setting name: %s", err) - } - } else if len(parts) == 4 { - if err := d.Set("name", parts[3]); err != nil { - return nil, fmt.Errorf("Error setting name: %s", err) - } - } else { - return nil, fmt.Errorf("Unexpected import id: %s, expected form {{parent}}/discoveryConfig/{{name}}", d.Get("name").(string)) - } - // Remove "/discoveryConfig/{{name}}" from the id - parts = parts[:len(parts)-2] - if err := d.Set("parent", strings.Join(parts, "/")); err != nil { - return nil, fmt.Errorf("Error setting parent: %s", err) - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/discoveryConfigs/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenDataLossPreventionDiscoveryConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenDataLossPreventionDiscoveryConfigDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigOrgConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["project_id"] = - flattenDataLossPreventionDiscoveryConfigOrgConfigProjectId(original["projectId"], d, config) - transformed["location"] = - flattenDataLossPreventionDiscoveryConfigOrgConfigLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigOrgConfigProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigOrgConfigLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["organization_id"] = - flattenDataLossPreventionDiscoveryConfigOrgConfigLocationOrganizationId(original["organizationId"], d, config) - transformed["folder_id"] = - flattenDataLossPreventionDiscoveryConfigOrgConfigLocationFolderId(original["folderId"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigOrgConfigLocationOrganizationId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigOrgConfigLocationFolderId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigInspectTemplates(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "export_data": flattenDataLossPreventionDiscoveryConfigActionsExportData(original["exportData"], d, config), - "pub_sub_notification": flattenDataLossPreventionDiscoveryConfigActionsPubSubNotification(original["pubSubNotification"], d, config), - }) - } - return transformed -} -func flattenDataLossPreventionDiscoveryConfigActionsExportData(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["profile_table"] = - flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTable(original["profileTable"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTable(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["project_id"] = - flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTableProjectId(original["projectId"], d, config) - transformed["dataset_id"] = - flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTableDatasetId(original["datasetId"], d, config) - transformed["table_id"] = - flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTableTableId(original["tableId"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTableProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTableDatasetId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsExportDataProfileTableTableId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotification(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["topic"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationTopic(original["topic"], d, config) - transformed["event"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationEvent(original["event"], d, config) - transformed["pubsub_condition"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubCondition(original["pubsubCondition"], d, config) - transformed["detail_of_message"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationDetailOfMessage(original["detailOfMessage"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationTopic(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationEvent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubCondition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expressions"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressions(original["expressions"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["logical_operator"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsLogicalOperator(original["logicalOperator"], d, config) - transformed["conditions"] = - flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditions(original["conditions"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsLogicalOperator(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "minimum_risk_score": flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumRiskScore(original["minimumRiskScore"], d, config), - "minimum_sensitivity_score": flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumSensitivityScore(original["minimumSensitivityScore"], d, config), - }) - } - return transformed -} -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumRiskScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumSensitivityScore(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigActionsPubSubNotificationDetailOfMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargets(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "big_query_target": flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTarget(original["bigQueryTarget"], d, config), - "cloud_sql_target": flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTarget(original["cloudSqlTarget"], d, config), - "secrets_target": flattenDataLossPreventionDiscoveryConfigTargetsSecretsTarget(original["secretsTarget"], d, config), - }) - } - return transformed -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTarget(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["filter"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilter(original["filter"], d, config) - transformed["conditions"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditions(original["conditions"], d, config) - transformed["cadence"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadence(original["cadence"], d, config) - transformed["disabled"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetDisabled(original["disabled"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["tables"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTables(original["tables"], d, config) - transformed["other_tables"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterOtherTables(original["otherTables"], d, config) - transformed["table_reference"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReference(original["tableReference"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTables(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["include_regexes"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexes(original["includeRegexes"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["patterns"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatterns(original["patterns"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatterns(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "project_id_regex": flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsProjectIdRegex(original["projectIdRegex"], d, config), - "dataset_id_regex": flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsDatasetIdRegex(original["datasetIdRegex"], d, config), - "table_id_regex": flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsTableIdRegex(original["tableIdRegex"], d, config), - }) - } - return transformed -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsProjectIdRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsDatasetIdRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsTableIdRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterOtherTables(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReference(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["dataset_id"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceDatasetId(original["datasetId"], d, config) - transformed["table_id"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceTableId(original["tableId"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceDatasetId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceTableId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["created_after"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsCreatedAfter(original["createdAfter"], d, config) - transformed["or_conditions"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditions(original["orConditions"], d, config) - transformed["types"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypes(original["types"], d, config) - transformed["type_collection"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypeCollection(original["typeCollection"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsCreatedAfter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["min_age"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinAge(original["minAge"], d, config) - transformed["min_row_count"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinRowCount(original["minRowCount"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinAge(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinRowCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["types"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypesTypes(original["types"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypesTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypeCollection(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadence(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["schema_modified_cadence"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadence(original["schemaModifiedCadence"], d, config) - transformed["table_modified_cadence"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadence(original["tableModifiedCadence"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadence(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["types"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceTypes(original["types"], d, config) - transformed["frequency"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceFrequency(original["frequency"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceFrequency(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadence(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["types"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceTypes(original["types"], d, config) - transformed["frequency"] = - flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceFrequency(original["frequency"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceFrequency(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsBigQueryTargetDisabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTarget(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["filter"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilter(original["filter"], d, config) - transformed["conditions"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditions(original["conditions"], d, config) - transformed["generation_cadence"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadence(original["generationCadence"], d, config) - transformed["disabled"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetDisabled(original["disabled"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["collection"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollection(original["collection"], d, config) - transformed["others"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterOthers(original["others"], d, config) - transformed["database_resource_reference"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReference(original["databaseResourceReference"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollection(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["include_regexes"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexes(original["includeRegexes"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["patterns"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatterns(original["patterns"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatterns(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "project_id_regex": flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsProjectIdRegex(original["projectIdRegex"], d, config), - "instance_regex": flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsInstanceRegex(original["instanceRegex"], d, config), - "database_regex": flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseRegex(original["databaseRegex"], d, config), - "database_resource_name_regex": flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseResourceNameRegex(original["databaseResourceNameRegex"], d, config), - }) - } - return transformed -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsProjectIdRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsInstanceRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseResourceNameRegex(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterOthers(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReference(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["project_id"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceProjectId(original["projectId"], d, config) - transformed["instance"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceInstance(original["instance"], d, config) - transformed["database"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabase(original["database"], d, config) - transformed["database_resource"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabaseResource(original["databaseResource"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceInstance(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabase(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabaseResource(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["database_engines"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsDatabaseEngines(original["databaseEngines"], d, config) - transformed["types"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsTypes(original["types"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsDatabaseEngines(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadence(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["schema_modified_cadence"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadence(original["schemaModifiedCadence"], d, config) - transformed["refresh_frequency"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceRefreshFrequency(original["refreshFrequency"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadence(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["types"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceTypes(original["types"], d, config) - transformed["frequency"] = - flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceFrequency(original["frequency"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceFrequency(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceRefreshFrequency(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetDisabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDataLossPreventionDiscoveryConfigTargetsSecretsTarget(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDataLossPreventionDiscoveryConfigErrors(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "details": flattenDataLossPreventionDiscoveryConfigErrorsDetails(original["details"], d, config), - "timestamp": flattenDataLossPreventionDiscoveryConfigErrorsTimestamp(original["timestamp"], d, config), - }) - } - return transformed -} -func flattenDataLossPreventionDiscoveryConfigErrorsDetails(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["code"] = - flattenDataLossPreventionDiscoveryConfigErrorsDetailsCode(original["code"], d, config) - transformed["message"] = - flattenDataLossPreventionDiscoveryConfigErrorsDetailsMessage(original["message"], d, config) - transformed["details"] = - flattenDataLossPreventionDiscoveryConfigErrorsDetailsDetails(original["details"], d, config) - return []interface{}{transformed} -} -func flattenDataLossPreventionDiscoveryConfigErrorsDetailsCode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenDataLossPreventionDiscoveryConfigErrorsDetailsMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigErrorsDetailsDetails(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigErrorsTimestamp(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigLastRunTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataLossPreventionDiscoveryConfigStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandDataLossPreventionDiscoveryConfigDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigOrgConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProjectId, err := expandDataLossPreventionDiscoveryConfigOrgConfigProjectId(original["project_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectId"] = transformedProjectId - } - - transformedLocation, err := expandDataLossPreventionDiscoveryConfigOrgConfigLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigOrgConfigProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigOrgConfigLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedOrganizationId, err := expandDataLossPreventionDiscoveryConfigOrgConfigLocationOrganizationId(original["organization_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOrganizationId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["organizationId"] = transformedOrganizationId - } - - transformedFolderId, err := expandDataLossPreventionDiscoveryConfigOrgConfigLocationFolderId(original["folder_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFolderId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["folderId"] = transformedFolderId - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigOrgConfigLocationOrganizationId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigOrgConfigLocationFolderId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigInspectTemplates(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExportData, err := expandDataLossPreventionDiscoveryConfigActionsExportData(original["export_data"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExportData); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["exportData"] = transformedExportData - } - - transformedPubSubNotification, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotification(original["pub_sub_notification"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPubSubNotification); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pubSubNotification"] = transformedPubSubNotification - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsExportData(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProfileTable, err := expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTable(original["profile_table"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProfileTable); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["profileTable"] = transformedProfileTable - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTable(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProjectId, err := expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTableProjectId(original["project_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectId"] = transformedProjectId - } - - transformedDatasetId, err := expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTableDatasetId(original["dataset_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatasetId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["datasetId"] = transformedDatasetId - } - - transformedTableId, err := expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTableTableId(original["table_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTableId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tableId"] = transformedTableId - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTableProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTableDatasetId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsExportDataProfileTableTableId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotification(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTopic, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationTopic(original["topic"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTopic); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["topic"] = transformedTopic - } - - transformedEvent, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationEvent(original["event"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEvent); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["event"] = transformedEvent - } - - transformedPubsubCondition, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubCondition(original["pubsub_condition"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPubsubCondition); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pubsubCondition"] = transformedPubsubCondition - } - - transformedDetailOfMessage, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationDetailOfMessage(original["detail_of_message"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDetailOfMessage); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["detailOfMessage"] = transformedDetailOfMessage - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationTopic(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationEvent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubCondition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpressions, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressions(original["expressions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpressions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expressions"] = transformedExpressions - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedLogicalOperator, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsLogicalOperator(original["logical_operator"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLogicalOperator); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["logicalOperator"] = transformedLogicalOperator - } - - transformedConditions, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditions(original["conditions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConditions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["conditions"] = transformedConditions - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsLogicalOperator(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMinimumRiskScore, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumRiskScore(original["minimum_risk_score"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinimumRiskScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minimumRiskScore"] = transformedMinimumRiskScore - } - - transformedMinimumSensitivityScore, err := expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumSensitivityScore(original["minimum_sensitivity_score"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinimumSensitivityScore); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minimumSensitivityScore"] = transformedMinimumSensitivityScore - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumRiskScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationPubsubConditionExpressionsConditionsMinimumSensitivityScore(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigActionsPubSubNotificationDetailOfMessage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargets(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedBigQueryTarget, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTarget(original["big_query_target"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBigQueryTarget); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["bigQueryTarget"] = transformedBigQueryTarget - } - - transformedCloudSqlTarget, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTarget(original["cloud_sql_target"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCloudSqlTarget); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["cloudSqlTarget"] = transformedCloudSqlTarget - } - - transformedSecretsTarget, err := expandDataLossPreventionDiscoveryConfigTargetsSecretsTarget(original["secrets_target"], d, config) - if err != nil { - return nil, err - } else { - transformed["secretsTarget"] = transformedSecretsTarget - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTarget(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedFilter, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilter(original["filter"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFilter); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["filter"] = transformedFilter - } - - transformedConditions, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditions(original["conditions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConditions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["conditions"] = transformedConditions - } - - transformedCadence, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadence(original["cadence"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCadence); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["cadence"] = transformedCadence - } - - transformedDisabled, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetDisabled(original["disabled"], d, config) - if err != nil { - return nil, err - } else { - transformed["disabled"] = transformedDisabled - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTables, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTables(original["tables"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTables); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tables"] = transformedTables - } - - transformedOtherTables, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterOtherTables(original["other_tables"], d, config) - if err != nil { - return nil, err - } else { - transformed["otherTables"] = transformedOtherTables - } - - transformedTableReference, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReference(original["table_reference"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTableReference); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tableReference"] = transformedTableReference - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTables(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedIncludeRegexes, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexes(original["include_regexes"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedIncludeRegexes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["includeRegexes"] = transformedIncludeRegexes - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPatterns, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatterns(original["patterns"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPatterns); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["patterns"] = transformedPatterns - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatterns(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProjectIdRegex, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsProjectIdRegex(original["project_id_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectIdRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectIdRegex"] = transformedProjectIdRegex - } - - transformedDatasetIdRegex, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsDatasetIdRegex(original["dataset_id_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatasetIdRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["datasetIdRegex"] = transformedDatasetIdRegex - } - - transformedTableIdRegex, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsTableIdRegex(original["table_id_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTableIdRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tableIdRegex"] = transformedTableIdRegex - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsProjectIdRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsDatasetIdRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTablesIncludeRegexesPatternsTableIdRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterOtherTables(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReference(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDatasetId, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceDatasetId(original["dataset_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatasetId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["datasetId"] = transformedDatasetId - } - - transformedTableId, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceTableId(original["table_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTableId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tableId"] = transformedTableId - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceDatasetId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetFilterTableReferenceTableId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCreatedAfter, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsCreatedAfter(original["created_after"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCreatedAfter); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["createdAfter"] = transformedCreatedAfter - } - - transformedOrConditions, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditions(original["or_conditions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOrConditions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["orConditions"] = transformedOrConditions - } - - transformedTypes, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypes(original["types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["types"] = transformedTypes - } - - transformedTypeCollection, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypeCollection(original["type_collection"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypeCollection); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["typeCollection"] = transformedTypeCollection - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsCreatedAfter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMinAge, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinAge(original["min_age"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinAge); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minAge"] = transformedMinAge - } - - transformedMinRowCount, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinRowCount(original["min_row_count"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinRowCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minRowCount"] = transformedMinRowCount - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinAge(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsOrConditionsMinRowCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTypes, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypesTypes(original["types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["types"] = transformedTypes - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypesTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetConditionsTypeCollection(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadence(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSchemaModifiedCadence, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadence(original["schema_modified_cadence"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSchemaModifiedCadence); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["schemaModifiedCadence"] = transformedSchemaModifiedCadence - } - - transformedTableModifiedCadence, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadence(original["table_modified_cadence"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTableModifiedCadence); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tableModifiedCadence"] = transformedTableModifiedCadence - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadence(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTypes, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceTypes(original["types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["types"] = transformedTypes - } - - transformedFrequency, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceFrequency(original["frequency"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFrequency); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["frequency"] = transformedFrequency - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceSchemaModifiedCadenceFrequency(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadence(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTypes, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceTypes(original["types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["types"] = transformedTypes - } - - transformedFrequency, err := expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceFrequency(original["frequency"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFrequency); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["frequency"] = transformedFrequency - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetCadenceTableModifiedCadenceFrequency(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsBigQueryTargetDisabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTarget(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedFilter, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilter(original["filter"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFilter); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["filter"] = transformedFilter - } - - transformedConditions, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditions(original["conditions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConditions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["conditions"] = transformedConditions - } - - transformedGenerationCadence, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadence(original["generation_cadence"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedGenerationCadence); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["generationCadence"] = transformedGenerationCadence - } - - transformedDisabled, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetDisabled(original["disabled"], d, config) - if err != nil { - return nil, err - } else { - transformed["disabled"] = transformedDisabled - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCollection, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollection(original["collection"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCollection); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["collection"] = transformedCollection - } - - transformedOthers, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterOthers(original["others"], d, config) - if err != nil { - return nil, err - } else { - transformed["others"] = transformedOthers - } - - transformedDatabaseResourceReference, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReference(original["database_resource_reference"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatabaseResourceReference); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["databaseResourceReference"] = transformedDatabaseResourceReference - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollection(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedIncludeRegexes, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexes(original["include_regexes"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedIncludeRegexes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["includeRegexes"] = transformedIncludeRegexes - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPatterns, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatterns(original["patterns"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPatterns); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["patterns"] = transformedPatterns - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatterns(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProjectIdRegex, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsProjectIdRegex(original["project_id_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectIdRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectIdRegex"] = transformedProjectIdRegex - } - - transformedInstanceRegex, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsInstanceRegex(original["instance_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedInstanceRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["instanceRegex"] = transformedInstanceRegex - } - - transformedDatabaseRegex, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseRegex(original["database_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatabaseRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["databaseRegex"] = transformedDatabaseRegex - } - - transformedDatabaseResourceNameRegex, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseResourceNameRegex(original["database_resource_name_regex"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatabaseResourceNameRegex); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["databaseResourceNameRegex"] = transformedDatabaseResourceNameRegex - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsProjectIdRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsInstanceRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterCollectionIncludeRegexesPatternsDatabaseResourceNameRegex(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterOthers(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReference(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProjectId, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceProjectId(original["project_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectId"] = transformedProjectId - } - - transformedInstance, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceInstance(original["instance"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedInstance); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["instance"] = transformedInstance - } - - transformedDatabase, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabase(original["database"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatabase); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["database"] = transformedDatabase - } - - transformedDatabaseResource, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabaseResource(original["database_resource"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatabaseResource); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["databaseResource"] = transformedDatabaseResource - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceInstance(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabase(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetFilterDatabaseResourceReferenceDatabaseResource(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDatabaseEngines, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsDatabaseEngines(original["database_engines"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDatabaseEngines); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["databaseEngines"] = transformedDatabaseEngines - } - - transformedTypes, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsTypes(original["types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["types"] = transformedTypes - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsDatabaseEngines(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetConditionsTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadence(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSchemaModifiedCadence, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadence(original["schema_modified_cadence"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSchemaModifiedCadence); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["schemaModifiedCadence"] = transformedSchemaModifiedCadence - } - - transformedRefreshFrequency, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceRefreshFrequency(original["refresh_frequency"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRefreshFrequency); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["refreshFrequency"] = transformedRefreshFrequency - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadence(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTypes, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceTypes(original["types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["types"] = transformedTypes - } - - transformedFrequency, err := expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceFrequency(original["frequency"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFrequency); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["frequency"] = transformedFrequency - } - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceSchemaModifiedCadenceFrequency(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetGenerationCadenceRefreshFrequency(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsCloudSqlTargetDisabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigTargetsSecretsTarget(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDataLossPreventionDiscoveryConfigStatus(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func resourceDataLossPreventionDiscoveryConfigEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - newObj := make(map[string]interface{}) - newObj["discoveryConfig"] = obj - return newObj, nil -} - -func resourceDataLossPreventionDiscoveryConfigUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - newObj := make(map[string]interface{}) - newObj["discoveryConfig"] = obj - return newObj, nil -} - -func resourceDataLossPreventionDiscoveryConfigDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - v, ok := res["discoveryConfig"] - if !ok || v == nil { - return res, nil - } - - return v.(map[string]interface{}), nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_sweeper.go deleted file mode 100644 index a1a9bc7c344..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_discovery_config_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package datalossprevention - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("DataLossPreventionDiscoveryConfig", testSweepDataLossPreventionDiscoveryConfig) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepDataLossPreventionDiscoveryConfig(region string) error { - resourceName := "DataLossPreventionDiscoveryConfig" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://dlp.googleapis.com/v2/{{parent}}/discoveryConfigs", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["discoveryConfigs"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://dlp.googleapis.com/v2/{{parent}}/discoveryConfigs/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go index 878417adc2a..6276585b154 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_inspect_template.go @@ -20,7 +20,6 @@ package datalossprevention import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -336,14 +335,9 @@ at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built Description: `Configuration of findings limit given for specified infoTypes.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "max_findings": { - Type: schema.TypeInt, - Required: true, - Description: `Max findings limit for the given infoType.`, - }, "info_type": { Type: schema.TypeList, - Optional: true, + Required: true, Description: `Type of information the findings limit applies to. Only one limit per infoType should be provided. If InfoTypeLimit does not have an infoType, the DLP API applies the limit against all infoTypes that are found but not specified in another InfoTypeLimit.`, @@ -380,6 +374,11 @@ at https://cloud.google.com/dlp/docs/infotypes-reference when specifying a built }, }, }, + "max_findings": { + Type: schema.TypeInt, + Required: true, + Description: `Max findings limit for the given infoType.`, + }, }, }, }, @@ -790,7 +789,6 @@ func resourceDataLossPreventionInspectTemplateCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -799,7 +797,6 @@ func resourceDataLossPreventionInspectTemplateCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating InspectTemplate: %s", err) @@ -839,14 +836,12 @@ func resourceDataLossPreventionInspectTemplateRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataLossPreventionInspectTemplate %q", d.Id())) @@ -920,7 +915,6 @@ func resourceDataLossPreventionInspectTemplateUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating InspectTemplate %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -956,7 +950,6 @@ func resourceDataLossPreventionInspectTemplateUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -991,8 +984,6 @@ func resourceDataLossPreventionInspectTemplateDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting InspectTemplate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1002,7 +993,6 @@ func resourceDataLossPreventionInspectTemplateDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "InspectTemplate") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go index 698f4622bd0..f612de5c808 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_job_trigger.go @@ -20,7 +20,6 @@ package datalossprevention import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -215,8 +214,7 @@ rowsLimit and rowsLimitPercent can be specified. Cannot be used in conjunction w Optional: true, ValidateFunc: verify.ValidateEnum([]string{"TOP", "RANDOM_START", ""}), Description: `How to sample rows if not all rows are scanned. Meaningful only when used in conjunction with either -rowsLimit or rowsLimitPercent. If not specified, rows are scanned in the order BigQuery reads them. -If TimespanConfig is set, set this to an empty string to avoid using the default value. Default value: "TOP" Possible values: ["TOP", "RANDOM_START"]`, +rowsLimit or rowsLimitPercent. If not specified, rows are scanned in the order BigQuery reads them. Default value: "TOP" Possible values: ["TOP", "RANDOM_START"]`, Default: "TOP", }, }, @@ -1471,7 +1469,6 @@ func resourceDataLossPreventionJobTriggerCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1480,7 +1477,6 @@ func resourceDataLossPreventionJobTriggerCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating JobTrigger: %s", err) @@ -1520,14 +1516,12 @@ func resourceDataLossPreventionJobTriggerRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataLossPreventionJobTrigger %q", d.Id())) @@ -1628,7 +1622,6 @@ func resourceDataLossPreventionJobTriggerUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating JobTrigger %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1672,7 +1665,6 @@ func resourceDataLossPreventionJobTriggerUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1707,8 +1699,6 @@ func resourceDataLossPreventionJobTriggerDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting JobTrigger %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1718,7 +1708,6 @@ func resourceDataLossPreventionJobTriggerDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "JobTrigger") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go index e34e0d43ef3..4960b80f6ec 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datalossprevention/resource_data_loss_prevention_stored_info_type.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -344,7 +343,6 @@ func resourceDataLossPreventionStoredInfoTypeCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -353,7 +351,6 @@ func resourceDataLossPreventionStoredInfoTypeCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating StoredInfoType: %s", err) @@ -442,14 +439,12 @@ func resourceDataLossPreventionStoredInfoTypeRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataLossPreventionStoredInfoType %q", d.Id())) @@ -541,7 +536,6 @@ func resourceDataLossPreventionStoredInfoTypeUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating StoredInfoType %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -585,7 +579,6 @@ func resourceDataLossPreventionStoredInfoTypeUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -620,8 +613,6 @@ func resourceDataLossPreventionStoredInfoTypeDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting StoredInfoType %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -631,7 +622,6 @@ func resourceDataLossPreventionStoredInfoTypeDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "StoredInfoType") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datapipeline/resource_data_pipeline_pipeline.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datapipeline/resource_data_pipeline_pipeline.go index ec325afdb87..c839020d2dc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datapipeline/resource_data_pipeline_pipeline.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datapipeline/resource_data_pipeline_pipeline.go @@ -20,7 +20,6 @@ package datapipeline import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -587,7 +586,6 @@ func resourceDataPipelinePipelineCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -596,7 +594,6 @@ func resourceDataPipelinePipelineCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Pipeline: %s", err) @@ -639,14 +636,12 @@ func resourceDataPipelinePipelineRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataPipelinePipeline %q", d.Id())) @@ -740,7 +735,6 @@ func resourceDataPipelinePipelineUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Pipeline %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -780,7 +774,6 @@ func resourceDataPipelinePipelineUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -821,8 +814,6 @@ func resourceDataPipelinePipelineDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Pipeline %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -832,7 +823,6 @@ func resourceDataPipelinePipelineDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Pipeline") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_aspect_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_aspect_type.go deleted file mode 100644 index d2c2fa59997..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_aspect_type.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "fmt" - - "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/cloudresourcemanager/v1" - - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -var DataplexAspectTypeIamSchema = map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "location": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "aspect_type_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, -} - -type DataplexAspectTypeIamUpdater struct { - project string - location string - aspectTypeId string - d tpgresource.TerraformResourceData - Config *transport_tpg.Config -} - -func DataplexAspectTypeIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - if err := d.Set("project", project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - } - values["project"] = project - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - if err := d.Set("location", location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - } - values["location"] = location - if v, ok := d.GetOk("aspect_type_id"); ok { - values["aspect_type_id"] = v.(string) - } - - // We may have gotten either a long or short name, so attempt to parse long name if possible - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/aspectTypes/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("aspect_type_id").(string)) - if err != nil { - return nil, err - } - - for k, v := range m { - values[k] = v - } - - u := &DataplexAspectTypeIamUpdater{ - project: values["project"], - location: values["location"], - aspectTypeId: values["aspect_type_id"], - d: d, - Config: config, - } - - if err := d.Set("project", u.project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - if err := d.Set("location", u.location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - if err := d.Set("aspect_type_id", u.GetResourceId()); err != nil { - return nil, fmt.Errorf("Error setting aspect_type_id: %s", err) - } - - return u, nil -} - -func DataplexAspectTypeIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - values["project"] = project - } - - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - values["location"] = location - } - - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/aspectTypes/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) - if err != nil { - return err - } - - for k, v := range m { - values[k] = v - } - - u := &DataplexAspectTypeIamUpdater{ - project: values["project"], - location: values["location"], - aspectTypeId: values["aspect_type_id"], - d: d, - Config: config, - } - if err := d.Set("aspect_type_id", u.GetResourceId()); err != nil { - return fmt.Errorf("Error setting aspect_type_id: %s", err) - } - d.SetId(u.GetResourceId()) - return nil -} - -func (u *DataplexAspectTypeIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { - url, err := u.qualifyAspectTypeUrl("getIamPolicy") - if err != nil { - return nil, err - } - - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return nil, err - } - var obj map[string]interface{} - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return nil, err - } - - policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - }) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - out := &cloudresourcemanager.Policy{} - err = tpgresource.Convert(policy, out) - if err != nil { - return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) - } - - return out, nil -} - -func (u *DataplexAspectTypeIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { - json, err := tpgresource.ConvertToMap(policy) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - obj["policy"] = json - - url, err := u.qualifyAspectTypeUrl("setIamPolicy") - if err != nil { - return err - } - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "POST", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: u.d.Timeout(schema.TimeoutCreate), - }) - if err != nil { - return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - return nil -} - -func (u *DataplexAspectTypeIamUpdater) qualifyAspectTypeUrl(methodIdentifier string) (string, error) { - urlTemplate := fmt.Sprintf("{{DataplexBasePath}}%s:%s", fmt.Sprintf("projects/%s/locations/%s/aspectTypes/%s", u.project, u.location, u.aspectTypeId), methodIdentifier) - url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) - if err != nil { - return "", err - } - return url, nil -} - -func (u *DataplexAspectTypeIamUpdater) GetResourceId() string { - return fmt.Sprintf("projects/%s/locations/%s/aspectTypes/%s", u.project, u.location, u.aspectTypeId) -} - -func (u *DataplexAspectTypeIamUpdater) GetMutexKey() string { - return fmt.Sprintf("iam-dataplex-aspecttype-%s", u.GetResourceId()) -} - -func (u *DataplexAspectTypeIamUpdater) DescribeResource() string { - return fmt.Sprintf("dataplex aspecttype %q", u.GetResourceId()) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_entry_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_entry_group.go deleted file mode 100644 index 5fcdabef49f..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_entry_group.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "fmt" - - "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/cloudresourcemanager/v1" - - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -var DataplexEntryGroupIamSchema = map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "location": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "entry_group_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, -} - -type DataplexEntryGroupIamUpdater struct { - project string - location string - entryGroupId string - d tpgresource.TerraformResourceData - Config *transport_tpg.Config -} - -func DataplexEntryGroupIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - if err := d.Set("project", project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - } - values["project"] = project - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - if err := d.Set("location", location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - } - values["location"] = location - if v, ok := d.GetOk("entry_group_id"); ok { - values["entry_group_id"] = v.(string) - } - - // We may have gotten either a long or short name, so attempt to parse long name if possible - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/entryGroups/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("entry_group_id").(string)) - if err != nil { - return nil, err - } - - for k, v := range m { - values[k] = v - } - - u := &DataplexEntryGroupIamUpdater{ - project: values["project"], - location: values["location"], - entryGroupId: values["entry_group_id"], - d: d, - Config: config, - } - - if err := d.Set("project", u.project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - if err := d.Set("location", u.location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - if err := d.Set("entry_group_id", u.GetResourceId()); err != nil { - return nil, fmt.Errorf("Error setting entry_group_id: %s", err) - } - - return u, nil -} - -func DataplexEntryGroupIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - values["project"] = project - } - - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - values["location"] = location - } - - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/entryGroups/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) - if err != nil { - return err - } - - for k, v := range m { - values[k] = v - } - - u := &DataplexEntryGroupIamUpdater{ - project: values["project"], - location: values["location"], - entryGroupId: values["entry_group_id"], - d: d, - Config: config, - } - if err := d.Set("entry_group_id", u.GetResourceId()); err != nil { - return fmt.Errorf("Error setting entry_group_id: %s", err) - } - d.SetId(u.GetResourceId()) - return nil -} - -func (u *DataplexEntryGroupIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { - url, err := u.qualifyEntryGroupUrl("getIamPolicy") - if err != nil { - return nil, err - } - - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return nil, err - } - var obj map[string]interface{} - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return nil, err - } - - policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - }) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - out := &cloudresourcemanager.Policy{} - err = tpgresource.Convert(policy, out) - if err != nil { - return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) - } - - return out, nil -} - -func (u *DataplexEntryGroupIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { - json, err := tpgresource.ConvertToMap(policy) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - obj["policy"] = json - - url, err := u.qualifyEntryGroupUrl("setIamPolicy") - if err != nil { - return err - } - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "POST", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: u.d.Timeout(schema.TimeoutCreate), - }) - if err != nil { - return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - return nil -} - -func (u *DataplexEntryGroupIamUpdater) qualifyEntryGroupUrl(methodIdentifier string) (string, error) { - urlTemplate := fmt.Sprintf("{{DataplexBasePath}}%s:%s", fmt.Sprintf("projects/%s/locations/%s/entryGroups/%s", u.project, u.location, u.entryGroupId), methodIdentifier) - url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) - if err != nil { - return "", err - } - return url, nil -} - -func (u *DataplexEntryGroupIamUpdater) GetResourceId() string { - return fmt.Sprintf("projects/%s/locations/%s/entryGroups/%s", u.project, u.location, u.entryGroupId) -} - -func (u *DataplexEntryGroupIamUpdater) GetMutexKey() string { - return fmt.Sprintf("iam-dataplex-entrygroup-%s", u.GetResourceId()) -} - -func (u *DataplexEntryGroupIamUpdater) DescribeResource() string { - return fmt.Sprintf("dataplex entrygroup %q", u.GetResourceId()) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_entry_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_entry_type.go deleted file mode 100644 index 354f98a753d..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/iam_dataplex_entry_type.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "fmt" - - "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/cloudresourcemanager/v1" - - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -var DataplexEntryTypeIamSchema = map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "location": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "entry_type_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, -} - -type DataplexEntryTypeIamUpdater struct { - project string - location string - entryTypeId string - d tpgresource.TerraformResourceData - Config *transport_tpg.Config -} - -func DataplexEntryTypeIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - if err := d.Set("project", project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - } - values["project"] = project - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - if err := d.Set("location", location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - } - values["location"] = location - if v, ok := d.GetOk("entry_type_id"); ok { - values["entry_type_id"] = v.(string) - } - - // We may have gotten either a long or short name, so attempt to parse long name if possible - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/entryTypes/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("entry_type_id").(string)) - if err != nil { - return nil, err - } - - for k, v := range m { - values[k] = v - } - - u := &DataplexEntryTypeIamUpdater{ - project: values["project"], - location: values["location"], - entryTypeId: values["entry_type_id"], - d: d, - Config: config, - } - - if err := d.Set("project", u.project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - if err := d.Set("location", u.location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - if err := d.Set("entry_type_id", u.GetResourceId()); err != nil { - return nil, fmt.Errorf("Error setting entry_type_id: %s", err) - } - - return u, nil -} - -func DataplexEntryTypeIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - values["project"] = project - } - - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - values["location"] = location - } - - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/entryTypes/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) - if err != nil { - return err - } - - for k, v := range m { - values[k] = v - } - - u := &DataplexEntryTypeIamUpdater{ - project: values["project"], - location: values["location"], - entryTypeId: values["entry_type_id"], - d: d, - Config: config, - } - if err := d.Set("entry_type_id", u.GetResourceId()); err != nil { - return fmt.Errorf("Error setting entry_type_id: %s", err) - } - d.SetId(u.GetResourceId()) - return nil -} - -func (u *DataplexEntryTypeIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { - url, err := u.qualifyEntryTypeUrl("getIamPolicy") - if err != nil { - return nil, err - } - - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return nil, err - } - var obj map[string]interface{} - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return nil, err - } - - policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - }) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - out := &cloudresourcemanager.Policy{} - err = tpgresource.Convert(policy, out) - if err != nil { - return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) - } - - return out, nil -} - -func (u *DataplexEntryTypeIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { - json, err := tpgresource.ConvertToMap(policy) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - obj["policy"] = json - - url, err := u.qualifyEntryTypeUrl("setIamPolicy") - if err != nil { - return err - } - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "POST", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: u.d.Timeout(schema.TimeoutCreate), - }) - if err != nil { - return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - return nil -} - -func (u *DataplexEntryTypeIamUpdater) qualifyEntryTypeUrl(methodIdentifier string) (string, error) { - urlTemplate := fmt.Sprintf("{{DataplexBasePath}}%s:%s", fmt.Sprintf("projects/%s/locations/%s/entryTypes/%s", u.project, u.location, u.entryTypeId), methodIdentifier) - url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) - if err != nil { - return "", err - } - return url, nil -} - -func (u *DataplexEntryTypeIamUpdater) GetResourceId() string { - return fmt.Sprintf("projects/%s/locations/%s/entryTypes/%s", u.project, u.location, u.entryTypeId) -} - -func (u *DataplexEntryTypeIamUpdater) GetMutexKey() string { - return fmt.Sprintf("iam-dataplex-entrytype-%s", u.GetResourceId()) -} - -func (u *DataplexEntryTypeIamUpdater) DescribeResource() string { - return fmt.Sprintf("dataplex entrytype %q", u.GetResourceId()) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_aspect_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_aspect_type.go deleted file mode 100644 index 13a5fa12cdc..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_aspect_type.go +++ /dev/null @@ -1,605 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "encoding/json" - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceDataplexAspectType() *schema.Resource { - return &schema.Resource{ - Create: resourceDataplexAspectTypeCreate, - Read: resourceDataplexAspectTypeRead, - Update: resourceDataplexAspectTypeUpdate, - Delete: resourceDataplexAspectTypeDelete, - - Importer: &schema.ResourceImporter{ - State: resourceDataplexAspectTypeImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(5 * time.Minute), - Delete: schema.DefaultTimeout(5 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "aspect_type_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The aspect type id of the aspect type.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the AspectType.`, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - Description: `User friendly display name.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `User-defined labels for the AspectType. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location where aspect type will be created in.`, - }, - "metadata_template": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringIsJSON, - StateFunc: func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }, - Description: `MetadataTemplate of the Aspect.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time when the AspectType was created.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The relative resource name of the AspectType, of the form: projects/{project_number}/locations/{location_id}/aspectTypes/{aspect_type_id}`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "transfer_status": { - Type: schema.TypeString, - Computed: true, - Description: `Denotes the transfer status of the Aspect Type. It is unspecified -for Aspect Type created from Dataplex API.`, - }, - "uid": { - Type: schema.TypeString, - Computed: true, - Description: `System generated globally unique ID for the AspectType. This ID will be different if the AspectType is deleted and re-created with the same name.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time when the AspectType was last updated.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceDataplexAspectTypeCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandDataplexAspectTypeDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - displayNameProp, err := expandDataplexAspectTypeDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - metadataTemplateProp, err := expandDataplexAspectTypeMetadataTemplate(d.Get("metadata_template"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("metadata_template"); !tpgresource.IsEmptyValue(reflect.ValueOf(metadataTemplateProp)) && (ok || !reflect.DeepEqual(v, metadataTemplateProp)) { - obj["metadataTemplate"] = metadataTemplateProp - } - labelsProp, err := expandDataplexAspectTypeEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/aspectTypes?aspectTypeId={{aspect_type_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new AspectType: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AspectType: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating AspectType: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = DataplexOperationWaitTime( - config, res, project, "Creating AspectType", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create AspectType: %s", err) - } - - log.Printf("[DEBUG] Finished creating AspectType %q: %#v", d.Id(), res) - - return resourceDataplexAspectTypeRead(d, meta) -} - -func resourceDataplexAspectTypeRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AspectType: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataplexAspectType %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - - if err := d.Set("name", flattenDataplexAspectTypeName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("uid", flattenDataplexAspectTypeUid(res["uid"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("create_time", flattenDataplexAspectTypeCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("update_time", flattenDataplexAspectTypeUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("description", flattenDataplexAspectTypeDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("display_name", flattenDataplexAspectTypeDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("labels", flattenDataplexAspectTypeLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("metadata_template", flattenDataplexAspectTypeMetadataTemplate(res["metadataTemplate"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("transfer_status", flattenDataplexAspectTypeTransferStatus(res["transferStatus"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("terraform_labels", flattenDataplexAspectTypeTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - if err := d.Set("effective_labels", flattenDataplexAspectTypeEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading AspectType: %s", err) - } - - return nil -} - -func resourceDataplexAspectTypeUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AspectType: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandDataplexAspectTypeDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - displayNameProp, err := expandDataplexAspectTypeDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - metadataTemplateProp, err := expandDataplexAspectTypeMetadataTemplate(d.Get("metadata_template"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("metadata_template"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, metadataTemplateProp)) { - obj["metadataTemplate"] = metadataTemplateProp - } - labelsProp, err := expandDataplexAspectTypeEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating AspectType %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("display_name") { - updateMask = append(updateMask, "displayName") - } - - if d.HasChange("metadata_template") { - updateMask = append(updateMask, "metadataTemplate") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating AspectType %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating AspectType %q: %#v", d.Id(), res) - } - - err = DataplexOperationWaitTime( - config, res, project, "Updating AspectType", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceDataplexAspectTypeRead(d, meta) -} - -func resourceDataplexAspectTypeDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AspectType: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting AspectType %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "AspectType") - } - - err = DataplexOperationWaitTime( - config, res, project, "Deleting AspectType", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting AspectType %q: %#v", d.Id(), res) - return nil -} - -func resourceDataplexAspectTypeImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/aspectTypes/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenDataplexAspectTypeName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataplexAspectTypeMetadataTemplate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - b, err := json.Marshal(v) - if err != nil { - // TODO: return error once https://github.com/GoogleCloudPlatform/magic-modules/issues/3257 is fixed. - log.Printf("[ERROR] failed to marshal schema to JSON: %v", err) - } - return string(b) -} - -func flattenDataplexAspectTypeTransferStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexAspectTypeTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataplexAspectTypeEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandDataplexAspectTypeDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexAspectTypeDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexAspectTypeMetadataTemplate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - b := []byte(v.(string)) - if len(b) == 0 { - return nil, nil - } - m := make(map[string]interface{}) - if err := json.Unmarshal(b, &m); err != nil { - return nil, err - } - return m, nil -} - -func expandDataplexAspectTypeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_aspect_type_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_aspect_type_sweeper.go deleted file mode 100644 index 89b12674b37..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_aspect_type_sweeper.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("DataplexAspectType", testSweepDataplexAspectType) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepDataplexAspectType(region string) error { - resourceName := "DataplexAspectType" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://dataplex.googleapis.com/v1/projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["aspectTypes"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - var name string - // Id detected in the delete URL, attempt to use id. - if obj["id"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) - } else if obj["name"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - } else { - log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) - return nil - } - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://dataplex.googleapis.com/v1/projects/{{project}}/locations/{{location}}/aspectTypes/{{aspect_type_id}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_datascan.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_datascan.go index 4d830c0954c..56164affb9d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_datascan.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_datascan.go @@ -20,7 +20,6 @@ package dataplex import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -403,21 +402,6 @@ Only relevant if a minValue has been defined. Default = false.`, }, }, }, - "sql_assertion": { - Type: schema.TypeList, - Optional: true, - Description: `Table rule which evaluates whether any row matches invalid state.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "sql_statement": { - Type: schema.TypeString, - Required: true, - Description: `The SQL statement.`, - }, - }, - }, - }, "statistic_range_expectation": { Type: schema.TypeList, Optional: true, @@ -666,7 +650,6 @@ func resourceDataplexDatascanCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -675,7 +658,6 @@ func resourceDataplexDatascanCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Datascan: %s", err) @@ -728,14 +710,12 @@ func resourceDataplexDatascanRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataplexDatascan %q", d.Id())) @@ -856,7 +836,6 @@ func resourceDataplexDatascanUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Datascan %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -904,7 +883,6 @@ func resourceDataplexDatascanUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -952,8 +930,6 @@ func resourceDataplexDatascanDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Datascan %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -963,7 +939,6 @@ func resourceDataplexDatascanDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Datascan") @@ -1238,7 +1213,6 @@ func flattenDataplexDatascanDataQualitySpecRules(v interface{}, d *schema.Resour "statistic_range_expectation": flattenDataplexDatascanDataQualitySpecRulesStatisticRangeExpectation(original["statisticRangeExpectation"], d, config), "row_condition_expectation": flattenDataplexDatascanDataQualitySpecRulesRowConditionExpectation(original["rowConditionExpectation"], d, config), "table_condition_expectation": flattenDataplexDatascanDataQualitySpecRulesTableConditionExpectation(original["tableConditionExpectation"], d, config), - "sql_assertion": flattenDataplexDatascanDataQualitySpecRulesSqlAssertion(original["sqlAssertion"], d, config), }) } return transformed @@ -1427,23 +1401,6 @@ func flattenDataplexDatascanDataQualitySpecRulesTableConditionExpectationSqlExpr return v } -func flattenDataplexDatascanDataQualitySpecRulesSqlAssertion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["sql_statement"] = - flattenDataplexDatascanDataQualitySpecRulesSqlAssertionSqlStatement(original["sqlStatement"], d, config) - return []interface{}{transformed} -} -func flattenDataplexDatascanDataQualitySpecRulesSqlAssertionSqlStatement(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenDataplexDatascanDataProfileSpec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1887,13 +1844,6 @@ func expandDataplexDatascanDataQualitySpecRules(v interface{}, d tpgresource.Ter transformed["tableConditionExpectation"] = transformedTableConditionExpectation } - transformedSqlAssertion, err := expandDataplexDatascanDataQualitySpecRulesSqlAssertion(original["sql_assertion"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSqlAssertion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sqlAssertion"] = transformedSqlAssertion - } - req = append(req, transformed) } return req, nil @@ -2168,29 +2118,6 @@ func expandDataplexDatascanDataQualitySpecRulesTableConditionExpectationSqlExpre return v, nil } -func expandDataplexDatascanDataQualitySpecRulesSqlAssertion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSqlStatement, err := expandDataplexDatascanDataQualitySpecRulesSqlAssertionSqlStatement(original["sql_statement"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSqlStatement); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sqlStatement"] = transformedSqlStatement - } - - return transformed, nil -} - -func expandDataplexDatascanDataQualitySpecRulesSqlAssertionSqlStatement(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandDataplexDatascanDataProfileSpec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_group.go deleted file mode 100644 index 4e521725fef..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_group.go +++ /dev/null @@ -1,552 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceDataplexEntryGroup() *schema.Resource { - return &schema.Resource{ - Create: resourceDataplexEntryGroupCreate, - Read: resourceDataplexEntryGroupRead, - Update: resourceDataplexEntryGroupUpdate, - Delete: resourceDataplexEntryGroupDelete, - - Importer: &schema.ResourceImporter{ - State: resourceDataplexEntryGroupImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(5 * time.Minute), - Delete: schema.DefaultTimeout(5 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the EntryGroup.`, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - Description: `User friendly display name.`, - }, - "entry_group_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The entry group id of the entry group.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `User-defined labels for the EntryGroup. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location where entry group will be created in.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time when the EntryGroup was created.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The relative resource name of the EntryGroup, of the form: projects/{project_number}/locations/{location_id}/entryGroups/{entry_group_id}`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "transfer_status": { - Type: schema.TypeString, - Computed: true, - Description: `Denotes the transfer status of the Entry Group. It is unspecified -for Entry Group created from Dataplex API.`, - }, - "uid": { - Type: schema.TypeString, - Computed: true, - Description: `System generated globally unique ID for the EntryGroup. This ID will be different if the EntryGroup is deleted and re-created with the same name.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time when the EntryGroup was last updated.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceDataplexEntryGroupCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandDataplexEntryGroupDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - displayNameProp, err := expandDataplexEntryGroupDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - labelsProp, err := expandDataplexEntryGroupEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryGroups?entryGroupId={{entry_group_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new EntryGroup: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryGroup: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating EntryGroup: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = DataplexOperationWaitTime( - config, res, project, "Creating EntryGroup", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create EntryGroup: %s", err) - } - - log.Printf("[DEBUG] Finished creating EntryGroup %q: %#v", d.Id(), res) - - return resourceDataplexEntryGroupRead(d, meta) -} - -func resourceDataplexEntryGroupRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryGroup: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataplexEntryGroup %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - - if err := d.Set("name", flattenDataplexEntryGroupName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("uid", flattenDataplexEntryGroupUid(res["uid"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("create_time", flattenDataplexEntryGroupCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("update_time", flattenDataplexEntryGroupUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("description", flattenDataplexEntryGroupDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("display_name", flattenDataplexEntryGroupDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("labels", flattenDataplexEntryGroupLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("transfer_status", flattenDataplexEntryGroupTransferStatus(res["transferStatus"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("terraform_labels", flattenDataplexEntryGroupTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - if err := d.Set("effective_labels", flattenDataplexEntryGroupEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryGroup: %s", err) - } - - return nil -} - -func resourceDataplexEntryGroupUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryGroup: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandDataplexEntryGroupDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - displayNameProp, err := expandDataplexEntryGroupDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - labelsProp, err := expandDataplexEntryGroupEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating EntryGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("display_name") { - updateMask = append(updateMask, "displayName") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating EntryGroup %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating EntryGroup %q: %#v", d.Id(), res) - } - - err = DataplexOperationWaitTime( - config, res, project, "Updating EntryGroup", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceDataplexEntryGroupRead(d, meta) -} - -func resourceDataplexEntryGroupDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryGroup: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting EntryGroup %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "EntryGroup") - } - - err = DataplexOperationWaitTime( - config, res, project, "Deleting EntryGroup", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting EntryGroup %q: %#v", d.Id(), res) - return nil -} - -func resourceDataplexEntryGroupImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/entryGroups/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenDataplexEntryGroupName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataplexEntryGroupTransferStatus(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryGroupTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataplexEntryGroupEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandDataplexEntryGroupDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryGroupDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryGroupEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_group_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_group_sweeper.go deleted file mode 100644 index 4a223716554..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_group_sweeper.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("DataplexEntryGroup", testSweepDataplexEntryGroup) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepDataplexEntryGroup(region string) error { - resourceName := "DataplexEntryGroup" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://dataplex.googleapis.com/v1/projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["entryGroups"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - var name string - // Id detected in the delete URL, attempt to use id. - if obj["id"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) - } else if obj["name"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - } else { - log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) - return nil - } - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://dataplex.googleapis.com/v1/projects/{{project}}/locations/{{location}}/entryGroups/{{entry_group_id}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_type.go deleted file mode 100644 index 22cbbd3fa39..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_type.go +++ /dev/null @@ -1,719 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceDataplexEntryType() *schema.Resource { - return &schema.Resource{ - Create: resourceDataplexEntryTypeCreate, - Read: resourceDataplexEntryTypeRead, - Update: resourceDataplexEntryTypeUpdate, - Delete: resourceDataplexEntryTypeDelete, - - Importer: &schema.ResourceImporter{ - State: resourceDataplexEntryTypeImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(5 * time.Minute), - Delete: schema.DefaultTimeout(5 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the EntryType.`, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - Description: `User friendly display name.`, - }, - "entry_type_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The entry type id of the entry type.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `User-defined labels for the EntryType. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location where entry type will be created in.`, - }, - "platform": { - Type: schema.TypeString, - Optional: true, - Description: `The platform that Entries of this type belongs to.`, - }, - "required_aspects": { - Type: schema.TypeList, - Optional: true, - Description: `AspectInfo for the entry type.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Optional: true, - Description: `Required aspect type for the entry type.`, - }, - }, - }, - }, - "system": { - Type: schema.TypeString, - Optional: true, - Description: `The system that Entries of this type belongs to.`, - }, - "type_aliases": { - Type: schema.TypeList, - Optional: true, - Description: `Indicates the class this Entry Type belongs to, for example, TABLE, DATABASE, MODEL.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time when the EntryType was created.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The relative resource name of the EntryType, of the form: projects/{project_number}/locations/{location_id}/entryTypes/{entry_type_id}`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "uid": { - Type: schema.TypeString, - Computed: true, - Description: `System generated globally unique ID for the EntryType. This ID will be different if the EntryType is deleted and re-created with the same name.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time when the EntryType was last updated.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceDataplexEntryTypeCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandDataplexEntryTypeDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - displayNameProp, err := expandDataplexEntryTypeDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - typeAliasesProp, err := expandDataplexEntryTypeTypeAliases(d.Get("type_aliases"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("type_aliases"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeAliasesProp)) && (ok || !reflect.DeepEqual(v, typeAliasesProp)) { - obj["typeAliases"] = typeAliasesProp - } - platformProp, err := expandDataplexEntryTypePlatform(d.Get("platform"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("platform"); !tpgresource.IsEmptyValue(reflect.ValueOf(platformProp)) && (ok || !reflect.DeepEqual(v, platformProp)) { - obj["platform"] = platformProp - } - systemProp, err := expandDataplexEntryTypeSystem(d.Get("system"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("system"); !tpgresource.IsEmptyValue(reflect.ValueOf(systemProp)) && (ok || !reflect.DeepEqual(v, systemProp)) { - obj["system"] = systemProp - } - requiredAspectsProp, err := expandDataplexEntryTypeRequiredAspects(d.Get("required_aspects"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("required_aspects"); !tpgresource.IsEmptyValue(reflect.ValueOf(requiredAspectsProp)) && (ok || !reflect.DeepEqual(v, requiredAspectsProp)) { - obj["requiredAspects"] = requiredAspectsProp - } - labelsProp, err := expandDataplexEntryTypeEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryTypes?entryTypeId={{entry_type_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new EntryType: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryType: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating EntryType: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = DataplexOperationWaitTime( - config, res, project, "Creating EntryType", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create EntryType: %s", err) - } - - log.Printf("[DEBUG] Finished creating EntryType %q: %#v", d.Id(), res) - - return resourceDataplexEntryTypeRead(d, meta) -} - -func resourceDataplexEntryTypeRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryType: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataplexEntryType %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - - if err := d.Set("name", flattenDataplexEntryTypeName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("uid", flattenDataplexEntryTypeUid(res["uid"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("create_time", flattenDataplexEntryTypeCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("update_time", flattenDataplexEntryTypeUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("description", flattenDataplexEntryTypeDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("display_name", flattenDataplexEntryTypeDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("labels", flattenDataplexEntryTypeLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("type_aliases", flattenDataplexEntryTypeTypeAliases(res["typeAliases"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("platform", flattenDataplexEntryTypePlatform(res["platform"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("system", flattenDataplexEntryTypeSystem(res["system"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("required_aspects", flattenDataplexEntryTypeRequiredAspects(res["requiredAspects"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("terraform_labels", flattenDataplexEntryTypeTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - if err := d.Set("effective_labels", flattenDataplexEntryTypeEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading EntryType: %s", err) - } - - return nil -} - -func resourceDataplexEntryTypeUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryType: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandDataplexEntryTypeDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - displayNameProp, err := expandDataplexEntryTypeDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - typeAliasesProp, err := expandDataplexEntryTypeTypeAliases(d.Get("type_aliases"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("type_aliases"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, typeAliasesProp)) { - obj["typeAliases"] = typeAliasesProp - } - platformProp, err := expandDataplexEntryTypePlatform(d.Get("platform"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("platform"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, platformProp)) { - obj["platform"] = platformProp - } - systemProp, err := expandDataplexEntryTypeSystem(d.Get("system"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("system"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, systemProp)) { - obj["system"] = systemProp - } - requiredAspectsProp, err := expandDataplexEntryTypeRequiredAspects(d.Get("required_aspects"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("required_aspects"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, requiredAspectsProp)) { - obj["requiredAspects"] = requiredAspectsProp - } - labelsProp, err := expandDataplexEntryTypeEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating EntryType %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("display_name") { - updateMask = append(updateMask, "displayName") - } - - if d.HasChange("type_aliases") { - updateMask = append(updateMask, "typeAliases") - } - - if d.HasChange("platform") { - updateMask = append(updateMask, "platform") - } - - if d.HasChange("system") { - updateMask = append(updateMask, "system") - } - - if d.HasChange("required_aspects") { - updateMask = append(updateMask, "requiredAspects") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating EntryType %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating EntryType %q: %#v", d.Id(), res) - } - - err = DataplexOperationWaitTime( - config, res, project, "Updating EntryType", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceDataplexEntryTypeRead(d, meta) -} - -func resourceDataplexEntryTypeDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for EntryType: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{DataplexBasePath}}projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting EntryType %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "EntryType") - } - - err = DataplexOperationWaitTime( - config, res, project, "Deleting EntryType", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting EntryType %q: %#v", d.Id(), res) - return nil -} - -func resourceDataplexEntryTypeImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/entryTypes/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenDataplexEntryTypeName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataplexEntryTypeTypeAliases(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypePlatform(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeSystem(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeRequiredAspects(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "type": flattenDataplexEntryTypeRequiredAspectsType(original["type"], d, config), - }) - } - return transformed -} -func flattenDataplexEntryTypeRequiredAspectsType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataplexEntryTypeTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataplexEntryTypeEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandDataplexEntryTypeDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryTypeDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryTypeTypeAliases(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryTypePlatform(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryTypeSystem(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryTypeRequiredAspects(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedType, err := expandDataplexEntryTypeRequiredAspectsType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - req = append(req, transformed) - } - return req, nil -} - -func expandDataplexEntryTypeRequiredAspectsType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataplexEntryTypeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_type_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_type_sweeper.go deleted file mode 100644 index dfe0bbd290b..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_entry_type_sweeper.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataplex - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("DataplexEntryType", testSweepDataplexEntryType) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepDataplexEntryType(region string) error { - resourceName := "DataplexEntryType" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://dataplex.googleapis.com/v1/projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["entryTypes"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - var name string - // Id detected in the delete URL, attempt to use id. - if obj["id"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) - } else if obj["name"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - } else { - log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) - return nil - } - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://dataplex.googleapis.com/v1/projects/{{project}}/locations/{{location}}/entryTypes/{{entry_type_id}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_task.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_task.go index 2e1599dbd03..ff61c1d50e7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_task.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataplex/resource_dataplex_task.go @@ -20,7 +20,6 @@ package dataplex import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -641,7 +640,6 @@ func resourceDataplexTaskCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -650,7 +648,6 @@ func resourceDataplexTaskCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Task: %s", err) @@ -703,14 +700,12 @@ func resourceDataplexTaskRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataplexTask %q", d.Id())) @@ -834,7 +829,6 @@ func resourceDataplexTaskUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Task %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -886,7 +880,6 @@ func resourceDataplexTaskUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -934,8 +927,6 @@ func resourceDataplexTaskDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Task %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -945,7 +936,6 @@ func resourceDataplexTaskDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Task") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_autoscaling_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_autoscaling_policy.go index 4f2053848ee..2e8d0617ce5 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_autoscaling_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_autoscaling_policy.go @@ -20,7 +20,6 @@ package dataproc import ( "fmt" "log" - "net/http" "reflect" "time" @@ -304,7 +303,6 @@ func resourceDataprocAutoscalingPolicyCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -313,7 +311,6 @@ func resourceDataprocAutoscalingPolicyCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AutoscalingPolicy: %s", err) @@ -359,14 +356,12 @@ func resourceDataprocAutoscalingPolicyRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataprocAutoscalingPolicy %q", d.Id())) @@ -442,7 +437,6 @@ func resourceDataprocAutoscalingPolicyUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating AutoscalingPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -457,7 +451,6 @@ func resourceDataprocAutoscalingPolicyUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -496,8 +489,6 @@ func resourceDataprocAutoscalingPolicyDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AutoscalingPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -507,7 +498,6 @@ func resourceDataprocAutoscalingPolicyDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AutoscalingPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster.go index a620bb03332..46890cab3f0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster.go @@ -78,9 +78,11 @@ var ( "cluster_config.0.gce_cluster_config.0.reservation_affinity.0.values", } - masterDiskConfigKeys = diskConfigKeys("master_config") - workerDiskConfigKeys = diskConfigKeys("worker_config") - preemptibleWorkerDiskConfigKeys = diskConfigKeys("preemptible_worker_config") + preemptibleWorkerDiskConfigKeys = []string{ + "cluster_config.0.preemptible_worker_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.preemptible_worker_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.preemptible_worker_config.0.disk_config.0.boot_disk_type", + } clusterSoftwareConfigKeys = []string{ "cluster_config.0.software_config.0.image_version", @@ -120,29 +122,6 @@ var ( const resourceDataprocGoogleLabelPrefix = "goog-dataproc" const resourceDataprocGoogleProvidedLabelPrefix = "labels." + resourceDataprocGoogleLabelPrefix -// The keys inside a DiskConfig. configName is the name of the field this disk -// config is inside. E.g. 'master_config', 'worker_config', or -// 'preemptible_worker_config'. -func diskConfigKeys(configName string) []string { - return []string{ - "cluster_config.0." + configName + ".0.disk_config.0.num_local_ssds", - "cluster_config.0." + configName + ".0.disk_config.0.boot_disk_size_gb", - "cluster_config.0." + configName + ".0.disk_config.0.boot_disk_type", - "cluster_config.0." + configName + ".0.disk_config.0.local_ssd_interface", - } -} - -// Suppress diffs for values that are equivalent except for their use of the words "location" -// compared to "region" or "zone" -func LocationDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - return LocationDiffSuppressHelper(old, new) || LocationDiffSuppressHelper(new, old) -} - -func LocationDiffSuppressHelper(a, b string) bool { - return strings.Replace(a, "/locations/", "/regions/", 1) == b || - strings.Replace(a, "/locations/", "/zones/", 1) == b -} - func resourceDataprocLabelDiffSuppress(k, old, new string, d *schema.ResourceData) bool { if strings.HasPrefix(k, resourceDataprocGoogleProvidedLabelPrefix) && new == "" { return true @@ -842,39 +821,43 @@ func ResourceDataprocCluster() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "num_local_ssds": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: `The amount of local SSD disks that will be attached to each master cluster node. Defaults to 0.`, - AtLeastOneOf: masterDiskConfigKeys, - ForceNew: true, + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: `The amount of local SSD disks that will be attached to each master cluster node. Defaults to 0.`, + AtLeastOneOf: []string{ + "cluster_config.0.master_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.master_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.master_config.0.disk_config.0.boot_disk_type", + }, + ForceNew: true, }, "boot_disk_size_gb": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: `Size of the primary disk attached to each node, specified in GB. The primary disk contains the boot volume and system libraries, and the smallest allowed disk size is 10GB. GCP will default to a predetermined computed value if not set (currently 500GB). Note: If SSDs are not attached, it also contains the HDFS data blocks and Hadoop working directories.`, - AtLeastOneOf: masterDiskConfigKeys, + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: `Size of the primary disk attached to each node, specified in GB. The primary disk contains the boot volume and system libraries, and the smallest allowed disk size is 10GB. GCP will default to a predetermined computed value if not set (currently 500GB). Note: If SSDs are not attached, it also contains the HDFS data blocks and Hadoop working directories.`, + AtLeastOneOf: []string{ + "cluster_config.0.master_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.master_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.master_config.0.disk_config.0.boot_disk_type", + }, ForceNew: true, ValidateFunc: validation.IntAtLeast(10), }, "boot_disk_type": { - Type: schema.TypeString, - Optional: true, - Description: `The disk type of the primary disk attached to each node. Such as "pd-ssd" or "pd-standard". Defaults to "pd-standard".`, - AtLeastOneOf: masterDiskConfigKeys, - ForceNew: true, - Default: "pd-standard", - }, - - "local_ssd_interface": { - Type: schema.TypeString, - Optional: true, - Description: `Interface type of local SSDs (default is "scsi"). Valid values: "scsi" (Small Computer System Interface), "nvme" (Non-Volatile Memory Express).`, - AtLeastOneOf: masterDiskConfigKeys, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + Description: `The disk type of the primary disk attached to each node. Such as "pd-ssd" or "pd-standard". Defaults to "pd-standard".`, + AtLeastOneOf: []string{ + "cluster_config.0.master_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.master_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.master_config.0.disk_config.0.boot_disk_type", + }, + ForceNew: true, + Default: "pd-standard", }, }, }, @@ -987,39 +970,43 @@ func ResourceDataprocCluster() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "num_local_ssds": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: `The amount of local SSD disks that will be attached to each master cluster node. Defaults to 0.`, - AtLeastOneOf: workerDiskConfigKeys, - ForceNew: true, + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: `The amount of local SSD disks that will be attached to each master cluster node. Defaults to 0.`, + AtLeastOneOf: []string{ + "cluster_config.0.worker_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.worker_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.worker_config.0.disk_config.0.boot_disk_type", + }, + ForceNew: true, }, "boot_disk_size_gb": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: `Size of the primary disk attached to each node, specified in GB. The primary disk contains the boot volume and system libraries, and the smallest allowed disk size is 10GB. GCP will default to a predetermined computed value if not set (currently 500GB). Note: If SSDs are not attached, it also contains the HDFS data blocks and Hadoop working directories.`, - AtLeastOneOf: workerDiskConfigKeys, + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: `Size of the primary disk attached to each node, specified in GB. The primary disk contains the boot volume and system libraries, and the smallest allowed disk size is 10GB. GCP will default to a predetermined computed value if not set (currently 500GB). Note: If SSDs are not attached, it also contains the HDFS data blocks and Hadoop working directories.`, + AtLeastOneOf: []string{ + "cluster_config.0.worker_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.worker_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.worker_config.0.disk_config.0.boot_disk_type", + }, ForceNew: true, ValidateFunc: validation.IntAtLeast(10), }, "boot_disk_type": { - Type: schema.TypeString, - Optional: true, - Description: `The disk type of the primary disk attached to each node. Such as "pd-ssd" or "pd-standard". Defaults to "pd-standard".`, - AtLeastOneOf: workerDiskConfigKeys, - ForceNew: true, - Default: "pd-standard", - }, - - "local_ssd_interface": { - Type: schema.TypeString, - Optional: true, - Description: `Interface type of local SSDs (default is "scsi"). Valid values: "scsi" (Small Computer System Interface), "nvme" (Non-Volatile Memory Express).`, - AtLeastOneOf: workerDiskConfigKeys, - ForceNew: true, + Type: schema.TypeString, + Optional: true, + Description: `The disk type of the primary disk attached to each node. Such as "pd-ssd" or "pd-standard". Defaults to "pd-standard".`, + AtLeastOneOf: []string{ + "cluster_config.0.worker_config.0.disk_config.0.num_local_ssds", + "cluster_config.0.worker_config.0.disk_config.0.boot_disk_size_gb", + "cluster_config.0.worker_config.0.disk_config.0.boot_disk_type", + }, + ForceNew: true, + Default: "pd-standard", }, }, }, @@ -1145,14 +1132,6 @@ func ResourceDataprocCluster() *schema.Resource { Default: "pd-standard", Description: `The disk type of the primary disk attached to each preemptible worker node. Such as "pd-ssd" or "pd-standard". Defaults to "pd-standard".`, }, - - "local_ssd_interface": { - Type: schema.TypeString, - Optional: true, - AtLeastOneOf: preemptibleWorkerDiskConfigKeys, - ForceNew: true, - Description: `Interface type of local SSDs (default is "scsi"). Valid values: "scsi" (Small Computer System Interface), "nvme" (Non-Volatile Memory Express).`, - }, }, }, }, @@ -1443,7 +1422,7 @@ by Dataproc`, Type: schema.TypeString, Required: true, Description: `The autoscaling policy used by the cluster.`, - DiffSuppressFunc: LocationDiffSuppress, + DiffSuppressFunc: tpgresource.LocationDiffSuppress, }, }, }, @@ -1637,13 +1616,6 @@ by Dataproc`, ForceNew: true, Default: "pd-standard", }, - - "local_ssd_interface": { - Type: schema.TypeString, - Optional: true, - Description: `Interface type of local SSDs (default is "scsi"). Valid values: "scsi" (Small Computer System Interface), "nvme" (Non-Volatile Memory Express).`, - ForceNew: true, - }, }, }, }, @@ -2124,9 +2096,6 @@ func expandNodeGroupConfig(cfg map[string]interface{}) *dataproc.InstanceGroupCo if v, ok := dcfg["boot_disk_type"]; ok { icg.DiskConfig.BootDiskType = v.(string) } - if v, ok := dcfg["local_ssd_interface"]; ok { - icg.DiskConfig.LocalSsdInterface = v.(string) - } } } @@ -2399,9 +2368,6 @@ func expandPreemptibleInstanceGroupConfig(cfg map[string]interface{}) *dataproc. if v, ok := dcfg["boot_disk_type"]; ok { icg.DiskConfig.BootDiskType = v.(string) } - if v, ok := dcfg["local_ssd_interface"]; ok { - icg.DiskConfig.LocalSsdInterface = v.(string) - } } } @@ -2475,9 +2441,6 @@ func expandMasterInstanceGroupConfig(cfg map[string]interface{}) *dataproc.Insta if v, ok := dcfg["boot_disk_type"]; ok { icg.DiskConfig.BootDiskType = v.(string) } - if v, ok := dcfg["local_ssd_interface"]; ok { - icg.DiskConfig.LocalSsdInterface = v.(string) - } } } @@ -2519,9 +2482,6 @@ func expandWorkerInstanceGroupConfig(cfg map[string]interface{}) *dataproc.Insta if v, ok := dcfg["boot_disk_type"]; ok { icg.DiskConfig.BootDiskType = v.(string) } - if v, ok := dcfg["local_ssd_interface"]; ok { - icg.DiskConfig.LocalSsdInterface = v.(string) - } } } @@ -3088,7 +3048,6 @@ func flattenNodeGroupConfig(icg *dataproc.InstanceGroupConfig) []map[string]inte disk["boot_disk_size_gb"] = icg.DiskConfig.BootDiskSizeGb disk["num_local_ssds"] = icg.DiskConfig.NumLocalSsds disk["boot_disk_type"] = icg.DiskConfig.BootDiskType - disk["local_ssd_interface"] = icg.DiskConfig.LocalSsdInterface } data["accelerators"] = flattenAccelerators(icg.Accelerators) @@ -3178,7 +3137,6 @@ func flattenPreemptibleInstanceGroupConfig(d *schema.ResourceData, icg *dataproc disk["boot_disk_size_gb"] = icg.DiskConfig.BootDiskSizeGb disk["num_local_ssds"] = icg.DiskConfig.NumLocalSsds disk["boot_disk_type"] = icg.DiskConfig.BootDiskType - disk["local_ssd_interface"] = icg.DiskConfig.LocalSsdInterface } if icg.InstanceFlexibilityPolicy != nil { instanceFlexibilityPolicy["instance_selection_list"] = flattenInstanceSelectionList(icg.InstanceFlexibilityPolicy.InstanceSelectionList) @@ -3233,7 +3191,6 @@ func flattenMasterInstanceGroupConfig(d *schema.ResourceData, icg *dataproc.Inst disk["boot_disk_size_gb"] = icg.DiskConfig.BootDiskSizeGb disk["num_local_ssds"] = icg.DiskConfig.NumLocalSsds disk["boot_disk_type"] = icg.DiskConfig.BootDiskType - disk["local_ssd_interface"] = icg.DiskConfig.LocalSsdInterface } data["accelerators"] = flattenAccelerators(icg.Accelerators) @@ -3258,7 +3215,6 @@ func flattenWorkerInstanceGroupConfig(d *schema.ResourceData, icg *dataproc.Inst disk["boot_disk_size_gb"] = icg.DiskConfig.BootDiskSizeGb disk["num_local_ssds"] = icg.DiskConfig.NumLocalSsds disk["boot_disk_type"] = icg.DiskConfig.BootDiskType - disk["local_ssd_interface"] = icg.DiskConfig.LocalSsdInterface } data["accelerators"] = flattenAccelerators(icg.Accelerators) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_migrate.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_migrate.go index 99277909596..240c15d08c1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_migrate.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_migrate.go @@ -1243,7 +1243,7 @@ by Dataproc`, Type: schema.TypeString, Required: true, Description: `The autoscaling policy used by the cluster.`, - DiffSuppressFunc: LocationDiffSuppress, + DiffSuppressFunc: tpgresource.LocationDiffSuppress, }, }, }, diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_sweeper.go index a5bfe8646ac..b8866f88026 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataproc/resource_dataproc_cluster_sweeper.go @@ -68,7 +68,7 @@ func testSweepDataprocCluster(region string) error { return nil } - resourceList, ok := res["clusters"] + resourceList, ok := res["policies"] if !ok { log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/iam_dataproc_metastore_federation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/iam_dataproc_metastore_federation.go deleted file mode 100644 index 03fc63c5025..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/iam_dataproc_metastore_federation.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataprocmetastore - -import ( - "fmt" - - "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/cloudresourcemanager/v1" - - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -var DataprocMetastoreFederationIamSchema = map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "location": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "federation_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, -} - -type DataprocMetastoreFederationIamUpdater struct { - project string - location string - federationId string - d tpgresource.TerraformResourceData - Config *transport_tpg.Config -} - -func DataprocMetastoreFederationIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - if err := d.Set("project", project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - } - values["project"] = project - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - if err := d.Set("location", location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - } - values["location"] = location - if v, ok := d.GetOk("federation_id"); ok { - values["federation_id"] = v.(string) - } - - // We may have gotten either a long or short name, so attempt to parse long name if possible - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/federations/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("federation_id").(string)) - if err != nil { - return nil, err - } - - for k, v := range m { - values[k] = v - } - - u := &DataprocMetastoreFederationIamUpdater{ - project: values["project"], - location: values["location"], - federationId: values["federation_id"], - d: d, - Config: config, - } - - if err := d.Set("project", u.project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - if err := d.Set("location", u.location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - if err := d.Set("federation_id", u.GetResourceId()); err != nil { - return nil, fmt.Errorf("Error setting federation_id: %s", err) - } - - return u, nil -} - -func DataprocMetastoreFederationIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - values["project"] = project - } - - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - values["location"] = location - } - - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/federations/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) - if err != nil { - return err - } - - for k, v := range m { - values[k] = v - } - - u := &DataprocMetastoreFederationIamUpdater{ - project: values["project"], - location: values["location"], - federationId: values["federation_id"], - d: d, - Config: config, - } - if err := d.Set("federation_id", u.GetResourceId()); err != nil { - return fmt.Errorf("Error setting federation_id: %s", err) - } - d.SetId(u.GetResourceId()) - return nil -} - -func (u *DataprocMetastoreFederationIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { - url, err := u.qualifyFederationUrl("getIamPolicy") - if err != nil { - return nil, err - } - - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return nil, err - } - var obj map[string]interface{} - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return nil, err - } - - policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - }) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - out := &cloudresourcemanager.Policy{} - err = tpgresource.Convert(policy, out) - if err != nil { - return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) - } - - return out, nil -} - -func (u *DataprocMetastoreFederationIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { - json, err := tpgresource.ConvertToMap(policy) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - obj["policy"] = json - - url, err := u.qualifyFederationUrl("setIamPolicy") - if err != nil { - return err - } - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "POST", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: u.d.Timeout(schema.TimeoutCreate), - }) - if err != nil { - return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - return nil -} - -func (u *DataprocMetastoreFederationIamUpdater) qualifyFederationUrl(methodIdentifier string) (string, error) { - urlTemplate := fmt.Sprintf("{{DataprocMetastoreBasePath}}%s:%s", fmt.Sprintf("projects/%s/locations/%s/federations/%s", u.project, u.location, u.federationId), methodIdentifier) - url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) - if err != nil { - return "", err - } - return url, nil -} - -func (u *DataprocMetastoreFederationIamUpdater) GetResourceId() string { - return fmt.Sprintf("projects/%s/locations/%s/federations/%s", u.project, u.location, u.federationId) -} - -func (u *DataprocMetastoreFederationIamUpdater) GetMutexKey() string { - return fmt.Sprintf("iam-dataprocmetastore-federation-%s", u.GetResourceId()) -} - -func (u *DataprocMetastoreFederationIamUpdater) DescribeResource() string { - return fmt.Sprintf("dataprocmetastore federation %q", u.GetResourceId()) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go deleted file mode 100644 index e7c19023a94..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_federation.go +++ /dev/null @@ -1,619 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataprocmetastore - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceDataprocMetastoreFederation() *schema.Resource { - return &schema.Resource{ - Create: resourceDataprocMetastoreFederationCreate, - Read: resourceDataprocMetastoreFederationRead, - Update: resourceDataprocMetastoreFederationUpdate, - Delete: resourceDataprocMetastoreFederationDelete, - - Importer: &schema.ResourceImporter{ - State: resourceDataprocMetastoreFederationImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "backend_metastores": { - Type: schema.TypeSet, - Required: true, - Description: `A map from BackendMetastore rank to BackendMetastores from which the federation service serves metadata at query time. The map key represents the order in which BackendMetastores should be evaluated to resolve database names at query time and should be greater than or equal to zero. A BackendMetastore with a lower number will be evaluated before a BackendMetastore with a higher number.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "rank": { - Type: schema.TypeString, - Required: true, - }, - "metastore_type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"METASTORE_TYPE_UNSPECIFIED", "DATAPROC_METASTORE", "BIGQUERY"}), - Description: `The type of the backend metastore. Possible values: ["METASTORE_TYPE_UNSPECIFIED", "DATAPROC_METASTORE", "BIGQUERY"]`, - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: `The relative resource name of the metastore that is being federated. The formats of the relative resource names for the currently supported metastores are listed below: Dataplex: projects/{projectId}/locations/{location}/lakes/{lake_id} BigQuery: projects/{projectId} Dataproc Metastore: projects/{projectId}/locations/{location}/services/{serviceId}`, - }, - }, - }, - }, - "federation_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The ID of the metastore federation. The id must contain only letters (a-z, A-Z), numbers (0-9), underscores (_), -and hyphens (-). Cannot begin or end with underscore or hyphen. Must consist of between -3 and 63 characters.`, - }, - "version": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The Apache Hive metastore version of the federation. All backend metastore versions must be compatible with the federation version.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `User-defined labels for the metastore federation. - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location where the metastore federation should reside.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "endpoint_uri": { - Type: schema.TypeString, - Computed: true, - Description: `The URI of the endpoint used to access the metastore federation.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The relative resource name of the metastore federation.`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `The current state of the metastore federation.`, - }, - "state_message": { - Type: schema.TypeString, - Computed: true, - Description: `Additional information about the current state of the metastore federation, if available.`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "uid": { - Type: schema.TypeString, - Computed: true, - Description: `The globally unique resource identifier of the metastore federation.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceDataprocMetastoreFederationCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - versionProp, err := expandDataprocMetastoreFederationVersion(d.Get("version"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("version"); !tpgresource.IsEmptyValue(reflect.ValueOf(versionProp)) && (ok || !reflect.DeepEqual(v, versionProp)) { - obj["version"] = versionProp - } - backendMetastoresProp, err := expandDataprocMetastoreFederationBackendMetastores(d.Get("backend_metastores"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("backend_metastores"); !tpgresource.IsEmptyValue(reflect.ValueOf(backendMetastoresProp)) && (ok || !reflect.DeepEqual(v, backendMetastoresProp)) { - obj["backendMetastores"] = backendMetastoresProp - } - labelsProp, err := expandDataprocMetastoreFederationEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataprocMetastoreBasePath}}projects/{{project}}/locations/{{location}}/federations?federationId={{federation_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new Federation: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Federation: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating Federation: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/federations/{{federation_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = DataprocMetastoreOperationWaitTime( - config, res, project, "Creating Federation", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create Federation: %s", err) - } - - log.Printf("[DEBUG] Finished creating Federation %q: %#v", d.Id(), res) - - return resourceDataprocMetastoreFederationRead(d, meta) -} - -func resourceDataprocMetastoreFederationRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataprocMetastoreBasePath}}projects/{{project}}/locations/{{location}}/federations/{{federation_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Federation: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataprocMetastoreFederation %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - - if err := d.Set("name", flattenDataprocMetastoreFederationName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("labels", flattenDataprocMetastoreFederationLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("endpoint_uri", flattenDataprocMetastoreFederationEndpointUri(res["endpointUri"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("state", flattenDataprocMetastoreFederationState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("state_message", flattenDataprocMetastoreFederationStateMessage(res["stateMessage"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("uid", flattenDataprocMetastoreFederationUid(res["uid"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("version", flattenDataprocMetastoreFederationVersion(res["version"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("backend_metastores", flattenDataprocMetastoreFederationBackendMetastores(res["backendMetastores"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("terraform_labels", flattenDataprocMetastoreFederationTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - if err := d.Set("effective_labels", flattenDataprocMetastoreFederationEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading Federation: %s", err) - } - - return nil -} - -func resourceDataprocMetastoreFederationUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Federation: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - backendMetastoresProp, err := expandDataprocMetastoreFederationBackendMetastores(d.Get("backend_metastores"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("backend_metastores"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, backendMetastoresProp)) { - obj["backendMetastores"] = backendMetastoresProp - } - labelsProp, err := expandDataprocMetastoreFederationEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{DataprocMetastoreBasePath}}projects/{{project}}/locations/{{location}}/federations/{{federation_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating Federation %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("backend_metastores") { - updateMask = append(updateMask, "backendMetastores") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating Federation %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating Federation %q: %#v", d.Id(), res) - } - - err = DataprocMetastoreOperationWaitTime( - config, res, project, "Updating Federation", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceDataprocMetastoreFederationRead(d, meta) -} - -func resourceDataprocMetastoreFederationDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Federation: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{DataprocMetastoreBasePath}}projects/{{project}}/locations/{{location}}/federations/{{federation_id}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting Federation %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "Federation") - } - - err = DataprocMetastoreOperationWaitTime( - config, res, project, "Deleting Federation", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting Federation %q: %#v", d.Id(), res) - return nil -} - -func resourceDataprocMetastoreFederationImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/federations/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/federations/{{federation_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenDataprocMetastoreFederationName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataprocMetastoreFederationEndpointUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationStateMessage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationBackendMetastores(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.(map[string]interface{}) - transformed := make([]interface{}, 0, len(l)) - for k, raw := range l { - original := raw.(map[string]interface{}) - transformed = append(transformed, map[string]interface{}{ - "rank": k, - "name": flattenDataprocMetastoreFederationBackendMetastoresName(original["name"], d, config), - "metastore_type": flattenDataprocMetastoreFederationBackendMetastoresMetastoreType(original["metastoreType"], d, config), - }) - } - return transformed -} -func flattenDataprocMetastoreFederationBackendMetastoresName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationBackendMetastoresMetastoreType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreFederationTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenDataprocMetastoreFederationEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandDataprocMetastoreFederationVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataprocMetastoreFederationBackendMetastores(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { - if v == nil { - return map[string]interface{}{}, nil - } - m := make(map[string]interface{}) - for _, raw := range v.(*schema.Set).List() { - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandDataprocMetastoreFederationBackendMetastoresName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedMetastoreType, err := expandDataprocMetastoreFederationBackendMetastoresMetastoreType(original["metastore_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMetastoreType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["metastoreType"] = transformedMetastoreType - } - - transformedRank, err := tpgresource.ExpandString(original["rank"], d, config) - if err != nil { - return nil, err - } - m[transformedRank] = transformed - } - return m, nil -} - -func expandDataprocMetastoreFederationBackendMetastoresName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataprocMetastoreFederationBackendMetastoresMetastoreType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataprocMetastoreFederationEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_federation_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_federation_sweeper.go deleted file mode 100644 index 1cb522dbcf3..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_federation_sweeper.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package dataprocmetastore - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("DataprocMetastoreFederation", testSweepDataprocMetastoreFederation) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepDataprocMetastoreFederation(region string) error { - resourceName := "DataprocMetastoreFederation" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://metastore.googleapis.com/v1/projects/{{project}}/locations/{{location}}/federations", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["federations"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - var name string - // Id detected in the delete URL, attempt to use id. - if obj["id"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) - } else if obj["name"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - } else { - log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) - return nil - } - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://metastore.googleapis.com/v1/projects/{{project}}/locations/{{location}}/federations/{{federation_id}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_service.go index 054b4364996..9ac2658f79b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dataprocmetastore/resource_dataproc_metastore_service.go @@ -20,7 +20,6 @@ package dataprocmetastore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -334,38 +333,6 @@ There must be at least one IP address available in the subnet's primary range. T }, }, }, - "scheduled_backup": { - Type: schema.TypeList, - Optional: true, - Description: `The configuration of scheduled backup for the metastore service.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "backup_location": { - Type: schema.TypeString, - Required: true, - Description: `A Cloud Storage URI of a folder, in the format gs:///. A sub-folder containing backup files will be stored below it.`, - }, - "cron_schedule": { - Type: schema.TypeString, - Optional: true, - Description: `The scheduled interval in Cron format, see https://en.wikipedia.org/wiki/Cron The default is empty: scheduled backup is not enabled. Must be specified to enable scheduled backups.`, - }, - "enabled": { - Type: schema.TypeBool, - Computed: true, - Optional: true, - Description: `Defines whether the scheduled backup is enabled. The default value is false.`, - }, - "time_zone": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `Specifies the time zone to be used when interpreting cronSchedule. Must be a time zone name from the time zone database (https://en.wikipedia.org/wiki/List_of_tz_database_time_zones), e.g. America/Los_Angeles or Africa/Abidjan. If left unspecified, the default is UTC.`, - }, - }, - }, - }, "telemetry_config": { Type: schema.TypeList, Computed: true, @@ -478,12 +445,6 @@ func resourceDataprocMetastoreServiceCreate(d *schema.ResourceData, meta interfa } else if v, ok := d.GetOkExists("scaling_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(scalingConfigProp)) && (ok || !reflect.DeepEqual(v, scalingConfigProp)) { obj["scalingConfig"] = scalingConfigProp } - scheduledBackupProp, err := expandDataprocMetastoreServiceScheduledBackup(d.Get("scheduled_backup"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("scheduled_backup"); !tpgresource.IsEmptyValue(reflect.ValueOf(scheduledBackupProp)) && (ok || !reflect.DeepEqual(v, scheduledBackupProp)) { - obj["scheduledBackup"] = scheduledBackupProp - } maintenanceWindowProp, err := expandDataprocMetastoreServiceMaintenanceWindow(d.Get("maintenance_window"), d, config) if err != nil { return err @@ -558,7 +519,6 @@ func resourceDataprocMetastoreServiceCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -567,7 +527,6 @@ func resourceDataprocMetastoreServiceCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Service: %s", err) @@ -620,14 +579,12 @@ func resourceDataprocMetastoreServiceRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DataprocMetastoreService %q", d.Id())) @@ -667,9 +624,6 @@ func resourceDataprocMetastoreServiceRead(d *schema.ResourceData, meta interface if err := d.Set("scaling_config", flattenDataprocMetastoreServiceScalingConfig(res["scalingConfig"], d, config)); err != nil { return fmt.Errorf("Error reading Service: %s", err) } - if err := d.Set("scheduled_backup", flattenDataprocMetastoreServiceScheduledBackup(res["scheduledBackup"], d, config)); err != nil { - return fmt.Errorf("Error reading Service: %s", err) - } if err := d.Set("maintenance_window", flattenDataprocMetastoreServiceMaintenanceWindow(res["maintenanceWindow"], d, config)); err != nil { return fmt.Errorf("Error reading Service: %s", err) } @@ -741,12 +695,6 @@ func resourceDataprocMetastoreServiceUpdate(d *schema.ResourceData, meta interfa } else if v, ok := d.GetOkExists("scaling_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, scalingConfigProp)) { obj["scalingConfig"] = scalingConfigProp } - scheduledBackupProp, err := expandDataprocMetastoreServiceScheduledBackup(d.Get("scheduled_backup"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("scheduled_backup"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, scheduledBackupProp)) { - obj["scheduledBackup"] = scheduledBackupProp - } maintenanceWindowProp, err := expandDataprocMetastoreServiceMaintenanceWindow(d.Get("maintenance_window"), d, config) if err != nil { return err @@ -790,7 +738,6 @@ func resourceDataprocMetastoreServiceUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating Service %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("port") { @@ -805,10 +752,6 @@ func resourceDataprocMetastoreServiceUpdate(d *schema.ResourceData, meta interfa updateMask = append(updateMask, "scalingConfig") } - if d.HasChange("scheduled_backup") { - updateMask = append(updateMask, "scheduledBackup") - } - if d.HasChange("maintenance_window") { updateMask = append(updateMask, "maintenanceWindow") } @@ -854,7 +797,6 @@ func resourceDataprocMetastoreServiceUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -902,8 +844,6 @@ func resourceDataprocMetastoreServiceDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Service %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -913,7 +853,6 @@ func resourceDataprocMetastoreServiceDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Service") @@ -1034,41 +973,6 @@ func flattenDataprocMetastoreServiceScalingConfigScalingFactor(v interface{}, d return v } -func flattenDataprocMetastoreServiceScheduledBackup(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["enabled"] = - flattenDataprocMetastoreServiceScheduledBackupEnabled(original["enabled"], d, config) - transformed["cron_schedule"] = - flattenDataprocMetastoreServiceScheduledBackupCronSchedule(original["cronSchedule"], d, config) - transformed["time_zone"] = - flattenDataprocMetastoreServiceScheduledBackupTimeZone(original["timeZone"], d, config) - transformed["backup_location"] = - flattenDataprocMetastoreServiceScheduledBackupBackupLocation(original["backupLocation"], d, config) - return []interface{}{transformed} -} -func flattenDataprocMetastoreServiceScheduledBackupEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreServiceScheduledBackupCronSchedule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreServiceScheduledBackupTimeZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDataprocMetastoreServiceScheduledBackupBackupLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenDataprocMetastoreServiceMaintenanceWindow(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1385,62 +1289,6 @@ func expandDataprocMetastoreServiceScalingConfigScalingFactor(v interface{}, d t return v, nil } -func expandDataprocMetastoreServiceScheduledBackup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEnabled, err := expandDataprocMetastoreServiceScheduledBackupEnabled(original["enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enabled"] = transformedEnabled - } - - transformedCronSchedule, err := expandDataprocMetastoreServiceScheduledBackupCronSchedule(original["cron_schedule"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCronSchedule); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["cronSchedule"] = transformedCronSchedule - } - - transformedTimeZone, err := expandDataprocMetastoreServiceScheduledBackupTimeZone(original["time_zone"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTimeZone); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["timeZone"] = transformedTimeZone - } - - transformedBackupLocation, err := expandDataprocMetastoreServiceScheduledBackupBackupLocation(original["backup_location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBackupLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["backupLocation"] = transformedBackupLocation - } - - return transformed, nil -} - -func expandDataprocMetastoreServiceScheduledBackupEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataprocMetastoreServiceScheduledBackupCronSchedule(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataprocMetastoreServiceScheduledBackupTimeZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDataprocMetastoreServiceScheduledBackupBackupLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandDataprocMetastoreServiceMaintenanceWindow(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastore/resource_datastore_index.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastore/resource_datastore_index.go index ee45e264d10..b54c5b024d1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastore/resource_datastore_index.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastore/resource_datastore_index.go @@ -20,7 +20,6 @@ package datastore import ( "fmt" "log" - "net/http" "reflect" "time" @@ -152,7 +151,6 @@ func resourceDatastoreIndexCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -161,7 +159,6 @@ func resourceDatastoreIndexCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, }) if err != nil { @@ -229,14 +226,12 @@ func resourceDatastoreIndexRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, }) if err != nil { @@ -290,8 +285,6 @@ func resourceDatastoreIndexDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Index %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -301,7 +294,6 @@ func resourceDatastoreIndexDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.DatastoreIndex409Contention}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_connection_profile.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_connection_profile.go index 7cd77b1d9b2..f55f558a16e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_connection_profile.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_connection_profile.go @@ -20,7 +20,6 @@ package datastream import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -82,13 +81,6 @@ func ResourceDatastreamConnectionProfile() *schema.Resource { }, ExactlyOneOf: []string{"oracle_profile", "gcs_profile", "mysql_profile", "bigquery_profile", "postgresql_profile"}, }, - "create_without_validation": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Create the connection profile without validating it.`, - Default: false, - }, "forward_ssh_connectivity": { Type: schema.TypeList, Optional: true, @@ -437,7 +429,7 @@ func resourceDatastreamConnectionProfileCreate(d *schema.ResourceData, meta inte obj["labels"] = labelsProp } - url, err := tpgresource.ReplaceVars(d, config, "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles?connectionProfileId={{connection_profile_id}}&force={{create_without_validation}}") + url, err := tpgresource.ReplaceVars(d, config, "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/connectionProfiles?connectionProfileId={{connection_profile_id}}") if err != nil { return err } @@ -456,7 +448,6 @@ func resourceDatastreamConnectionProfileCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -465,7 +456,6 @@ func resourceDatastreamConnectionProfileCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ConnectionProfile: %s", err) @@ -532,14 +522,12 @@ func resourceDatastreamConnectionProfileRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DatastreamConnectionProfile %q", d.Id())) @@ -666,7 +654,6 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating ConnectionProfile %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -726,7 +713,6 @@ func resourceDatastreamConnectionProfileUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -774,8 +760,6 @@ func resourceDatastreamConnectionProfileDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ConnectionProfile %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -785,7 +769,6 @@ func resourceDatastreamConnectionProfileDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ConnectionProfile") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection.go index 478c8f9b689..125f72f7ea7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection.go @@ -22,12 +22,11 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -46,22 +45,22 @@ func extractError(d *schema.ResourceData) error { // waitForPrivateConnectionReady waits for a private connection state to become // CREATED, if the state is FAILED propegate the error to the user. func waitForPrivateConnectionReady(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceDatastreamPrivateConnectionRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) state := d.Get("state").(string) if state == "CREATING" { - return retry.RetryableError(fmt.Errorf("PrivateConnection %q has state %q.", name, state)) + return resource.RetryableError(fmt.Errorf("PrivateConnection %q has state %q.", name, state)) } else if state == "CREATED" { log.Printf("[DEBUG] PrivateConnection %q has state %q.", name, state) return nil } else if state == "FAILED" { - return retry.NonRetryableError(extractError(d)) + return resource.NonRetryableError(extractError(d)) } else { - return retry.NonRetryableError(fmt.Errorf("PrivateConnection %q has state %q.", name, state)) + return resource.NonRetryableError(fmt.Errorf("PrivateConnection %q has state %q.", name, state)) } }) } @@ -141,13 +140,6 @@ Format: projects/{project}/global/{networks}/{name}`, }, }, }, - "create_without_validation": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `If set to true, will skip validations.`, - Default: false, - }, "labels": { Type: schema.TypeMap, Optional: true, @@ -239,7 +231,7 @@ func resourceDatastreamPrivateConnectionCreate(d *schema.ResourceData, meta inte obj["labels"] = labelsProp } - url, err := tpgresource.ReplaceVars(d, config, "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/privateConnections?privateConnectionId={{private_connection_id}}&force={{create_without_validation}}") + url, err := tpgresource.ReplaceVars(d, config, "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/privateConnections?privateConnectionId={{private_connection_id}}") if err != nil { return err } @@ -258,7 +250,6 @@ func resourceDatastreamPrivateConnectionCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -267,7 +258,6 @@ func resourceDatastreamPrivateConnectionCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PrivateConnection: %s", err) @@ -338,14 +328,12 @@ func resourceDatastreamPrivateConnectionRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DatastreamPrivateConnection %q", d.Id())) @@ -415,8 +403,6 @@ func resourceDatastreamPrivateConnectionDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PrivateConnection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -426,7 +412,6 @@ func resourceDatastreamPrivateConnectionDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PrivateConnection") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection_sweeper.go index 979ea34bdc8..0333c3af63e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_private_connection_sweeper.go @@ -1,5 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + package datastream import ( @@ -103,7 +118,7 @@ func testSweepDatastreamPrivateConnection(region string) error { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) return nil } - deleteUrl = deleteUrl + name + "?force=true" + deleteUrl = deleteUrl + name // Don't wait on operations as we may have a lot to delete _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_stream.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_stream.go index 4b128c72c85..e8b731be90f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_stream.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/datastream/resource_datastream_stream.go @@ -21,14 +21,13 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -70,20 +69,20 @@ func resourceDatastreamStreamCustomDiff(_ context.Context, diff *schema.Resource // waitForDatastreamStreamReady waits for an agent pool to reach a stable state to indicate that it's ready. func waitForDatastreamStreamReady(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceDatastreamStreamRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) state := d.Get("state").(string) if state == "STARTING" || state == "DRAINING" { - return retry.RetryableError(fmt.Errorf("Stream %q has state %q.", name, state)) + return resource.RetryableError(fmt.Errorf("Stream %q has state %q.", name, state)) } else if state == "NOT_STARTED" || state == "RUNNING" || state == "PAUSED" { log.Printf("[DEBUG] Stream %q has state %q.", name, state) return nil } else { - return retry.NonRetryableError(fmt.Errorf("Stream %q has state %q.", name, state)) + return resource.NonRetryableError(fmt.Errorf("Stream %q has state %q.", name, state)) } }) } @@ -1261,13 +1260,6 @@ https://www.postgresql.org/docs/current/datatype.html`, }, ExactlyOneOf: []string{"backfill_all", "backfill_none"}, }, - "create_without_validation": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Create the stream without validating it.`, - Default: false, - }, "customer_managed_encryption_key": { Type: schema.TypeString, Optional: true, @@ -1380,7 +1372,7 @@ func resourceDatastreamStreamCreate(d *schema.ResourceData, meta interface{}) er return err } - url, err := tpgresource.ReplaceVars(d, config, "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/streams?streamId={{stream_id}}&force={{create_without_validation}}") + url, err := tpgresource.ReplaceVars(d, config, "{{DatastreamBasePath}}projects/{{project}}/locations/{{location}}/streams?streamId={{stream_id}}") if err != nil { return err } @@ -1399,7 +1391,6 @@ func resourceDatastreamStreamCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1408,7 +1399,6 @@ func resourceDatastreamStreamCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Stream: %s", err) @@ -1486,14 +1476,12 @@ func resourceDatastreamStreamRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DatastreamStream %q", d.Id())) @@ -1610,7 +1598,6 @@ func resourceDatastreamStreamUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Stream %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -1685,7 +1672,6 @@ func resourceDatastreamStreamUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1736,8 +1722,6 @@ func resourceDatastreamStreamDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Stream %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1747,7 +1731,6 @@ func resourceDatastreamStreamDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Stream") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/deploymentmanager/resource_deployment_manager_deployment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/deploymentmanager/resource_deployment_manager_deployment.go index d6a311844fb..ca6f5a6313d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/deploymentmanager/resource_deployment_manager_deployment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/deploymentmanager/resource_deployment_manager_deployment.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -281,7 +280,6 @@ func resourceDeploymentManagerDeploymentCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -290,7 +288,6 @@ func resourceDeploymentManagerDeploymentCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Deployment: %s", err) @@ -344,14 +341,12 @@ func resourceDeploymentManagerDeploymentRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DeploymentManagerDeployment %q", d.Id())) @@ -431,8 +426,6 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -446,7 +439,6 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Deployment %q: %s", d.Id(), err) @@ -511,8 +503,6 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -526,7 +516,6 @@ func resourceDeploymentManagerDeploymentUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Deployment %q: %s", d.Id(), err) @@ -574,8 +563,6 @@ func resourceDeploymentManagerDeploymentDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Deployment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -585,7 +572,6 @@ func resourceDeploymentManagerDeploymentDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Deployment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_agent.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_agent.go index 56f5d26cb67..97d33d346d0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_agent.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_agent.go @@ -20,7 +20,6 @@ package dialogflow import ( "fmt" "log" - "net/http" "reflect" "time" @@ -253,7 +252,6 @@ func resourceDialogflowAgentCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -262,7 +260,6 @@ func resourceDialogflowAgentCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Agent: %s", err) @@ -305,14 +302,12 @@ func resourceDialogflowAgentRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowAgent %q", d.Id())) @@ -445,7 +440,6 @@ func resourceDialogflowAgentUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Agent %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -460,7 +454,6 @@ func resourceDialogflowAgentUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -499,8 +492,6 @@ func resourceDialogflowAgentDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Agent %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -510,7 +501,6 @@ func resourceDialogflowAgentDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Agent") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_entity_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_entity_type.go index ea5efd65346..9e9778015e4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_entity_type.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_entity_type.go @@ -20,7 +20,6 @@ package dialogflow import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -174,7 +173,6 @@ func resourceDialogflowEntityTypeCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -183,7 +181,6 @@ func resourceDialogflowEntityTypeCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EntityType: %s", err) @@ -247,14 +244,12 @@ func resourceDialogflowEntityTypeRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowEntityType %q", d.Id())) @@ -330,7 +325,6 @@ func resourceDialogflowEntityTypeUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating EntityType %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -345,7 +339,6 @@ func resourceDialogflowEntityTypeUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -384,8 +377,6 @@ func resourceDialogflowEntityTypeDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EntityType %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -395,7 +386,6 @@ func resourceDialogflowEntityTypeDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EntityType") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_fulfillment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_fulfillment.go index 13de1cc22d3..eeb6a9baefb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_fulfillment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_fulfillment.go @@ -20,7 +20,6 @@ package dialogflow import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -181,7 +180,6 @@ func resourceDialogflowFulfillmentCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -190,7 +188,6 @@ func resourceDialogflowFulfillmentCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Fulfillment: %s", err) @@ -254,14 +251,12 @@ func resourceDialogflowFulfillmentRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowFulfillment %q", d.Id())) @@ -337,7 +332,6 @@ func resourceDialogflowFulfillmentUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating Fulfillment %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -377,7 +371,6 @@ func resourceDialogflowFulfillmentUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -418,8 +411,6 @@ func resourceDialogflowFulfillmentDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Fulfillment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -429,7 +420,6 @@ func resourceDialogflowFulfillmentDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Fulfillment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_intent.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_intent.go index 0d82e7b7efa..4a67b1ced5f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_intent.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflow/resource_dialogflow_intent.go @@ -20,7 +20,6 @@ package dialogflow import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -283,7 +282,6 @@ func resourceDialogflowIntentCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -292,7 +290,6 @@ func resourceDialogflowIntentCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Intent: %s", err) @@ -356,14 +353,12 @@ func resourceDialogflowIntentRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowIntent %q", d.Id())) @@ -502,7 +497,6 @@ func resourceDialogflowIntentUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Intent %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -517,7 +511,6 @@ func resourceDialogflowIntentUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -556,8 +549,6 @@ func resourceDialogflowIntentDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Intent %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -567,7 +558,6 @@ func resourceDialogflowIntentDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Intent") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_agent.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_agent.go index 586e76a17b6..272966a76ca 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_agent.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_agent.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -389,7 +388,6 @@ func resourceDialogflowCXAgentCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -398,7 +396,6 @@ func resourceDialogflowCXAgentCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Agent: %s", err) @@ -444,14 +441,12 @@ func resourceDialogflowCXAgentRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXAgent %q", d.Id())) @@ -605,7 +600,6 @@ func resourceDialogflowCXAgentUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Agent %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -677,7 +671,6 @@ func resourceDialogflowCXAgentUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -718,8 +711,6 @@ func resourceDialogflowCXAgentDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Agent %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -729,7 +720,6 @@ func resourceDialogflowCXAgentDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Agent") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go index 023c6da949e..910aa5a4c74 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_entity_type.go @@ -20,7 +20,6 @@ package dialogflowcx import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -217,8 +216,6 @@ func resourceDialogflowCXEntityTypeCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -241,7 +238,6 @@ func resourceDialogflowCXEntityTypeCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EntityType: %s", err) @@ -281,8 +277,6 @@ func resourceDialogflowCXEntityTypeRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -303,7 +297,6 @@ func resourceDialogflowCXEntityTypeRead(d *schema.ResourceData, meta interface{} Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXEntityType %q", d.Id())) @@ -396,7 +389,6 @@ func resourceDialogflowCXEntityTypeUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating EntityType %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -463,7 +455,6 @@ func resourceDialogflowCXEntityTypeUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -498,8 +489,6 @@ func resourceDialogflowCXEntityTypeDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -524,7 +513,6 @@ func resourceDialogflowCXEntityTypeDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EntityType") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_environment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_environment.go index e44d16a51cd..e2cf4f566e6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_environment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_environment.go @@ -20,7 +20,6 @@ package dialogflowcx import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -144,8 +143,6 @@ func resourceDialogflowCXEnvironmentCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -168,7 +165,6 @@ func resourceDialogflowCXEnvironmentCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Environment: %s", err) @@ -229,8 +225,6 @@ func resourceDialogflowCXEnvironmentRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -251,7 +245,6 @@ func resourceDialogflowCXEnvironmentRead(d *schema.ResourceData, meta interface{ Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXEnvironment %q", d.Id())) @@ -311,7 +304,6 @@ func resourceDialogflowCXEnvironmentUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating Environment %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -362,7 +354,6 @@ func resourceDialogflowCXEnvironmentUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -404,8 +395,6 @@ func resourceDialogflowCXEnvironmentDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -430,7 +419,6 @@ func resourceDialogflowCXEnvironmentDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Environment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_flow.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_flow.go index 7446da3d287..590f27ddc95 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_flow.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_flow.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -772,8 +771,6 @@ func resourceDialogflowCXFlowCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -824,7 +821,6 @@ func resourceDialogflowCXFlowCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Flow: %s", err) @@ -864,8 +860,6 @@ func resourceDialogflowCXFlowRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -886,7 +880,6 @@ func resourceDialogflowCXFlowRead(d *schema.ResourceData, meta interface{}) erro Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXFlow %q", d.Id())) @@ -984,7 +977,6 @@ func resourceDialogflowCXFlowUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Flow %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -1051,7 +1043,6 @@ func resourceDialogflowCXFlowUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1086,8 +1077,6 @@ func resourceDialogflowCXFlowDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -1123,7 +1112,6 @@ func resourceDialogflowCXFlowDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Flow") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_intent.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_intent.go index f893fddc0d6..02d2a419f21 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_intent.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_intent.go @@ -20,7 +20,6 @@ package dialogflowcx import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -296,8 +295,6 @@ func resourceDialogflowCXIntentCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -348,7 +345,6 @@ func resourceDialogflowCXIntentCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Intent: %s", err) @@ -388,8 +384,6 @@ func resourceDialogflowCXIntentRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -410,7 +404,6 @@ func resourceDialogflowCXIntentRead(d *schema.ResourceData, meta interface{}) er Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXIntent %q", d.Id())) @@ -514,7 +507,6 @@ func resourceDialogflowCXIntentUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Intent %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -581,7 +573,6 @@ func resourceDialogflowCXIntentUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -616,8 +607,6 @@ func resourceDialogflowCXIntentDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -653,7 +642,6 @@ func resourceDialogflowCXIntentDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Intent") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_page.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_page.go index 55dd1ae2301..fac7c4424a0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_page.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_page.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -1482,8 +1481,6 @@ func resourceDialogflowCXPageCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -1506,7 +1503,6 @@ func resourceDialogflowCXPageCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Page: %s", err) @@ -1546,8 +1542,6 @@ func resourceDialogflowCXPageRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -1568,7 +1562,6 @@ func resourceDialogflowCXPageRead(d *schema.ResourceData, meta interface{}) erro Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXPage %q", d.Id())) @@ -1664,7 +1657,6 @@ func resourceDialogflowCXPageUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Page %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -1731,7 +1723,6 @@ func resourceDialogflowCXPageUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1766,8 +1757,6 @@ func resourceDialogflowCXPageDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -1792,7 +1781,6 @@ func resourceDialogflowCXPageDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Page") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go index a409696e192..8343f9d3fe7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_security_settings.go @@ -20,7 +20,6 @@ package dialogflowcx import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -277,7 +276,6 @@ func resourceDialogflowCXSecuritySettingsCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -286,7 +284,6 @@ func resourceDialogflowCXSecuritySettingsCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SecuritySettings: %s", err) @@ -332,14 +329,12 @@ func resourceDialogflowCXSecuritySettingsRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXSecuritySettings %q", d.Id())) @@ -469,7 +464,6 @@ func resourceDialogflowCXSecuritySettingsUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating SecuritySettings %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -533,7 +527,6 @@ func resourceDialogflowCXSecuritySettingsUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -574,8 +567,6 @@ func resourceDialogflowCXSecuritySettingsDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting SecuritySettings %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -585,7 +576,6 @@ func resourceDialogflowCXSecuritySettingsDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SecuritySettings") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_test_case.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_test_case.go index 65236586847..8aea561bd65 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_test_case.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_test_case.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -627,8 +626,6 @@ func resourceDialogflowCXTestCaseCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -651,7 +648,6 @@ func resourceDialogflowCXTestCaseCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TestCase: %s", err) @@ -691,8 +687,6 @@ func resourceDialogflowCXTestCaseRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -713,7 +707,6 @@ func resourceDialogflowCXTestCaseRead(d *schema.ResourceData, meta interface{}) Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXTestCase %q", d.Id())) @@ -794,7 +787,6 @@ func resourceDialogflowCXTestCaseUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating TestCase %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("tags") { @@ -853,7 +845,6 @@ func resourceDialogflowCXTestCaseUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -888,8 +879,6 @@ func resourceDialogflowCXTestCaseDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -914,7 +903,6 @@ func resourceDialogflowCXTestCaseDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TestCase") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_version.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_version.go index f3092060a76..d4f4e72ad87 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_version.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_version.go @@ -20,7 +20,6 @@ package dialogflowcx import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -164,8 +163,6 @@ func resourceDialogflowCXVersionCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -188,7 +185,6 @@ func resourceDialogflowCXVersionCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Version: %s", err) @@ -249,8 +245,6 @@ func resourceDialogflowCXVersionRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -271,7 +265,6 @@ func resourceDialogflowCXVersionRead(d *schema.ResourceData, meta interface{}) e Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXVersion %q", d.Id())) @@ -328,7 +321,6 @@ func resourceDialogflowCXVersionUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Version %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -375,7 +367,6 @@ func resourceDialogflowCXVersionUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -410,8 +401,6 @@ func resourceDialogflowCXVersionDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -436,7 +425,6 @@ func resourceDialogflowCXVersionDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Version") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_webhook.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_webhook.go index d10681fd8a2..bd591a6aa33 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_webhook.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dialogflowcx/resource_dialogflow_cx_webhook.go @@ -20,7 +20,6 @@ package dialogflowcx import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -248,8 +247,6 @@ func resourceDialogflowCXWebhookCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -272,7 +269,6 @@ func resourceDialogflowCXWebhookCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Webhook: %s", err) @@ -312,8 +308,6 @@ func resourceDialogflowCXWebhookRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -334,7 +328,6 @@ func resourceDialogflowCXWebhookRead(d *schema.ResourceData, meta interface{}) e Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DialogflowCXWebhook %q", d.Id())) @@ -439,7 +432,6 @@ func resourceDialogflowCXWebhookUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Webhook %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -510,7 +502,6 @@ func resourceDialogflowCXWebhookUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -545,8 +536,6 @@ func resourceDialogflowCXWebhookDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - // extract location from the parent location := "" @@ -571,7 +560,6 @@ func resourceDialogflowCXWebhookDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Webhook") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_chat_engine.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_chat_engine.go index 279a214b811..898183a4f91 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_chat_engine.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_chat_engine.go @@ -20,7 +20,6 @@ package discoveryengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -260,7 +259,6 @@ func resourceDiscoveryEngineChatEngineCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -269,7 +267,6 @@ func resourceDiscoveryEngineChatEngineCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ChatEngine: %s", err) @@ -336,14 +333,12 @@ func resourceDiscoveryEngineChatEngineRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DiscoveryEngineChatEngine %q", d.Id())) @@ -415,7 +410,6 @@ func resourceDiscoveryEngineChatEngineUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating ChatEngine %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -443,7 +437,6 @@ func resourceDiscoveryEngineChatEngineUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -484,8 +477,6 @@ func resourceDiscoveryEngineChatEngineDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ChatEngine %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -495,7 +486,6 @@ func resourceDiscoveryEngineChatEngineDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ChatEngine") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_data_store.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_data_store.go index 3d8e9b145fd..5983492ef92 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_data_store.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_data_store.go @@ -20,7 +20,6 @@ package discoveryengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -96,103 +95,6 @@ data store is not configured as site search (GENERIC vertical and PUBLIC_WEBSITE contentConfig), this flag will be ignored.`, Default: false, }, - "document_processing_config": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Configuration for Document understanding and enrichment.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "default_parsing_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configurations for default Document parser. If not specified, this resource -will be configured to use a default DigitalParsingConfig, and the default parsing -config will be applied to all file types for Document parsing.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "digital_parsing_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configurations applied to digital parser.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - ExactlyOneOf: []string{}, - }, - "ocr_parsing_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configurations applied to OCR parser. Currently it only applies to PDFs.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "use_native_text": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, will use native text instead of OCR text on pages containing native text.`, - }, - }, - }, - ExactlyOneOf: []string{}, - }, - }, - }, - }, - "parsing_config_overrides": { - Type: schema.TypeSet, - Optional: true, - Description: `Map from file type to override the default parsing configuration based on the file type. Supported keys: - * 'pdf': Override parsing config for PDF files, either digital parsing, ocr parsing or layout parsing is supported. - * 'html': Override parsing config for HTML files, only digital parsing and or layout parsing are supported. - * 'docx': Override parsing config for DOCX files, only digital parsing and or layout parsing are supported.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "file_type": { - Type: schema.TypeString, - Required: true, - }, - "digital_parsing_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configurations applied to digital parser.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - ExactlyOneOf: []string{}, - }, - "ocr_parsing_config": { - Type: schema.TypeList, - Optional: true, - Description: `Configurations applied to OCR parser. Currently it only applies to PDFs.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "use_native_text": { - Type: schema.TypeBool, - Optional: true, - Description: `If true, will use native text instead of OCR text on pages containing native text.`, - }, - }, - }, - ExactlyOneOf: []string{}, - }, - }, - }, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The full resource name of the Document Processing Config. Format: -'projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}/documentProcessingConfig'.`, - }, - }, - }, - }, "solution_types": { Type: schema.TypeList, Optional: true, @@ -264,12 +166,6 @@ func resourceDiscoveryEngineDataStoreCreate(d *schema.ResourceData, meta interfa } else if v, ok := d.GetOkExists("content_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(contentConfigProp)) && (ok || !reflect.DeepEqual(v, contentConfigProp)) { obj["contentConfig"] = contentConfigProp } - documentProcessingConfigProp, err := expandDiscoveryEngineDataStoreDocumentProcessingConfig(d.Get("document_processing_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("document_processing_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(documentProcessingConfigProp)) && (ok || !reflect.DeepEqual(v, documentProcessingConfigProp)) { - obj["documentProcessingConfig"] = documentProcessingConfigProp - } url, err := tpgresource.ReplaceVars(d, config, "{{DiscoveryEngineBasePath}}projects/{{project}}/locations/{{location}}/collections/default_collection/dataStores?dataStoreId={{data_store_id}}&createAdvancedSiteSearch={{create_advanced_site_search}}") if err != nil { @@ -290,7 +186,6 @@ func resourceDiscoveryEngineDataStoreCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -299,7 +194,6 @@ func resourceDiscoveryEngineDataStoreCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DataStore: %s", err) @@ -352,14 +246,12 @@ func resourceDiscoveryEngineDataStoreRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DiscoveryEngineDataStore %q", d.Id())) @@ -387,9 +279,6 @@ func resourceDiscoveryEngineDataStoreRead(d *schema.ResourceData, meta interface if err := d.Set("content_config", flattenDiscoveryEngineDataStoreContentConfig(res["contentConfig"], d, config)); err != nil { return fmt.Errorf("Error reading DataStore: %s", err) } - if err := d.Set("document_processing_config", flattenDiscoveryEngineDataStoreDocumentProcessingConfig(res["documentProcessingConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading DataStore: %s", err) - } if err := d.Set("create_time", flattenDiscoveryEngineDataStoreCreateTime(res["createTime"], d, config)); err != nil { return fmt.Errorf("Error reading DataStore: %s", err) } @@ -426,7 +315,6 @@ func resourceDiscoveryEngineDataStoreUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating DataStore %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -454,7 +342,6 @@ func resourceDiscoveryEngineDataStoreUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -502,8 +389,6 @@ func resourceDiscoveryEngineDataStoreDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DataStore %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -513,7 +398,6 @@ func resourceDiscoveryEngineDataStoreDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DataStore") @@ -575,108 +459,6 @@ func flattenDiscoveryEngineDataStoreContentConfig(v interface{}, d *schema.Resou return v } -func flattenDiscoveryEngineDataStoreDocumentProcessingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["name"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigName(original["name"], d, config) - transformed["default_parsing_config"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfig(original["defaultParsingConfig"], d, config) - transformed["parsing_config_overrides"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverrides(original["parsingConfigOverrides"], d, config) - return []interface{}{transformed} -} -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["digital_parsing_config"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigDigitalParsingConfig(original["digitalParsingConfig"], d, config) - transformed["ocr_parsing_config"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfig(original["ocrParsingConfig"], d, config) - return []interface{}{transformed} -} -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigDigitalParsingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["use_native_text"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfigUseNativeText(original["useNativeText"], d, config) - return []interface{}{transformed} -} -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfigUseNativeText(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverrides(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.(map[string]interface{}) - transformed := make([]interface{}, 0, len(l)) - for k, raw := range l { - original := raw.(map[string]interface{}) - transformed = append(transformed, map[string]interface{}{ - "file_type": k, - "digital_parsing_config": flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesDigitalParsingConfig(original["digitalParsingConfig"], d, config), - "ocr_parsing_config": flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfig(original["ocrParsingConfig"], d, config), - }) - } - return transformed -} -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesDigitalParsingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["use_native_text"] = - flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfigUseNativeText(original["useNativeText"], d, config) - return []interface{}{transformed} -} -func flattenDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfigUseNativeText(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenDiscoveryEngineDataStoreCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -696,174 +478,3 @@ func expandDiscoveryEngineDataStoreSolutionTypes(v interface{}, d tpgresource.Te func expandDiscoveryEngineDataStoreContentConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func expandDiscoveryEngineDataStoreDocumentProcessingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedDefaultParsingConfig, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfig(original["default_parsing_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDefaultParsingConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["defaultParsingConfig"] = transformedDefaultParsingConfig - } - - transformedParsingConfigOverrides, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverrides(original["parsing_config_overrides"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedParsingConfigOverrides); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["parsingConfigOverrides"] = transformedParsingConfigOverrides - } - - return transformed, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDigitalParsingConfig, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigDigitalParsingConfig(original["digital_parsing_config"], d, config) - if err != nil { - return nil, err - } else { - transformed["digitalParsingConfig"] = transformedDigitalParsingConfig - } - - transformedOcrParsingConfig, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfig(original["ocr_parsing_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOcrParsingConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["ocrParsingConfig"] = transformedOcrParsingConfig - } - - return transformed, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigDigitalParsingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUseNativeText, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfigUseNativeText(original["use_native_text"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUseNativeText); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["useNativeText"] = transformedUseNativeText - } - - return transformed, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigDefaultParsingConfigOcrParsingConfigUseNativeText(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverrides(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { - if v == nil { - return map[string]interface{}{}, nil - } - m := make(map[string]interface{}) - for _, raw := range v.(*schema.Set).List() { - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDigitalParsingConfig, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesDigitalParsingConfig(original["digital_parsing_config"], d, config) - if err != nil { - return nil, err - } else { - transformed["digitalParsingConfig"] = transformedDigitalParsingConfig - } - - transformedOcrParsingConfig, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfig(original["ocr_parsing_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOcrParsingConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["ocrParsingConfig"] = transformedOcrParsingConfig - } - - transformedFileType, err := tpgresource.ExpandString(original["file_type"], d, config) - if err != nil { - return nil, err - } - m[transformedFileType] = transformed - } - return m, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesDigitalParsingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUseNativeText, err := expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfigUseNativeText(original["use_native_text"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUseNativeText); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["useNativeText"] = transformedUseNativeText - } - - return transformed, nil -} - -func expandDiscoveryEngineDataStoreDocumentProcessingConfigParsingConfigOverridesOcrParsingConfigUseNativeText(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_search_engine.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_search_engine.go index ead9927f391..9427679df28 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_search_engine.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/discoveryengine/resource_discovery_engine_search_engine.go @@ -20,7 +20,6 @@ package discoveryengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -230,7 +229,6 @@ func resourceDiscoveryEngineSearchEngineCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -239,7 +237,6 @@ func resourceDiscoveryEngineSearchEngineCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SearchEngine: %s", err) @@ -306,14 +303,12 @@ func resourceDiscoveryEngineSearchEngineRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DiscoveryEngineSearchEngine %q", d.Id())) @@ -391,7 +386,6 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating SearchEngine %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -423,7 +417,6 @@ func resourceDiscoveryEngineSearchEngineUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -464,8 +457,6 @@ func resourceDiscoveryEngineSearchEngineDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting SearchEngine %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -475,7 +466,6 @@ func resourceDiscoveryEngineSearchEngineDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SearchEngine") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_keys.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_keys.go index c12044763a7..41849645004 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_keys.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_keys.go @@ -3,231 +3,391 @@ package dns import ( + "context" "fmt" - "log" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" "google.golang.org/api/dns/v1" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + + "github.com/hashicorp/terraform-provider-google/google/fwmodels" + "github.com/hashicorp/terraform-provider-google/google/fwresource" + "github.com/hashicorp/terraform-provider-google/google/fwtransport" ) -// DNSSEC Algorithm Numbers: https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml -// The following are algorithms that are supported by Cloud DNS -var dnssecAlgoNums = map[string]int{ - "rsasha1": 5, - "rsasha256": 8, - "rsasha512": 10, - "ecdsap256sha256": 13, - "ecdsap384sha384": 14, +// Ensure the implementation satisfies the expected interfaces +var ( + _ datasource.DataSource = &GoogleDnsKeysDataSource{} + _ datasource.DataSourceWithConfigure = &GoogleDnsKeysDataSource{} +) + +func NewGoogleDnsKeysDataSource() datasource.DataSource { + return &GoogleDnsKeysDataSource{} } -// DS RR Digest Types: https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml -// The following are digests that are supported by Cloud DNS -var dnssecDigestType = map[string]int{ - "sha1": 1, - "sha256": 2, - "sha384": 4, +// GoogleDnsKeysDataSource defines the data source implementation +type GoogleDnsKeysDataSource struct { + client *dns.Service + project types.String } -func DataSourceDNSKeys() *schema.Resource { - return &schema.Resource{ - Read: dataSourceDNSKeysRead, +type GoogleDnsKeysModel struct { + Id types.String `tfsdk:"id"` + ManagedZone types.String `tfsdk:"managed_zone"` + Project types.String `tfsdk:"project"` + KeySigningKeys types.List `tfsdk:"key_signing_keys"` + ZoneSigningKeys types.List `tfsdk:"zone_signing_keys"` +} - Schema: map[string]*schema.Schema{ - "managed_zone": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - "key_signing_keys": { - Type: schema.TypeList, - Computed: true, - Elem: kskResource(), - }, - "zone_signing_keys": { - Type: schema.TypeList, - Computed: true, - Elem: dnsKeyResource(), - }, - }, +type GoogleZoneSigningKey struct { + Algorithm types.String `tfsdk:"algorithm"` + CreationTime types.String `tfsdk:"creation_time"` + Description types.String `tfsdk:"description"` + Id types.String `tfsdk:"id"` + IsActive types.Bool `tfsdk:"is_active"` + KeyLength types.Int64 `tfsdk:"key_length"` + KeyTag types.Int64 `tfsdk:"key_tag"` + PublicKey types.String `tfsdk:"public_key"` + Digests types.List `tfsdk:"digests"` +} + +type GoogleKeySigningKey struct { + Algorithm types.String `tfsdk:"algorithm"` + CreationTime types.String `tfsdk:"creation_time"` + Description types.String `tfsdk:"description"` + Id types.String `tfsdk:"id"` + IsActive types.Bool `tfsdk:"is_active"` + KeyLength types.Int64 `tfsdk:"key_length"` + KeyTag types.Int64 `tfsdk:"key_tag"` + PublicKey types.String `tfsdk:"public_key"` + Digests types.List `tfsdk:"digests"` + + DSRecord types.String `tfsdk:"ds_record"` +} + +type GoogleZoneSigningKeyDigest struct { + Digest types.String `tfsdk:"digest"` + Type types.String `tfsdk:"type"` +} + +var ( + digestAttrTypes = map[string]attr.Type{ + "digest": types.StringType, + "type": types.StringType, } +) + +func (d *GoogleDnsKeysDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_dns_keys" } -func dnsKeyResource() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "algorithm": { - Type: schema.TypeString, - Computed: true, - }, - "creation_time": { - Type: schema.TypeString, - Computed: true, - }, - "description": { - Type: schema.TypeString, - Computed: true, - }, - "digests": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "digest": { - Type: schema.TypeString, - Optional: true, - }, - "type": { - Type: schema.TypeString, - Optional: true, - }, - }, - }, - }, - "id": { - Type: schema.TypeString, - Computed: true, +func (d *GoogleDnsKeysDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "Get the DNSKEY and DS records of DNSSEC-signed managed zones", + + Attributes: map[string]schema.Attribute{ + "managed_zone": schema.StringAttribute{ + Description: "The Name of the zone.", + MarkdownDescription: "The Name of the zone.", + Required: true, }, - "is_active": { - Type: schema.TypeBool, - Computed: true, + "project": schema.StringAttribute{ + Description: "The ID of the project for the Google Cloud.", + MarkdownDescription: "The ID of the project for the Google Cloud.", + Optional: true, + Computed: true, }, - "key_length": { - Type: schema.TypeInt, - Computed: true, + "id": schema.StringAttribute{ + Description: "DNS keys identifier", + MarkdownDescription: "DNS keys identifier", + Computed: true, }, - "key_tag": { - Type: schema.TypeInt, - Computed: true, + // Issue with using computed blocks in the plugin framework with protocol 5 + // See: https://developer.hashicorp.com/terraform/plugin/framework/migrating/attributes-blocks/blocks-computed#framework + "zone_signing_keys": schema.ListAttribute{ + Description: "A list of Zone-signing key (ZSK) records.", + MarkdownDescription: "A list of Zone-signing key (ZSK) records.", + ElementType: dnsKeyObject(), + Computed: true, }, - "public_key": { - Type: schema.TypeString, - Computed: true, + // Issue with using computed blocks in the plugin framework with protocol 5 + // See: https://developer.hashicorp.com/terraform/plugin/framework/migrating/attributes-blocks/blocks-computed#framework + "key_signing_keys": schema.ListAttribute{ + Description: "A list of Key-signing key (KSK) records.", + MarkdownDescription: "A list of Key-signing key (KSK) records.", + ElementType: kskObject(), + Computed: true, }, }, } } -func kskResource() *schema.Resource { - resource := dnsKeyResource() +func (d *GoogleDnsKeysDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } - resource.Schema["ds_record"] = &schema.Schema{ - Type: schema.TypeString, - Computed: true, + p, ok := req.ProviderData.(*fwtransport.FrameworkProviderConfig) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *fwtransport.FrameworkProviderConfig, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return } - return resource + d.client = p.NewDnsClient(p.UserAgent, &resp.Diagnostics) + d.project = p.Project } -func generateDSRecord(signingKey *dns.DnsKey) (string, error) { - algoNum, found := dnssecAlgoNums[signingKey.Algorithm] - if !found { - return "", fmt.Errorf("DNSSEC Algorithm number for %s not found", signingKey.Algorithm) +func (d *GoogleDnsKeysDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data GoogleDnsKeysModel + var metaData *fwmodels.ProviderMetaModel + var diags diag.Diagnostics + + // Read Provider meta into the meta model + resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &metaData)...) + if resp.Diagnostics.HasError() { + return } - digestType, found := dnssecDigestType[signingKey.Digests[0].Type] - if !found { - return "", fmt.Errorf("DNSSEC Digest type for %s not found", signingKey.Digests[0].Type) + d.client.UserAgent = fwtransport.GenerateFrameworkUserAgentString(metaData, d.client.UserAgent) + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return } - return fmt.Sprintf("%d %d %d %s", - signingKey.KeyTag, - algoNum, - digestType, - signingKey.Digests[0].Digest), nil + fv := fwresource.ParseProjectFieldValueFramework("managedZones", data.ManagedZone.ValueString(), "project", data.Project, d.project, false, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + data.Project = types.StringValue(fv.Project) + data.ManagedZone = types.StringValue(fv.Name) + + data.Id = types.StringValue(fmt.Sprintf("projects/%s/managedZones/%s", data.Project.ValueString(), data.ManagedZone.ValueString())) + + tflog.Debug(ctx, fmt.Sprintf("fetching DNS keys from managed zone %s", data.ManagedZone.ValueString())) + + clientResp, err := d.client.DnsKeys.List(data.Project.ValueString(), data.ManagedZone.ValueString()).Do() + if err != nil { + resp.Diagnostics.AddError(fmt.Sprintf("Error when reading or editing dataSourceDnsKeys"), err.Error()) + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) + return + } + + tflog.Trace(ctx, "read dns keys data source") + + zoneSigningKeys, keySigningKeys := flattenSigningKeys(ctx, clientResp.DnsKeys, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } + + zskObjType := types.ObjectType{}.WithAttributeTypes(getDnsKeyAttrs("zoneSigning")) + data.ZoneSigningKeys, diags = types.ListValueFrom(ctx, zskObjType, zoneSigningKeys) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + kskObjType := types.ObjectType{}.WithAttributeTypes(getDnsKeyAttrs("keySigning")) + data.KeySigningKeys, diags = types.ListValueFrom(ctx, kskObjType, keySigningKeys) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func flattenSigningKeys(signingKeys []*dns.DnsKey, keyType string) []map[string]interface{} { - var keys []map[string]interface{} +// dnsKeyObject is a helper function for the zone_signing_keys schema and +// is also used by key_signing_keys schema (called in kskObject defined below) +func dnsKeyObject() types.ObjectType { + // See comments in Schema function + // Also: https://github.com/hashicorp/terraform-plugin-framework/issues/214#issuecomment-1194666110 + return types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "algorithm": types.StringType, + "creation_time": types.StringType, + "description": types.StringType, + "id": types.StringType, + "is_active": types.BoolType, + "key_length": types.Int64Type, + "key_tag": types.Int64Type, + "public_key": types.StringType, + "digests": types.ListType{ + ElemType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "digest": types.StringType, + "type": types.StringType, + }, + }, + }, + }, + } +} + +// kskObject is a helper function for the key_signing_keys schema +func kskObject() types.ObjectType { + nbo := dnsKeyObject() + + nbo.AttrTypes["ds_record"] = types.StringType + + return nbo +} + +func flattenSigningKeys(ctx context.Context, signingKeys []*dns.DnsKey, diags *diag.Diagnostics) ([]types.Object, []types.Object) { + var zoneSigningKeys []types.Object + var keySigningKeys []types.Object + var d diag.Diagnostics for _, signingKey := range signingKeys { - if signingKey != nil && signingKey.Type == keyType { - data := map[string]interface{}{ - "algorithm": signingKey.Algorithm, - "creation_time": signingKey.CreationTime, - "description": signingKey.Description, - "digests": flattenDigests(signingKey.Digests), - "id": signingKey.Id, - "is_active": signingKey.IsActive, - "key_length": signingKey.KeyLength, - "key_tag": signingKey.KeyTag, - "public_key": signingKey.PublicKey, + if signingKey != nil { + var digests []types.Object + for _, dig := range signingKey.Digests { + digest := GoogleZoneSigningKeyDigest{ + Digest: types.StringValue(dig.Digest), + Type: types.StringValue(dig.Type), + } + obj, d := types.ObjectValueFrom(ctx, digestAttrTypes, digest) + diags.Append(d...) + if diags.HasError() { + return zoneSigningKeys, keySigningKeys + } + + digests = append(digests, obj) } if signingKey.Type == "keySigning" && len(signingKey.Digests) > 0 { + ksk := GoogleKeySigningKey{ + Algorithm: types.StringValue(signingKey.Algorithm), + CreationTime: types.StringValue(signingKey.CreationTime), + Description: types.StringValue(signingKey.Description), + Id: types.StringValue(signingKey.Id), + IsActive: types.BoolValue(signingKey.IsActive), + KeyLength: types.Int64Value(signingKey.KeyLength), + KeyTag: types.Int64Value(signingKey.KeyTag), + PublicKey: types.StringValue(signingKey.PublicKey), + } + + objType := types.ObjectType{}.WithAttributeTypes(digestAttrTypes) + ksk.Digests, d = types.ListValueFrom(ctx, objType, digests) + diags.Append(d...) + if diags.HasError() { + return zoneSigningKeys, keySigningKeys + } + dsRecord, err := generateDSRecord(signingKey) - if err == nil { - data["ds_record"] = dsRecord + if err != nil { + diags.AddError("error generating ds record", err.Error()) + return zoneSigningKeys, keySigningKeys } - } - keys = append(keys, data) - } - } + ksk.DSRecord = types.StringValue(dsRecord) - return keys -} + obj, d := types.ObjectValueFrom(ctx, getDnsKeyAttrs(signingKey.Type), ksk) + diags.Append(d...) + if diags.HasError() { + return zoneSigningKeys, keySigningKeys + } + keySigningKeys = append(keySigningKeys, obj) + } else { + zsk := GoogleZoneSigningKey{ + Algorithm: types.StringValue(signingKey.Algorithm), + CreationTime: types.StringValue(signingKey.CreationTime), + Description: types.StringValue(signingKey.Description), + Id: types.StringValue(signingKey.Id), + IsActive: types.BoolValue(signingKey.IsActive), + KeyLength: types.Int64Value(signingKey.KeyLength), + KeyTag: types.Int64Value(signingKey.KeyTag), + PublicKey: types.StringValue(signingKey.PublicKey), + } -func flattenDigests(dnsKeyDigests []*dns.DnsKeyDigest) []map[string]interface{} { - var digests []map[string]interface{} + objType := types.ObjectType{}.WithAttributeTypes(digestAttrTypes) + zsk.Digests, d = types.ListValueFrom(ctx, objType, digests) + diags.Append(d...) + if diags.HasError() { + return zoneSigningKeys, keySigningKeys + } - for _, dnsKeyDigest := range dnsKeyDigests { - if dnsKeyDigest != nil { - data := map[string]interface{}{ - "digest": dnsKeyDigest.Digest, - "type": dnsKeyDigest.Type, + obj, d := types.ObjectValueFrom(ctx, getDnsKeyAttrs("zoneSigning"), zsk) + diags.Append(d...) + if diags.HasError() { + return zoneSigningKeys, keySigningKeys + } + zoneSigningKeys = append(zoneSigningKeys, obj) } - digests = append(digests, data) } } - return digests + return zoneSigningKeys, keySigningKeys } -func dataSourceDNSKeysRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } +// DNSSEC Algorithm Numbers: https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml +// The following are algorithms that are supported by Cloud DNS +var dnssecAlgoNums = map[string]int{ + "rsasha1": 5, + "rsasha256": 8, + "rsasha512": 10, + "ecdsap256sha256": 13, + "ecdsap384sha384": 14, +} - fv, err := tpgresource.ParseProjectFieldValue("managedZones", d.Get("managed_zone").(string), "project", d, config, false) - if err != nil { - return err - } - project := fv.Project - managedZone := fv.Name +// DS RR Digest Types: https://www.iana.org/assignments/ds-rr-types/ds-rr-types.xhtml +// The following are digests that are supported by Cloud DNS +var dnssecDigestType = map[string]int{ + "sha1": 1, + "sha256": 2, + "sha384": 4, +} - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error setting project: %s", err) +// generateDSRecord will generate the ds_record on key signing keys +func generateDSRecord(signingKey *dns.DnsKey) (string, error) { + algoNum, found := dnssecAlgoNums[signingKey.Algorithm] + if !found { + return "", fmt.Errorf("DNSSEC Algorithm number for %s not found", signingKey.Algorithm) } - d.SetId(fmt.Sprintf("projects/%s/managedZones/%s", project, managedZone)) - - log.Printf("[DEBUG] Fetching DNS keys from managed zone %s", managedZone) - response, err := config.NewDnsClient(userAgent).DnsKeys.List(project, managedZone).Do() - if err != nil && !transport_tpg.IsGoogleApiErrorWithCode(err, 404) { - return fmt.Errorf("error retrieving DNS keys: %s", err) - } else if transport_tpg.IsGoogleApiErrorWithCode(err, 404) { - return nil + digestType, found := dnssecDigestType[signingKey.Digests[0].Type] + if !found { + return "", fmt.Errorf("DNSSEC Digest type for %s not found", signingKey.Digests[0].Type) } - log.Printf("[DEBUG] Fetched DNS keys from managed zone %s", managedZone) + return fmt.Sprintf("%d %d %d %s", + signingKey.KeyTag, + algoNum, + digestType, + signingKey.Digests[0].Digest), nil +} - if err := d.Set("key_signing_keys", flattenSigningKeys(response.DnsKeys, "keySigning")); err != nil { - return fmt.Errorf("Error setting key_signing_keys: %s", err) +func getDnsKeyAttrs(keyType string) map[string]attr.Type { + dnsKeyAttrs := map[string]attr.Type{ + "algorithm": types.StringType, + "creation_time": types.StringType, + "description": types.StringType, + "id": types.StringType, + "is_active": types.BoolType, + "key_length": types.Int64Type, + "key_tag": types.Int64Type, + "public_key": types.StringType, + "digests": types.ListType{}.WithElementType(types.ObjectType{}.WithAttributeTypes(digestAttrTypes)), } - if err := d.Set("zone_signing_keys", flattenSigningKeys(response.DnsKeys, "zoneSigning")); err != nil { - return fmt.Errorf("Error setting zone_signing_keys: %s", err) + + if keyType == "keySigning" { + dnsKeyAttrs["ds_record"] = types.StringType } - return nil + return dnsKeyAttrs } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zone.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zone.go index c7893b0c698..0febdc9d1e6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zone.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zone.go @@ -3,107 +3,198 @@ package dns import ( + "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "google.golang.org/api/dns/v1" + + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + + "github.com/hashicorp/terraform-provider-google/google/fwmodels" + "github.com/hashicorp/terraform-provider-google/google/fwresource" + "github.com/hashicorp/terraform-provider-google/google/fwtransport" ) -func DataSourceDnsManagedZone() *schema.Resource { - return &schema.Resource{ - Read: dataSourceDnsManagedZoneRead, +// Ensure the implementation satisfies the expected interfaces +var ( + _ datasource.DataSource = &GoogleDnsManagedZoneDataSource{} + _ datasource.DataSourceWithConfigure = &GoogleDnsManagedZoneDataSource{} +) - Schema: map[string]*schema.Schema{ - "dns_name": { - Type: schema.TypeString, - Computed: true, - }, +func NewGoogleDnsManagedZoneDataSource() datasource.DataSource { + return &GoogleDnsManagedZoneDataSource{} +} + +// GoogleDnsManagedZoneDataSource defines the data source implementation +type GoogleDnsManagedZoneDataSource struct { + client *dns.Service + project types.String +} + +type GoogleDnsManagedZoneModel struct { + Id types.String `tfsdk:"id"` + DnsName types.String `tfsdk:"dns_name"` + Name types.String `tfsdk:"name"` + Description types.String `tfsdk:"description"` + ManagedZoneId types.Int64 `tfsdk:"managed_zone_id"` + NameServers types.List `tfsdk:"name_servers"` + Visibility types.String `tfsdk:"visibility"` + Project types.String `tfsdk:"project"` +} - "name": { - Type: schema.TypeString, - Required: true, +func (d *GoogleDnsManagedZoneDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_dns_managed_zone" +} + +func (d *GoogleDnsManagedZoneDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "Provides access to a zone's attributes within Google Cloud DNS", + + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Description: "A unique name for the resource.", + MarkdownDescription: "A unique name for the resource.", + Required: true, }, - "description": { - Type: schema.TypeString, - Computed: true, + // Google Cloud DNS ManagedZone resources do not have a SelfLink attribute. + "project": schema.StringAttribute{ + Description: "The ID of the project for the Google Cloud.", + MarkdownDescription: "The ID of the project for the Google Cloud.", + Optional: true, }, - "managed_zone_id": { - Type: schema.TypeInt, - Computed: true, + "dns_name": schema.StringAttribute{ + Description: "The fully qualified DNS name of this zone.", + MarkdownDescription: "The fully qualified DNS name of this zone.", + Computed: true, }, - "name_servers": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, + "description": schema.StringAttribute{ + Description: "A textual description field.", + MarkdownDescription: "A textual description field.", + Computed: true, }, - "visibility": { - Type: schema.TypeString, - Computed: true, + "managed_zone_id": schema.Int64Attribute{ + Description: "Unique identifier for the resource; defined by the server.", + MarkdownDescription: "Unique identifier for the resource; defined by the server.", + Computed: true, }, - // Google Cloud DNS ManagedZone resources do not have a SelfLink attribute. - "project": { - Type: schema.TypeString, - Optional: true, + "name_servers": schema.ListAttribute{ + Description: "The list of nameservers that will be authoritative for this " + + "domain. Use NS records to redirect from your DNS provider to these names, " + + "thus making Google Cloud DNS authoritative for this zone.", + MarkdownDescription: "The list of nameservers that will be authoritative for this " + + "domain. Use NS records to redirect from your DNS provider to these names, " + + "thus making Google Cloud DNS authoritative for this zone.", + Computed: true, + ElementType: types.StringType, }, - "id": { - Type: schema.TypeString, + "visibility": schema.StringAttribute{ + Description: "The zone's visibility: public zones are exposed to the Internet, " + + "while private zones are visible only to Virtual Private Cloud resources.", + MarkdownDescription: "The zone's visibility: public zones are exposed to the Internet, " + + "while private zones are visible only to Virtual Private Cloud resources.", Computed: true, }, + + "id": schema.StringAttribute{ + Description: "DNS managed zone identifier", + MarkdownDescription: "DNS managed zone identifier", + Computed: true, + }, }, } } -func dataSourceDnsManagedZoneRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err +func (d *GoogleDnsManagedZoneDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return } - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err + p, ok := req.ProviderData.(*fwtransport.FrameworkProviderConfig) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *fwtransport.FrameworkProviderConfig, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return } - name := d.Get("name").(string) - d.SetId(fmt.Sprintf("projects/%s/managedZones/%s", project, name)) + d.client = p.NewDnsClient(p.UserAgent, &resp.Diagnostics) + d.project = p.Project +} - zone, err := config.NewDnsClient(userAgent).ManagedZones.Get( - project, name).Do() - if err != nil { - return err - } +func (d *GoogleDnsManagedZoneDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data GoogleDnsManagedZoneModel + var metaData *fwmodels.ProviderMetaModel + var diags diag.Diagnostics - if err := d.Set("name_servers", zone.NameServers); err != nil { - return fmt.Errorf("Error setting name_servers: %s", err) + // Read Provider meta into the meta model + resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &metaData)...) + if resp.Diagnostics.HasError() { + return } - if err := d.Set("name", zone.Name); err != nil { - return fmt.Errorf("Error setting name: %s", err) - } - if err := d.Set("dns_name", zone.DnsName); err != nil { - return fmt.Errorf("Error setting dns_name: %s", err) + + d.client.UserAgent = fwtransport.GenerateFrameworkUserAgentString(metaData, d.client.UserAgent) + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return } - if err := d.Set("managed_zone_id", zone.Id); err != nil { - return fmt.Errorf("Error setting managed_zone_id: %s", err) + + data.Project = fwresource.GetProjectFramework(data.Project, d.project, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return } - if err := d.Set("description", zone.Description); err != nil { - return fmt.Errorf("Error setting description: %s", err) + + data.Id = types.StringValue(fmt.Sprintf("projects/%s/managedZones/%s", data.Project.ValueString(), data.Name.ValueString())) + clientResp, err := d.client.ManagedZones.Get(data.Project.ValueString(), data.Name.ValueString()).Do() + if err != nil { + fwtransport.HandleDatasourceNotFoundError(ctx, err, &resp.State, fmt.Sprintf("dataSourceDnsManagedZone %q", data.Name.ValueString()), &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } } - if err := d.Set("visibility", zone.Visibility); err != nil { - return fmt.Errorf("Error setting visibility: %s", err) + + tflog.Trace(ctx, "read dns managed zone data source") + + data.DnsName = types.StringValue(clientResp.DnsName) + data.Description = types.StringValue(clientResp.Description) + data.ManagedZoneId = types.Int64Value(int64(clientResp.Id)) + data.Visibility = types.StringValue(clientResp.Visibility) + data.NameServers, diags = types.ListValueFrom(ctx, types.StringType, clientResp.NameServers) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return } - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error setting project: %s", err) + + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} + +func getDnsManagedZoneAttrs() map[string]attr.Type { + dnsManagedZoneAttrs := map[string]attr.Type{ + "name": types.StringType, + "project": types.StringType, + "dns_name": types.StringType, + "description": types.StringType, + "managed_zone_id": types.Int64Type, + "name_servers": types.ListType{}.WithElementType(types.StringType), + "visibility": types.StringType, + "id": types.StringType, } - return nil + return dnsManagedZoneAttrs } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zones.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zones.go index ff0900887f8..d3acb594e88 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zones.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_managed_zones.go @@ -3,95 +3,242 @@ package dns import ( + "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" "google.golang.org/api/dns/v1" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + + "github.com/hashicorp/terraform-provider-google/google/fwmodels" + "github.com/hashicorp/terraform-provider-google/google/fwresource" + "github.com/hashicorp/terraform-provider-google/google/fwtransport" ) -func DataSourceDnsManagedZones() *schema.Resource { +// Ensure the implementation satisfies the expected interfaces +var ( + _ datasource.DataSource = &GoogleDnsManagedZonesDataSource{} + _ datasource.DataSourceWithConfigure = &GoogleDnsManagedZonesDataSource{} +) + +func NewGoogleDnsManagedZonesDataSource() datasource.DataSource { + return &GoogleDnsManagedZonesDataSource{} +} + +// GoogleDnsManagedZonesDataSource defines the data source implementation +type GoogleDnsManagedZonesDataSource struct { + client *dns.Service + project types.String +} - mzSchema := DataSourceDnsManagedZone().Schema - tpgresource.AddOptionalFieldsToSchema(mzSchema, "name") +type GoogleDnsManagedZonesModel struct { + Id types.String `tfsdk:"id"` + Project types.String `tfsdk:"project"` + ManagedZones types.List `tfsdk:"managed_zones"` +} + +func (d *GoogleDnsManagedZonesDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_dns_managed_zones" +} - return &schema.Resource{ - Read: dataSourceDnsManagedZonesRead, +func (d *GoogleDnsManagedZonesDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "Provides access to all zones for a given project within Google Cloud DNS", + + Attributes: map[string]schema.Attribute{ + + "project": schema.StringAttribute{ + Description: "The ID of the project for the Google Cloud.", + MarkdownDescription: "The ID of the project for the Google Cloud.", + Optional: true, }, - "managed_zones": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: mzSchema, - }, + // Id field is added to match plugin-framework migrated google_dns_managed_zone data source + // Whilst ID fields are required in the SDK, they're not needed in the plugin-framework. + "id": schema.StringAttribute{ + Description: "foobar", + MarkdownDescription: "foobar", + Computed: true, }, + }, - // Google Cloud DNS ManagedZone resources do not have a SelfLink attribute. - "project": { - Type: schema.TypeString, - Optional: true, + Blocks: map[string]schema.Block{ + "managed_zones": schema.ListNestedBlock{ + Description: "The list of managed zones in the given project.", + MarkdownDescription: "The list of managed zones in the given project.", + NestedObject: schema.NestedBlockObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + Description: "A unique name for the resource.", + MarkdownDescription: "A unique name for the resource.", + Computed: true, + }, + + // Google Cloud DNS ManagedZone resources do not have a SelfLink attribute. + "project": schema.StringAttribute{ + Description: "The ID of the project for the Google Cloud.", + MarkdownDescription: "The ID of the project for the Google Cloud.", + Computed: true, + }, + + "dns_name": schema.StringAttribute{ + Description: "The fully qualified DNS name of this zone.", + MarkdownDescription: "The fully qualified DNS name of this zone.", + Computed: true, + }, + + "description": schema.StringAttribute{ + Description: "A textual description field.", + MarkdownDescription: "A textual description field.", + Computed: true, + }, + + "managed_zone_id": schema.Int64Attribute{ + Description: "Unique identifier for the resource; defined by the server.", + MarkdownDescription: "Unique identifier for the resource; defined by the server.", + Computed: true, + }, + + "name_servers": schema.ListAttribute{ + Description: "The list of nameservers that will be authoritative for this " + + "domain. Use NS records to redirect from your DNS provider to these names, " + + "thus making Google Cloud DNS authoritative for this zone.", + MarkdownDescription: "The list of nameservers that will be authoritative for this " + + "domain. Use NS records to redirect from your DNS provider to these names, " + + "thus making Google Cloud DNS authoritative for this zone.", + Computed: true, + ElementType: types.StringType, + }, + + "visibility": schema.StringAttribute{ + Description: "The zone's visibility: public zones are exposed to the Internet, " + + "while private zones are visible only to Virtual Private Cloud resources.", + MarkdownDescription: "The zone's visibility: public zones are exposed to the Internet, " + + "while private zones are visible only to Virtual Private Cloud resources.", + Computed: true, + }, + + "id": schema.StringAttribute{ + Description: "DNS managed zone identifier", + MarkdownDescription: "DNS managed zone identifier", + Computed: true, + }, + }, + }, }, }, } } -func dataSourceDnsManagedZonesRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err +func (d *GoogleDnsManagedZonesDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return } - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err + p, ok := req.ProviderData.(*fwtransport.FrameworkProviderConfig) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *fwtransport.FrameworkProviderConfig, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return + } + + d.client = p.NewDnsClient(p.UserAgent, &resp.Diagnostics) + d.project = p.Project +} + +func (d *GoogleDnsManagedZonesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data GoogleDnsManagedZonesModel + var metaData *fwmodels.ProviderMetaModel + var diags diag.Diagnostics + + // Read Provider meta into the meta model + resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &metaData)...) + if resp.Diagnostics.HasError() { + return + } + + d.client.UserAgent = fwtransport.GenerateFrameworkUserAgentString(metaData, d.client.UserAgent) + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return + } + + data.Project = fwresource.GetProjectFramework(data.Project, d.project, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return } - d.SetId(fmt.Sprintf("projects/%s/managedZones", project)) + data.Id = types.StringValue(fmt.Sprintf("projects/%s/managedZones", data.Project.ValueString())) - zones, err := config.NewDnsClient(userAgent).ManagedZones.List(project).Do() + tflog.Debug(ctx, fmt.Sprintf("fetching managed zones from project %s", data.Project.ValueString())) + + clientResp, err := d.client.ManagedZones.List(data.Project.ValueString()).Do() if err != nil { - return err + fwtransport.HandleDatasourceNotFoundError(ctx, err, &resp.State, fmt.Sprintf("dataSourceDnsManagedZones %q", data.Project.ValueString()), &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } } - if err := d.Set("managed_zones", flattenZones(zones.ManagedZones, project)); err != nil { - return fmt.Errorf("error setting managed_zones: %s", err) + tflog.Trace(ctx, "read dns managed zones data source") + + zones, di := flattenManagedZones(ctx, clientResp.ManagedZones, data.Project.ValueString()) + diags.Append(di...) + + if len(zones) > 0 { + mzObjType := types.ObjectType{}.WithAttributeTypes(getDnsManagedZoneAttrs()) + data.ManagedZones, di = types.ListValueFrom(ctx, mzObjType, zones) + diags.Append(di...) } - if err := d.Set("project", project); err != nil { - return fmt.Errorf("error setting project: %s", err) + + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return } - return nil + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -// flattenZones flattens the list of managed zones into a format that can be assigned to the managed_zones field -// on the plural datasource. This includes setting the project value for each item, as this isn't returned by the API. -func flattenZones(items []*dns.ManagedZone, project string) []map[string]interface{} { - var zones []map[string]interface{} - - for _, item := range items { - if item != nil { - data := map[string]interface{}{ - "id": fmt.Sprintf("projects/%s/managedZones/%s", project, item.Name), // Matches construction in singlur data source - "dns_name": item.DnsName, - "name": item.Name, - "managed_zone_id": item.Id, - "description": item.Description, - "visibility": item.Visibility, - "name_servers": item.NameServers, - "project": project, - } - - zones = append(zones, data) +func flattenManagedZones(ctx context.Context, managedZones []*dns.ManagedZone, project string) ([]types.Object, diag.Diagnostics) { + var zones []types.Object + var diags diag.Diagnostics + + for _, zone := range managedZones { + + data := GoogleDnsManagedZoneModel{ + // Id is not an API value but we assemble it here to match the google_dns_managed_zone data source + // and fulfil the GoogleDnsManagedZoneModel's fields. + // IDs are not required in the plugin-framework (vs the SDK) + Id: types.StringValue(fmt.Sprintf("projects/%s/managedZones/%s", project, zone.Name)), + Project: types.StringValue(project), + + DnsName: types.StringValue(zone.DnsName), + Name: types.StringValue(zone.Name), + Description: types.StringValue(zone.Description), + ManagedZoneId: types.Int64Value(int64(zone.Id)), + Visibility: types.StringValue(zone.Visibility), } + + data.NameServers, diags = types.ListValueFrom(ctx, types.StringType, zone.NameServers) + diags.Append(diags...) + + obj, d := types.ObjectValueFrom(ctx, getDnsManagedZoneAttrs(), data) + diags.Append(d...) + + zones = append(zones, obj) } - return zones + return zones, diags } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_record_set.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_record_set.go index 7804ba05978..469c43666ca 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_record_set.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/data_source_dns_record_set.go @@ -3,88 +3,155 @@ package dns import ( + "context" "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "google.golang.org/api/dns/v1" + + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/hashicorp/terraform-plugin-log/tflog" + "github.com/hashicorp/terraform-provider-google/google/fwmodels" + "github.com/hashicorp/terraform-provider-google/google/fwresource" + "github.com/hashicorp/terraform-provider-google/google/fwtransport" ) -func DataSourceDnsRecordSet() *schema.Resource { - return &schema.Resource{ - Read: dataSourceDnsRecordSetRead, +// Ensure the implementation satisfies the expected interfaces +var ( + _ datasource.DataSource = &GoogleDnsRecordSetDataSource{} + _ datasource.DataSourceWithConfigure = &GoogleDnsRecordSetDataSource{} +) - Schema: map[string]*schema.Schema{ - "managed_zone": { - Type: schema.TypeString, - Required: true, - }, +func NewGoogleDnsRecordSetDataSource() datasource.DataSource { + return &GoogleDnsRecordSetDataSource{} +} - "name": { - Type: schema.TypeString, - Required: true, - }, +// GoogleDnsRecordSetDataSource defines the data source implementation +type GoogleDnsRecordSetDataSource struct { + client *dns.Service + project types.String +} - "rrdatas": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, +type GoogleDnsRecordSetModel struct { + Id types.String `tfsdk:"id"` + ManagedZone types.String `tfsdk:"managed_zone"` + Name types.String `tfsdk:"name"` + Rrdatas types.List `tfsdk:"rrdatas"` + Ttl types.Int64 `tfsdk:"ttl"` + Type types.String `tfsdk:"type"` + Project types.String `tfsdk:"project"` +} - "ttl": { - Type: schema.TypeInt, - Computed: true, - }, +func (d *GoogleDnsRecordSetDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_dns_record_set" +} - "type": { - Type: schema.TypeString, - Required: true, - }, +func (d *GoogleDnsRecordSetDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + // This description is used by the documentation generator and the language server. + MarkdownDescription: "A DNS record set within Google Cloud DNS", - "project": { - Type: schema.TypeString, - Optional: true, + Attributes: map[string]schema.Attribute{ + "managed_zone": schema.StringAttribute{ + MarkdownDescription: "The Name of the zone.", + Required: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "The DNS name for the resource.", + Required: true, + }, + "type": schema.StringAttribute{ + MarkdownDescription: "The identifier of a supported record type. See the list of Supported DNS record types.", + Required: true, + }, + "project": schema.StringAttribute{ + MarkdownDescription: "The ID of the project for the Google Cloud.", + Optional: true, + }, + "rrdatas": schema.ListAttribute{ + MarkdownDescription: "The string data for the records in this record set.", + Computed: true, + ElementType: types.StringType, + }, + "ttl": schema.Int64Attribute{ + MarkdownDescription: "The time-to-live of this record set (seconds).", + Computed: true, + }, + "id": schema.StringAttribute{ + MarkdownDescription: "DNS record set identifier", + Computed: true, }, }, } } -func dataSourceDnsRecordSetRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err +func (d *GoogleDnsRecordSetDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return } - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err + p, ok := req.ProviderData.(*fwtransport.FrameworkProviderConfig) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *fwtransport.FrameworkProviderConfig, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return } - zone := d.Get("managed_zone").(string) - name := d.Get("name").(string) - dnsType := d.Get("type").(string) - d.SetId(fmt.Sprintf("projects/%s/managedZones/%s/rrsets/%s/%s", project, zone, name, dnsType)) + d.client = p.NewDnsClient(p.UserAgent, &resp.Diagnostics) + d.project = p.Project +} - resp, err := config.NewDnsClient(userAgent).ResourceRecordSets.List(project, zone).Name(name).Type(dnsType).Do() - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("dataSourceDnsRecordSet %q", name)) +func (d *GoogleDnsRecordSetDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data GoogleDnsRecordSetModel + var metaData *fwmodels.ProviderMetaModel + var diags diag.Diagnostics + + // Read Provider meta into the meta model + resp.Diagnostics.Append(req.ProviderMeta.Get(ctx, &metaData)...) + if resp.Diagnostics.HasError() { + return } - if len(resp.Rrsets) != 1 { - return fmt.Errorf("Only expected 1 record set, got %d", len(resp.Rrsets)) + + d.client.UserAgent = fwtransport.GenerateFrameworkUserAgentString(metaData, d.client.UserAgent) + + // Read Terraform configuration data into the model + resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) + if resp.Diagnostics.HasError() { + return } - if err := d.Set("rrdatas", resp.Rrsets[0].Rrdatas); err != nil { - return fmt.Errorf("Error setting rrdatas: %s", err) + data.Project = fwresource.GetProjectFramework(data.Project, d.project, &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return } - if err := d.Set("ttl", resp.Rrsets[0].Ttl); err != nil { - return fmt.Errorf("Error setting ttl: %s", err) + + data.Id = types.StringValue(fmt.Sprintf("projects/%s/managedZones/%s/rrsets/%s/%s", data.Project.ValueString(), data.ManagedZone.ValueString(), data.Name.ValueString(), data.Type.ValueString())) + clientResp, err := d.client.ResourceRecordSets.List(data.Project.ValueString(), data.ManagedZone.ValueString()).Name(data.Name.ValueString()).Type(data.Type.ValueString()).Do() + if err != nil { + fwtransport.HandleDatasourceNotFoundError(ctx, err, &resp.State, fmt.Sprintf("dataSourceDnsRecordSet %q", data.Name.ValueString()), &resp.Diagnostics) + if resp.Diagnostics.HasError() { + return + } } - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error setting project: %s", err) + if len(clientResp.Rrsets) != 1 { + resp.Diagnostics.AddError("only expected 1 record set", fmt.Sprintf("%d record sets were returned", len(clientResp.Rrsets))) + } + + tflog.Trace(ctx, "read dns record set data source") + + data.Type = types.StringValue(clientResp.Rrsets[0].Type) + data.Ttl = types.Int64Value(clientResp.Rrsets[0].Ttl) + data.Rrdatas, diags = types.ListValueFrom(ctx, types.StringType, clientResp.Rrsets[0].Rrdatas) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return } - return nil + // Save data into Terraform state + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/dns_change.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/dns_change.go index 28dfceb8a72..37c7a3a6548 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/dns_change.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/dns_change.go @@ -7,7 +7,7 @@ import ( "google.golang.org/api/dns/v1" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) type DnsChangeWaiter struct { @@ -17,7 +17,7 @@ type DnsChangeWaiter struct { ManagedZone string } -func (w *DnsChangeWaiter) RefreshFunc() retry.StateRefreshFunc { +func (w *DnsChangeWaiter) RefreshFunc() resource.StateRefreshFunc { return func() (interface{}, string, error) { var chg *dns.Change var err error @@ -33,8 +33,8 @@ func (w *DnsChangeWaiter) RefreshFunc() retry.StateRefreshFunc { } } -func (w *DnsChangeWaiter) Conf() *retry.StateChangeConf { - return &retry.StateChangeConf{ +func (w *DnsChangeWaiter) Conf() *resource.StateChangeConf { + return &resource.StateChangeConf{ Pending: []string{"pending"}, Target: []string{"done"}, Refresh: w.RefreshFunc(), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_managed_zone.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_managed_zone.go index 4e484c83fb3..b939d9ce3bf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_managed_zone.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_managed_zone.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -471,7 +470,6 @@ func resourceDNSManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -480,7 +478,6 @@ func resourceDNSManagedZoneCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ManagedZone: %s", err) @@ -523,14 +520,12 @@ func resourceDNSManagedZoneRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DNSManagedZone %q", d.Id())) @@ -683,7 +678,6 @@ func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating ManagedZone %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -698,7 +692,6 @@ func resourceDNSManagedZoneUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -737,7 +730,6 @@ func resourceDNSManagedZoneDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) if d.Get("force_destroy").(bool) { zone := d.Get("name").(string) token := "" @@ -818,7 +810,6 @@ func resourceDNSManagedZoneDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ManagedZone") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_policy.go index 0af25877323..b51ca3658e8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_policy.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -236,7 +235,6 @@ func resourceDNSPolicyCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -245,7 +243,6 @@ func resourceDNSPolicyCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Policy: %s", err) @@ -288,14 +285,12 @@ func resourceDNSPolicyRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DNSPolicy %q", d.Id())) @@ -383,8 +378,6 @@ func resourceDNSPolicyUpdate(d *schema.ResourceData, meta interface{}) error { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -398,7 +391,6 @@ func resourceDNSPolicyUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Policy %q: %s", d.Id(), err) @@ -440,7 +432,6 @@ func resourceDNSPolicyDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) // if networks are attached, they need to be detached before the policy can be deleted if d.Get("networks.#").(int) > 0 { patched := make(map[string]interface{}) @@ -474,7 +465,6 @@ func resourceDNSPolicyDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Policy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_record_set.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_record_set.go index 0f81ac4ad1c..c91d1dcffed 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_record_set.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_record_set.go @@ -169,7 +169,7 @@ func ResourceDnsRecordSet() *schema.Resource { "primary_backup": { Type: schema.TypeList, Optional: true, - Description: "The configuration for a failover policy with global to regional failover. Queries are responded to with the global primary targets, but if none of the primary targets are healthy, then we fallback to a regional failover policy.", + Description: "The configuration for a primary-backup policy with global to regional failover. Queries are responded to with the global primary targets, but if none of the primary targets are healthy, then we fallback to a regional failover policy.", MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -459,17 +459,14 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error zone := d.Get("managed_zone").(string) - // NS and SOA records on the root zone must always have a value, - // so we short-circuit delete this allows terraform delete to work, - // but may have unexpected side-effects when deleting just that - // record set. + // NS records must always have a value, so we short-circuit delete + // this allows terraform delete to work, but may have unexpected + // side-effects when deleting just that record set. // Unfortunately, you can set NS records on subdomains, and those // CAN and MUST be deleted, so we need to retrieve the managed zone, // check if what we're looking at is a subdomain, and only not delete // if it's not actually a subdomain - // This does not apply to SOA, as they can only be set on the root - // zone. - if d.Get("type").(string) == "NS" || d.Get("type").(string) == "SOA" { + if d.Get("type").(string) == "NS" { mz, err := config.NewDnsClient(userAgent).ManagedZones.Get(project, zone).Do() if err != nil { return fmt.Errorf("Error retrieving managed zone %q from %q: %s", zone, project, err) @@ -477,7 +474,7 @@ func resourceDnsRecordSetDelete(d *schema.ResourceData, meta interface{}) error domain := mz.DnsName if domain == d.Get("name").(string) { - log.Printf("[DEBUG] root-level %s records can't be deleted due to API restrictions, so they're being left in place. See https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_record_set for more information.\n", d.Get("type").(string)) + log.Println("[DEBUG] NS records can't be deleted due to API restrictions, so they're being left in place. See https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/dns_record_set for more information.") return nil } } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy.go index f5e647ec682..74ac89559cc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy.go @@ -20,7 +20,6 @@ package dns import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -162,7 +161,6 @@ func resourceDNSResponsePolicyCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -171,7 +169,6 @@ func resourceDNSResponsePolicyCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ResponsePolicy: %s", err) @@ -214,14 +211,12 @@ func resourceDNSResponsePolicyRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DNSResponsePolicy %q", d.Id())) @@ -288,7 +283,6 @@ func resourceDNSResponsePolicyUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating ResponsePolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -303,7 +297,6 @@ func resourceDNSResponsePolicyUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -342,7 +335,6 @@ func resourceDNSResponsePolicyDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) // if gke clusters are attached, they need to be detached before the response policy can be deleted if d.Get("gke_clusters.#").(int) > 0 { patched := make(map[string]interface{}) @@ -400,7 +392,6 @@ func resourceDNSResponsePolicyDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ResponsePolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy_rule.go index 355c5ee9bb7..0a019bad041 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/dns/resource_dns_response_policy_rule.go @@ -20,7 +20,6 @@ package dns import ( "fmt" "log" - "net/http" "reflect" "time" @@ -174,7 +173,6 @@ func resourceDNSResponsePolicyRuleCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -183,7 +181,6 @@ func resourceDNSResponsePolicyRuleCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ResponsePolicyRule: %s", err) @@ -226,14 +223,12 @@ func resourceDNSResponsePolicyRuleRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DNSResponsePolicyRule %q", d.Id())) @@ -291,7 +286,6 @@ func resourceDNSResponsePolicyRuleUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating ResponsePolicyRule %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -306,7 +300,6 @@ func resourceDNSResponsePolicyRuleUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -345,8 +338,6 @@ func resourceDNSResponsePolicyRuleDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ResponsePolicyRule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -356,7 +347,6 @@ func resourceDNSResponsePolicyRuleDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ResponsePolicyRule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor.go index a5f4fbd8409..d70f4503d90 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor.go @@ -20,7 +20,6 @@ package documentai import ( "fmt" "log" - "net/http" "reflect" "time" @@ -137,7 +136,6 @@ func resourceDocumentAIProcessorCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -146,7 +144,6 @@ func resourceDocumentAIProcessorCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Processor: %s", err) @@ -192,14 +189,12 @@ func resourceDocumentAIProcessorRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DocumentAIProcessor %q", d.Id())) @@ -252,8 +247,6 @@ func resourceDocumentAIProcessorDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Processor %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -263,7 +256,6 @@ func resourceDocumentAIProcessorDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Processor") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor_default_version.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor_default_version.go index 080ef7cc0dd..8471de1eb20 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor_default_version.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentai/resource_document_ai_processor_default_version.go @@ -20,7 +20,6 @@ package documentai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -100,7 +99,6 @@ func resourceDocumentAIProcessorDefaultVersionCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) if strings.Contains(url, "https://-") { location := tpgresource.GetRegionFromRegionalSelfLink(url) url = strings.TrimPrefix(url, "https://") @@ -114,7 +112,6 @@ func resourceDocumentAIProcessorDefaultVersionCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ProcessorDefaultVersion: %s", err) @@ -151,7 +148,6 @@ func resourceDocumentAIProcessorDefaultVersionRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) if strings.Contains(url, "https://-") { location := tpgresource.GetRegionFromRegionalSelfLink(url) url = strings.TrimPrefix(url, "https://") @@ -163,7 +159,6 @@ func resourceDocumentAIProcessorDefaultVersionRead(d *schema.ResourceData, meta Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DocumentAIProcessorDefaultVersion %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go index 050214dcc68..f319bbd4053 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_document_schema.go @@ -20,7 +20,6 @@ package documentaiwarehouse import ( "fmt" "log" - "net/http" "reflect" "time" @@ -466,7 +465,6 @@ func resourceDocumentAIWarehouseDocumentSchemaCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -475,7 +473,6 @@ func resourceDocumentAIWarehouseDocumentSchemaCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DocumentSchema: %s", err) @@ -515,14 +512,12 @@ func resourceDocumentAIWarehouseDocumentSchemaRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("DocumentAIWarehouseDocumentSchema %q", d.Id())) @@ -565,8 +560,6 @@ func resourceDocumentAIWarehouseDocumentSchemaDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DocumentSchema %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -576,7 +569,6 @@ func resourceDocumentAIWarehouseDocumentSchemaDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DocumentSchema") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_location.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_location.go index fe4caf98013..836e117fecb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_location.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/documentaiwarehouse/resource_document_ai_warehouse_location.go @@ -20,7 +20,6 @@ package documentaiwarehouse import ( "fmt" "log" - "net/http" "reflect" "time" @@ -137,7 +136,6 @@ func resourceDocumentAIWarehouseLocationCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -146,7 +144,6 @@ func resourceDocumentAIWarehouseLocationCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Location: %s", err) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_cluster.go index cb39e346dd0..24542291d30 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_cluster.go @@ -20,7 +20,6 @@ package edgecontainer import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -405,47 +404,6 @@ start time.`, }, }, }, - "maintenance_exclusions": { - Type: schema.TypeList, - Optional: true, - Description: `Exclusions to automatic maintenance. Non-emergency maintenance should not occur -in these windows. Each exclusion has a unique name and may be active or expired. -The max number of maintenance exclusions allowed at a given time is 3.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `A unique (per cluster) id for the window.`, - }, - "window": { - Type: schema.TypeList, - Computed: true, - Optional: true, - Description: `Represents an arbitrary window of time.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "end_time": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The time that the window ends. The end time must take place after the -start time.`, - }, - "start_time": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The time that the window first starts.`, - }, - }, - }, - }, - }, - }, - }, }, }, }, @@ -729,7 +687,6 @@ func resourceEdgecontainerClusterCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -738,7 +695,6 @@ func resourceEdgecontainerClusterCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Cluster: %s", err) @@ -791,14 +747,12 @@ func resourceEdgecontainerClusterRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("EdgecontainerCluster %q", d.Id())) @@ -958,7 +912,6 @@ func resourceEdgecontainerClusterUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Cluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("networking") { @@ -1018,7 +971,6 @@ func resourceEdgecontainerClusterUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1052,8 +1004,6 @@ func resourceEdgecontainerClusterUpdate(d *schema.ResourceData, meta interface{} return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1067,7 +1017,6 @@ func resourceEdgecontainerClusterUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Cluster %q: %s", d.Id(), err) @@ -1115,8 +1064,6 @@ func resourceEdgecontainerClusterDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Cluster %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1126,7 +1073,6 @@ func resourceEdgecontainerClusterDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Cluster") @@ -1334,8 +1280,6 @@ func flattenEdgecontainerClusterMaintenancePolicy(v interface{}, d *schema.Resou transformed := make(map[string]interface{}) transformed["window"] = flattenEdgecontainerClusterMaintenancePolicyWindow(original["window"], d, config) - transformed["maintenance_exclusions"] = - flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusions(original["maintenanceExclusions"], d, config) return []interface{}{transformed} } func flattenEdgecontainerClusterMaintenancePolicyWindow(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1393,52 +1337,6 @@ func flattenEdgecontainerClusterMaintenancePolicyWindowRecurringWindowRecurrence return v } -func flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "window": flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindow(original["window"], d, config), - "id": flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsId(original["id"], d, config), - }) - } - return transformed -} -func flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindow(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["start_time"] = - flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowStartTime(original["startTime"], d, config) - transformed["end_time"] = - flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowEndTime(original["endTime"], d, config) - return []interface{}{transformed} -} -func flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowStartTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowEndTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenEdgecontainerClusterControlPlaneVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1895,13 +1793,6 @@ func expandEdgecontainerClusterMaintenancePolicy(v interface{}, d tpgresource.Te transformed["window"] = transformedWindow } - transformedMaintenanceExclusions, err := expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusions(original["maintenance_exclusions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMaintenanceExclusions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["maintenanceExclusions"] = transformedMaintenanceExclusions - } - return transformed, nil } @@ -1988,73 +1879,6 @@ func expandEdgecontainerClusterMaintenancePolicyWindowRecurringWindowRecurrence( return v, nil } -func expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedWindow, err := expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindow(original["window"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedWindow); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["window"] = transformedWindow - } - - transformedId, err := expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsId(original["id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["id"] = transformedId - } - - req = append(req, transformed) - } - return req, nil -} - -func expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindow(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedStartTime, err := expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowStartTime(original["start_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStartTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["startTime"] = transformedStartTime - } - - transformedEndTime, err := expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowEndTime(original["end_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEndTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["endTime"] = transformedEndTime - } - - return transformed, nil -} - -func expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowStartTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsWindowEndTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandEdgecontainerClusterMaintenancePolicyMaintenanceExclusionsId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandEdgecontainerClusterControlPlane(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_node_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_node_pool.go index f78cf25800e..7137b1d3080 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_node_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_node_pool.go @@ -20,7 +20,6 @@ package edgecontainer import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -250,7 +249,6 @@ func resourceEdgecontainerNodePoolCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -259,7 +257,6 @@ func resourceEdgecontainerNodePoolCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NodePool: %s", err) @@ -312,14 +309,12 @@ func resourceEdgecontainerNodePoolRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("EdgecontainerNodePool %q", d.Id())) @@ -419,7 +414,6 @@ func resourceEdgecontainerNodePoolUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating NodePool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("node_count") { @@ -463,7 +457,6 @@ func resourceEdgecontainerNodePoolUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -511,8 +504,6 @@ func resourceEdgecontainerNodePoolDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NodePool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -522,7 +513,6 @@ func resourceEdgecontainerNodePoolDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NodePool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go index 2803ffc8e55..a3bfff2a749 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgecontainer/resource_edgecontainer_vpn_connection.go @@ -20,7 +20,6 @@ package edgecontainer import ( "fmt" "log" - "net/http" "reflect" "time" @@ -274,7 +273,6 @@ func resourceEdgecontainerVpnConnectionCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -283,7 +281,6 @@ func resourceEdgecontainerVpnConnectionCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VpnConnection: %s", err) @@ -336,14 +333,12 @@ func resourceEdgecontainerVpnConnectionRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("EdgecontainerVpnConnection %q", d.Id())) @@ -458,7 +453,6 @@ func resourceEdgecontainerVpnConnectionUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating VpnConnection %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -473,7 +467,6 @@ func resourceEdgecontainerVpnConnectionUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -520,8 +513,6 @@ func resourceEdgecontainerVpnConnectionDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting VpnConnection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -531,7 +522,6 @@ func resourceEdgecontainerVpnConnectionDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VpnConnection") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_network.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_network.go index 195d72f2028..7f2bb8b7e93 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_network.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_network.go @@ -20,7 +20,6 @@ package edgenetwork import ( "fmt" "log" - "net/http" "reflect" "time" @@ -166,7 +165,6 @@ func resourceEdgenetworkNetworkCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -175,7 +173,6 @@ func resourceEdgenetworkNetworkCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Network: %s", err) @@ -228,14 +225,12 @@ func resourceEdgenetworkNetworkRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("EdgenetworkNetwork %q", d.Id())) @@ -294,8 +289,6 @@ func resourceEdgenetworkNetworkDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Network %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -305,7 +298,6 @@ func resourceEdgenetworkNetworkDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Network") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_subnet.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_subnet.go index d27fe211001..146a7e2ad9e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_subnet.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/edgenetwork/resource_edgenetwork_subnet.go @@ -20,7 +20,6 @@ package edgenetwork import ( "fmt" "log" - "net/http" "reflect" "time" @@ -215,7 +214,6 @@ func resourceEdgenetworkSubnetCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -224,7 +222,6 @@ func resourceEdgenetworkSubnetCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Subnet: %s", err) @@ -277,14 +274,12 @@ func resourceEdgenetworkSubnetRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("EdgenetworkSubnet %q", d.Id())) @@ -355,8 +350,6 @@ func resourceEdgenetworkSubnetDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Subnet %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -366,7 +359,6 @@ func resourceEdgenetworkSubnetDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Subnet") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/essentialcontacts/resource_essential_contacts_contact.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/essentialcontacts/resource_essential_contacts_contact.go index ddf55b54509..4f831a5c324 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/essentialcontacts/resource_essential_contacts_contact.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/essentialcontacts/resource_essential_contacts_contact.go @@ -20,7 +20,6 @@ package essentialcontacts import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -124,7 +123,6 @@ func resourceEssentialContactsContactCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -133,7 +131,6 @@ func resourceEssentialContactsContactCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Contact: %s", err) @@ -173,14 +170,12 @@ func resourceEssentialContactsContactRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("EssentialContactsContact %q", d.Id())) @@ -231,7 +226,6 @@ func resourceEssentialContactsContactUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating Contact %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_category_subscriptions") { @@ -263,7 +257,6 @@ func resourceEssentialContactsContactUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -298,8 +291,6 @@ func resourceEssentialContactsContactDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Contact %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -309,7 +300,6 @@ func resourceEssentialContactsContactDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Contact") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_backup.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_backup.go index 8272d88cd5e..800fd22deb6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_backup.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_backup.go @@ -20,7 +20,6 @@ package filestore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -218,7 +217,6 @@ func resourceFilestoreBackupCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -227,7 +225,6 @@ func resourceFilestoreBackupCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -291,14 +288,12 @@ func resourceFilestoreBackupRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -400,7 +395,6 @@ func resourceFilestoreBackupUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Backup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -436,7 +430,6 @@ func resourceFilestoreBackupUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -492,8 +485,6 @@ func resourceFilestoreBackupDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Backup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -503,7 +494,6 @@ func resourceFilestoreBackupDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_instance.go index ad045853f81..4342ef64c7c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_instance.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -354,7 +353,6 @@ func resourceFilestoreInstanceCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) if d.Get("location") == "" { zone, err := tpgresource.GetZone(d, config) if err != nil { @@ -380,7 +378,6 @@ func resourceFilestoreInstanceCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -444,14 +441,12 @@ func resourceFilestoreInstanceRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -537,7 +532,6 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -573,7 +567,6 @@ func resourceFilestoreInstanceUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -622,8 +615,6 @@ func resourceFilestoreInstanceDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -633,7 +624,6 @@ func resourceFilestoreInstanceDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_snapshot.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_snapshot.go index 7c4162de014..48c0a61a2d7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_snapshot.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/filestore/resource_filestore_snapshot.go @@ -20,7 +20,6 @@ package filestore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -181,7 +180,6 @@ func resourceFilestoreSnapshotCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -190,7 +188,6 @@ func resourceFilestoreSnapshotCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -254,14 +251,12 @@ func resourceFilestoreSnapshotRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -339,7 +334,6 @@ func resourceFilestoreSnapshotUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Snapshot %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -371,7 +365,6 @@ func resourceFilestoreSnapshotUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -427,8 +420,6 @@ func resourceFilestoreSnapshotDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Snapshot %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -438,7 +429,6 @@ func resourceFilestoreSnapshotDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go index 04e0c929ab9..23ff7f30c95 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_app_attest_config.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -120,7 +119,6 @@ func resourceFirebaseAppCheckAppAttestConfigCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -129,7 +127,6 @@ func resourceFirebaseAppCheckAppAttestConfigCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AppAttestConfig: %s", err) @@ -175,14 +172,12 @@ func resourceFirebaseAppCheckAppAttestConfigRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckAppAttestConfig %q", d.Id())) @@ -231,7 +226,6 @@ func resourceFirebaseAppCheckAppAttestConfigUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating AppAttestConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("token_ttl") { @@ -259,7 +253,6 @@ func resourceFirebaseAppCheckAppAttestConfigUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go index 57832964c67..5ef52c43b1c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_debug_token.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -138,7 +137,6 @@ func resourceFirebaseAppCheckDebugTokenCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -147,7 +145,6 @@ func resourceFirebaseAppCheckDebugTokenCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DebugToken: %s", err) @@ -193,14 +190,12 @@ func resourceFirebaseAppCheckDebugTokenRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckDebugToken %q", d.Id())) @@ -249,7 +244,6 @@ func resourceFirebaseAppCheckDebugTokenUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating DebugToken %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -277,7 +271,6 @@ func resourceFirebaseAppCheckDebugTokenUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -318,8 +311,6 @@ func resourceFirebaseAppCheckDebugTokenDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DebugToken %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -329,7 +320,6 @@ func resourceFirebaseAppCheckDebugTokenDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DebugToken") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go index 22f8ec3f536..1dd28b7b448 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_device_check_config.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -149,7 +148,6 @@ func resourceFirebaseAppCheckDeviceCheckConfigCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -158,7 +156,6 @@ func resourceFirebaseAppCheckDeviceCheckConfigCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DeviceCheckConfig: %s", err) @@ -204,14 +201,12 @@ func resourceFirebaseAppCheckDeviceCheckConfigRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckDeviceCheckConfig %q", d.Id())) @@ -278,7 +273,6 @@ func resourceFirebaseAppCheckDeviceCheckConfigUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating DeviceCheckConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("token_ttl") { @@ -314,7 +308,6 @@ func resourceFirebaseAppCheckDeviceCheckConfigUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go index aac90cb486d..5aeaf6427ff 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_play_integrity_config.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -120,7 +119,6 @@ func resourceFirebaseAppCheckPlayIntegrityConfigCreate(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -129,7 +127,6 @@ func resourceFirebaseAppCheckPlayIntegrityConfigCreate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PlayIntegrityConfig: %s", err) @@ -175,14 +172,12 @@ func resourceFirebaseAppCheckPlayIntegrityConfigRead(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckPlayIntegrityConfig %q", d.Id())) @@ -231,7 +226,6 @@ func resourceFirebaseAppCheckPlayIntegrityConfigUpdate(d *schema.ResourceData, m } log.Printf("[DEBUG] Updating PlayIntegrityConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("token_ttl") { @@ -259,7 +253,6 @@ func resourceFirebaseAppCheckPlayIntegrityConfigUpdate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go index 436b5e07b6e..b16f8c024db 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_enterprise_config.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -133,7 +132,6 @@ func resourceFirebaseAppCheckRecaptchaEnterpriseConfigCreate(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -142,7 +140,6 @@ func resourceFirebaseAppCheckRecaptchaEnterpriseConfigCreate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RecaptchaEnterpriseConfig: %s", err) @@ -188,14 +185,12 @@ func resourceFirebaseAppCheckRecaptchaEnterpriseConfigRead(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckRecaptchaEnterpriseConfig %q", d.Id())) @@ -253,7 +248,6 @@ func resourceFirebaseAppCheckRecaptchaEnterpriseConfigUpdate(d *schema.ResourceD } log.Printf("[DEBUG] Updating RecaptchaEnterpriseConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("token_ttl") { @@ -285,7 +279,6 @@ func resourceFirebaseAppCheckRecaptchaEnterpriseConfigUpdate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go index 60f967f49dc..4b92e0e3fac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_recaptcha_v3_config.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -138,7 +137,6 @@ func resourceFirebaseAppCheckRecaptchaV3ConfigCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -147,7 +145,6 @@ func resourceFirebaseAppCheckRecaptchaV3ConfigCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RecaptchaV3Config: %s", err) @@ -193,14 +190,12 @@ func resourceFirebaseAppCheckRecaptchaV3ConfigRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckRecaptchaV3Config %q", d.Id())) @@ -258,7 +253,6 @@ func resourceFirebaseAppCheckRecaptchaV3ConfigUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating RecaptchaV3Config %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("token_ttl") { @@ -290,7 +284,6 @@ func resourceFirebaseAppCheckRecaptchaV3ConfigUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go index 8c001c46cc1..3dd7a40c23d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firebaseappcheck/resource_firebase_app_check_service_config.go @@ -20,7 +20,6 @@ package firebaseappcheck import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -150,7 +149,6 @@ func resourceFirebaseAppCheckServiceConfigCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -159,7 +157,6 @@ func resourceFirebaseAppCheckServiceConfigCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServiceConfig: %s", err) @@ -205,14 +202,12 @@ func resourceFirebaseAppCheckServiceConfigRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirebaseAppCheckServiceConfig %q", d.Id())) @@ -261,7 +256,6 @@ func resourceFirebaseAppCheckServiceConfigUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating ServiceConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enforcement_mode") { @@ -289,7 +283,6 @@ func resourceFirebaseAppCheckServiceConfigUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -330,8 +323,6 @@ func resourceFirebaseAppCheckServiceConfigDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServiceConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -341,7 +332,6 @@ func resourceFirebaseAppCheckServiceConfigDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServiceConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_backup_schedule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_backup_schedule.go index c152235b566..3145fe1508d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_backup_schedule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_backup_schedule.go @@ -20,7 +20,6 @@ package firestore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -61,13 +60,13 @@ func ResourceFirestoreBackupSchedule() *schema.Resource { Description: `At what relative time in the future, compared to its creation time, the backup should be deleted, e.g. keep backups for 7 days. A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s". -You can set this to a value up to 14 weeks.`, +For a daily backup recurrence, set this to a value up to 7 days. If you set a weekly backup recurrence, set this to a value up to 14 weeks.`, }, "daily_recurrence": { Type: schema.TypeList, Optional: true, ForceNew: true, - Description: `For a schedule that runs daily.`, + Description: `For a schedule that runs daily at a specified time.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{}, @@ -85,7 +84,7 @@ You can set this to a value up to 14 weeks.`, Type: schema.TypeList, Optional: true, ForceNew: true, - Description: `For a schedule that runs weekly on a specific day.`, + Description: `For a schedule that runs weekly on a specific day and time.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -162,7 +161,6 @@ func resourceFirestoreBackupScheduleCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -171,7 +169,6 @@ func resourceFirestoreBackupScheduleCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BackupSchedule: %s", err) @@ -217,14 +214,12 @@ func resourceFirestoreBackupScheduleRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirestoreBackupSchedule %q", d.Id())) @@ -279,7 +274,6 @@ func resourceFirestoreBackupScheduleUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating BackupSchedule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("retention") { @@ -307,7 +301,6 @@ func resourceFirestoreBackupScheduleUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -348,8 +341,6 @@ func resourceFirestoreBackupScheduleDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BackupSchedule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -359,7 +350,6 @@ func resourceFirestoreBackupScheduleDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BackupSchedule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database.go index 8ccdc5cff3a..b9d8f988733 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database.go @@ -20,7 +20,6 @@ package firestore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -258,7 +257,6 @@ func resourceFirestoreDatabaseCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -267,7 +265,6 @@ func resourceFirestoreDatabaseCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Database: %s", err) @@ -334,14 +331,12 @@ func resourceFirestoreDatabaseRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirestoreDatabase %q", d.Id())) @@ -462,7 +457,6 @@ func resourceFirestoreDatabaseUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Database %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("type") { @@ -510,7 +504,6 @@ func resourceFirestoreDatabaseUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -558,7 +551,6 @@ func resourceFirestoreDatabaseDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) if deletionPolicy := d.Get("deletion_policy"); deletionPolicy != "DELETE" { log.Printf("[WARN] Firestore database %q deletion_policy is not set to 'DELETE', skipping deletion", d.Get("name").(string)) return nil @@ -576,7 +568,6 @@ func resourceFirestoreDatabaseDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Database") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database_sweeper.go deleted file mode 100644 index 4537750529a..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_database_sweeper.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package firestore - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("FirestoreDatabase", testSweepFirestoreDatabase) -} - -// At the time of writing, the CI only passes us-central1 as the region -// But all Firestore examples use nam5, so we will force that instead -func testSweepFirestoreDatabase(region string) error { - actualRegion := "nam5" - resourceName := "FirestoreDatabase" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Set up variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": actualRegion, - "location": actualRegion, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://firestore.googleapis.com/v1/projects/{{project}}/databases", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["databases"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) && name != "(default)" { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://firestore.googleapis.com/v1/projects/{{project}}/databases/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_document.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_document.go index 1b97ae29179..15ece52bd6e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_document.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_document.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -88,7 +87,7 @@ func ResourceFirestoreDocument() *schema.Resource { "name": { Type: schema.TypeString, Computed: true, - Description: `A server defined name for this document. Format: + Description: `A server defined name for this index. Format: 'projects/{{project_id}}/databases/{{database_id}}/documents/{{path}}/{{document_id}}'`, }, "path": { @@ -146,7 +145,6 @@ func resourceFirestoreDocumentCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -155,7 +153,6 @@ func resourceFirestoreDocumentCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Document: %s", err) @@ -201,14 +198,12 @@ func resourceFirestoreDocumentRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("FirestoreDocument %q", d.Id())) @@ -278,7 +273,6 @@ func resourceFirestoreDocumentUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Document %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -293,7 +287,6 @@ func resourceFirestoreDocumentUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -332,8 +325,6 @@ func resourceFirestoreDocumentDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Document %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -343,7 +334,6 @@ func resourceFirestoreDocumentDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Document") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_field.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_field.go index 5f17e6bd4e0..e41b899aba4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_field.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_field.go @@ -20,7 +20,6 @@ package firestore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -200,7 +199,6 @@ func resourceFirestoreFieldCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -209,7 +207,6 @@ func resourceFirestoreFieldCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.FirestoreField409RetryUnderlyingDataChanged}, }) if err != nil { @@ -277,14 +274,12 @@ func resourceFirestoreFieldRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.FirestoreField409RetryUnderlyingDataChanged}, }) if err != nil { @@ -348,7 +343,6 @@ func resourceFirestoreFieldUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Field %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("index_config") { @@ -380,7 +374,6 @@ func resourceFirestoreFieldUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.FirestoreField409RetryUnderlyingDataChanged}, }) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_index.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_index.go index 10b0aa3fbd7..0e524872cad 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_index.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/firestore/resource_firestore_index.go @@ -20,7 +20,6 @@ package firestore import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -101,12 +100,12 @@ func ResourceFirestoreIndex() *schema.Resource { Required: true, ForceNew: true, DiffSuppressFunc: firestoreIFieldsDiffSuppress, - Description: `The fields supported by this index. The last non-stored field entry is -always for the field path '__name__'. If, on creation, '__name__' was not -specified as the last field, it will be added automatically with the same -direction as that of the last field defined. If the final field in a -composite index is not directional, the '__name__' will be ordered -'"ASCENDING"' (unless explicitly specified otherwise).`, + Description: `The fields supported by this index. The last field entry is always for +the field path '__name__'. If, on creation, '__name__' was not +specified as the last field, it will be added automatically with the +same direction as that of the last field defined. If the final field +in a composite index is not directional, the '__name__' will be +ordered '"ASCENDING"' (unless explicitly specified otherwise).`, MinItems: 2, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -115,8 +114,8 @@ composite index is not directional, the '__name__' will be ordered Optional: true, ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"CONTAINS", ""}), - Description: `Indicates that this field supports operations on arrayValues. Only one of 'order', 'arrayConfig', and -'vectorConfig' can be specified. Possible values: ["CONTAINS"]`, + Description: `Indicates that this field supports operations on arrayValues. Only one of 'order' and 'arrayConfig' can +be specified. Possible values: ["CONTAINS"]`, }, "field_path": { Type: schema.TypeString, @@ -130,36 +129,7 @@ composite index is not directional, the '__name__' will be ordered ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"ASCENDING", "DESCENDING", ""}), Description: `Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. -Only one of 'order', 'arrayConfig', and 'vectorConfig' can be specified. Possible values: ["ASCENDING", "DESCENDING"]`, - }, - "vector_config": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Indicates that this field supports vector search operations. Only one of 'order', 'arrayConfig', and -'vectorConfig' can be specified. Vector Fields should come after the field path '__name__'.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "dimension": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `The resulting index will only include vectors of this dimension, and can be used for vector search -with the same dimension.`, - }, - "flat": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Indicates the vector index is a flat index.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - }, - }, - }, +Only one of 'order' and 'arrayConfig' can be specified. Possible values: ["ASCENDING", "DESCENDING"]`, }, }, }, @@ -267,7 +237,6 @@ func resourceFirestoreIndexCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -276,7 +245,6 @@ func resourceFirestoreIndexCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.FirestoreIndex409Retry}, }) if err != nil { @@ -354,14 +322,12 @@ func resourceFirestoreIndexRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.FirestoreIndex409Retry}, }) if err != nil { @@ -415,8 +381,6 @@ func resourceFirestoreIndexDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Index %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -426,7 +390,6 @@ func resourceFirestoreIndexDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.FirestoreIndex409Retry}, }) if err != nil { @@ -504,10 +467,9 @@ func flattenFirestoreIndexFields(v interface{}, d *schema.ResourceData, config * continue } transformed = append(transformed, map[string]interface{}{ - "field_path": flattenFirestoreIndexFieldsFieldPath(original["fieldPath"], d, config), - "order": flattenFirestoreIndexFieldsOrder(original["order"], d, config), - "array_config": flattenFirestoreIndexFieldsArrayConfig(original["arrayConfig"], d, config), - "vector_config": flattenFirestoreIndexFieldsVectorConfig(original["vectorConfig"], d, config), + "field_path": flattenFirestoreIndexFieldsFieldPath(original["fieldPath"], d, config), + "order": flattenFirestoreIndexFieldsOrder(original["order"], d, config), + "array_config": flattenFirestoreIndexFieldsArrayConfig(original["arrayConfig"], d, config), }) } return transformed @@ -524,46 +486,6 @@ func flattenFirestoreIndexFieldsArrayConfig(v interface{}, d *schema.ResourceDat return v } -func flattenFirestoreIndexFieldsVectorConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["dimension"] = - flattenFirestoreIndexFieldsVectorConfigDimension(original["dimension"], d, config) - transformed["flat"] = - flattenFirestoreIndexFieldsVectorConfigFlat(original["flat"], d, config) - return []interface{}{transformed} -} -func flattenFirestoreIndexFieldsVectorConfigDimension(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenFirestoreIndexFieldsVectorConfigFlat(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - func expandFirestoreIndexDatabase(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -611,13 +533,6 @@ func expandFirestoreIndexFields(v interface{}, d tpgresource.TerraformResourceDa transformed["arrayConfig"] = transformedArrayConfig } - transformedVectorConfig, err := expandFirestoreIndexFieldsVectorConfig(original["vector_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedVectorConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["vectorConfig"] = transformedVectorConfig - } - req = append(req, transformed) } return req, nil @@ -635,51 +550,6 @@ func expandFirestoreIndexFieldsArrayConfig(v interface{}, d tpgresource.Terrafor return v, nil } -func expandFirestoreIndexFieldsVectorConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDimension, err := expandFirestoreIndexFieldsVectorConfigDimension(original["dimension"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDimension); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["dimension"] = transformedDimension - } - - transformedFlat, err := expandFirestoreIndexFieldsVectorConfigFlat(original["flat"], d, config) - if err != nil { - return nil, err - } else { - transformed["flat"] = transformedFlat - } - - return transformed, nil -} - -func expandFirestoreIndexFieldsVectorConfigDimension(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandFirestoreIndexFieldsVectorConfigFlat(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - func resourceFirestoreIndexEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { // We've added project / database / collection as split fields of the name, but // the API doesn't expect them. Make sure we remove them from any requests. diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_backup_plan.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_backup_plan.go index 8385f1c97a0..854125bfa1f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_backup_plan.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_backup_plan.go @@ -20,7 +20,6 @@ package gkebackup import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -30,7 +29,6 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" ) func ResourceGKEBackupBackupPlan() *schema.Resource { @@ -116,13 +114,6 @@ when they fall into the scope of Backups.`, Optional: true, Description: `This flag specifies whether volume data should be backed up when PVCs are included in the scope of a Backup.`, - }, - "permissive_mode": { - Type: schema.TypeBool, - Optional: true, - Description: `This flag specifies whether Backups will not fail when -Backup for GKE detects Kubernetes configuration that is -non-standard or requires additional setup to restore.`, }, "selected_applications": { Type: schema.TypeList, @@ -188,8 +179,6 @@ non-standard or requires additional setup to restore.`, Optional: true, Description: `A standard cron string that defines a repeating schedule for creating Backups via this BackupPlan. -This is mutually exclusive with the rpoConfig field since at most one -schedule can be defined for a BackupPlan. If this is defined, then backupRetainDays must also be defined.`, }, "paused": { @@ -198,136 +187,6 @@ If this is defined, then backupRetainDays must also be defined.`, Optional: true, Description: `This flag denotes whether automatic Backup creation is paused for this BackupPlan.`, }, - "rpo_config": { - Type: schema.TypeList, - Optional: true, - Description: `Defines the RPO schedule configuration for this BackupPlan. This is mutually -exclusive with the cronSchedule field since at most one schedule can be defined -for a BackupPLan. If this is defined, then backupRetainDays must also be defined.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "target_rpo_minutes": { - Type: schema.TypeInt, - Required: true, - Description: `Defines the target RPO for the BackupPlan in minutes, which means the target -maximum data loss in time that is acceptable for this BackupPlan. This must be -at least 60, i.e., 1 hour, and at most 86400, i.e., 60 days.`, - }, - "exclusion_windows": { - Type: schema.TypeList, - Optional: true, - Description: `User specified time windows during which backup can NOT happen for this BackupPlan. -Backups should start and finish outside of any given exclusion window. Note: backup -jobs will be scheduled to start and finish outside the duration of the window as -much as possible, but running jobs will not get canceled when it runs into the window. -All the time and date values in exclusionWindows entry in the API are in UTC. We -only allow <=1 recurrence (daily or weekly) exclusion window for a BackupPlan while no -restriction on number of single occurrence windows.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "duration": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateDuration(), - Description: `Specifies duration of the window in seconds with up to nine fractional digits, -terminated by 's'. Example: "3.5s". Restrictions for duration based on the -recurrence type to allow some time for backup to happen: - - single_occurrence_date: no restriction - - daily window: duration < 24 hours - - weekly window: - - days of week includes all seven days of a week: duration < 24 hours - - all other weekly window: duration < 168 hours (i.e., 24 * 7 hours)`, - }, - "start_time": { - Type: schema.TypeList, - Required: true, - Description: `Specifies the start time of the window using time of the day in UTC.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "hours": { - Type: schema.TypeInt, - Optional: true, - Description: `Hours of day in 24 hour format.`, - }, - "minutes": { - Type: schema.TypeInt, - Optional: true, - Description: `Minutes of hour of day.`, - }, - "nanos": { - Type: schema.TypeInt, - Optional: true, - Description: `Fractions of seconds in nanoseconds.`, - }, - "seconds": { - Type: schema.TypeInt, - Optional: true, - Description: `Seconds of minutes of the time.`, - }, - }, - }, - }, - "daily": { - Type: schema.TypeBool, - Optional: true, - Description: `The exclusion window occurs every day if set to "True". -Specifying this field to "False" is an error. -Only one of singleOccurrenceDate, daily and daysOfWeek may be set.`, - }, - "days_of_week": { - Type: schema.TypeList, - Optional: true, - Description: `The exclusion window occurs on these days of each week in UTC. -Only one of singleOccurrenceDate, daily and daysOfWeek may be set.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "days_of_week": { - Type: schema.TypeList, - Optional: true, - Description: `A list of days of week. Possible values: ["MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"}), - }, - }, - }, - }, - }, - "single_occurrence_date": { - Type: schema.TypeList, - Optional: true, - Description: `No recurrence. The exclusion window occurs only once and on this date in UTC. -Only one of singleOccurrenceDate, daily and daysOfWeek may be set.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "day": { - Type: schema.TypeInt, - Optional: true, - Description: `Day of a month.`, - }, - "month": { - Type: schema.TypeInt, - Optional: true, - Description: `Month of a year.`, - }, - "year": { - Type: schema.TypeInt, - Optional: true, - Description: `Year of the date.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, }, }, }, @@ -388,9 +247,7 @@ subject to automatic deletion. Updating this field does NOT affect existing Backups under it. Backups created AFTER a successful update will automatically pick up the new value. NOTE: backupRetainDays must be >= backupDeleteLockDays. -If cronSchedule is defined, then this must be <= 360 * the creation interval. -If rpo_config is defined, then this must be -<= 360 * targetRpoMinutes/(1440minutes/day)`, +If cronSchedule is defined, then this must be <= 360 * the creation interval.]`, }, "locked": { Type: schema.TypeBool, @@ -533,7 +390,6 @@ func resourceGKEBackupBackupPlanCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -542,7 +398,6 @@ func resourceGKEBackupBackupPlanCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BackupPlan: %s", err) @@ -609,14 +464,12 @@ func resourceGKEBackupBackupPlanRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEBackupBackupPlan %q", d.Id())) @@ -734,7 +587,6 @@ func resourceGKEBackupBackupPlanUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating BackupPlan %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -782,7 +634,6 @@ func resourceGKEBackupBackupPlanUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -830,8 +681,6 @@ func resourceGKEBackupBackupPlanDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BackupPlan %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -841,7 +690,6 @@ func resourceGKEBackupBackupPlanDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BackupPlan") @@ -981,8 +829,6 @@ func flattenGKEBackupBackupPlanBackupSchedule(v interface{}, d *schema.ResourceD flattenGKEBackupBackupPlanBackupScheduleCronSchedule(original["cronSchedule"], d, config) transformed["paused"] = flattenGKEBackupBackupPlanBackupSchedulePaused(original["paused"], d, config) - transformed["rpo_config"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfig(original["rpoConfig"], d, config) return []interface{}{transformed} } func flattenGKEBackupBackupPlanBackupScheduleCronSchedule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -993,240 +839,6 @@ func flattenGKEBackupBackupPlanBackupSchedulePaused(v interface{}, d *schema.Res return v } -func flattenGKEBackupBackupPlanBackupScheduleRpoConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["target_rpo_minutes"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigTargetRpoMinutes(original["targetRpoMinutes"], d, config) - transformed["exclusion_windows"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindows(original["exclusionWindows"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigTargetRpoMinutes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindows(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "start_time": flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTime(original["startTime"], d, config), - "duration": flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDuration(original["duration"], d, config), - "single_occurrence_date": flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDate(original["singleOccurrenceDate"], d, config), - "daily": flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaily(original["daily"], d, config), - "days_of_week": flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeek(original["daysOfWeek"], d, config), - }) - } - return transformed -} -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["hours"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeHours(original["hours"], d, config) - transformed["minutes"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeMinutes(original["minutes"], d, config) - transformed["seconds"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeSeconds(original["seconds"], d, config) - transformed["nanos"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeNanos(original["nanos"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeHours(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeMinutes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeSeconds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeNanos(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDuration(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["year"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateYear(original["year"], d, config) - transformed["month"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateMonth(original["month"], d, config) - transformed["day"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateDay(original["day"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateYear(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateMonth(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateDay(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaily(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeek(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["days_of_week"] = - flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeekDaysOfWeek(original["daysOfWeek"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeekDaysOfWeek(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenGKEBackupBackupPlanEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1256,8 +868,6 @@ func flattenGKEBackupBackupPlanBackupConfig(v interface{}, d *schema.ResourceDat flattenGKEBackupBackupPlanBackupConfigSelectedNamespaces(original["selectedNamespaces"], d, config) transformed["selected_applications"] = flattenGKEBackupBackupPlanBackupConfigSelectedApplications(original["selectedApplications"], d, config) - transformed["permissive_mode"] = - flattenGKEBackupBackupPlanBackupConfigPermissiveMode(original["permissiveMode"], d, config) return []interface{}{transformed} } func flattenGKEBackupBackupPlanBackupConfigIncludeVolumeData(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1346,10 +956,6 @@ func flattenGKEBackupBackupPlanBackupConfigSelectedApplicationsNamespacedNamesNa return v } -func flattenGKEBackupBackupPlanBackupConfigPermissiveMode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenGKEBackupBackupPlanProtectedPodCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -1474,13 +1080,6 @@ func expandGKEBackupBackupPlanBackupSchedule(v interface{}, d tpgresource.Terraf transformed["paused"] = transformedPaused } - transformedRpoConfig, err := expandGKEBackupBackupPlanBackupScheduleRpoConfig(original["rpo_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRpoConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["rpoConfig"] = transformedRpoConfig - } - return transformed, nil } @@ -1492,218 +1091,6 @@ func expandGKEBackupBackupPlanBackupSchedulePaused(v interface{}, d tpgresource. return v, nil } -func expandGKEBackupBackupPlanBackupScheduleRpoConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedTargetRpoMinutes, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigTargetRpoMinutes(original["target_rpo_minutes"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTargetRpoMinutes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["targetRpoMinutes"] = transformedTargetRpoMinutes - } - - transformedExclusionWindows, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindows(original["exclusion_windows"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExclusionWindows); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["exclusionWindows"] = transformedExclusionWindows - } - - return transformed, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigTargetRpoMinutes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindows(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedStartTime, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTime(original["start_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStartTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["startTime"] = transformedStartTime - } - - transformedDuration, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDuration(original["duration"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDuration); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["duration"] = transformedDuration - } - - transformedSingleOccurrenceDate, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDate(original["single_occurrence_date"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSingleOccurrenceDate); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["singleOccurrenceDate"] = transformedSingleOccurrenceDate - } - - transformedDaily, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaily(original["daily"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDaily); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["daily"] = transformedDaily - } - - transformedDaysOfWeek, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeek(original["days_of_week"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDaysOfWeek); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["daysOfWeek"] = transformedDaysOfWeek - } - - req = append(req, transformed) - } - return req, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedHours, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeHours(original["hours"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedHours); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["hours"] = transformedHours - } - - transformedMinutes, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeMinutes(original["minutes"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinutes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minutes"] = transformedMinutes - } - - transformedSeconds, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeSeconds(original["seconds"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeconds); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["seconds"] = transformedSeconds - } - - transformedNanos, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeNanos(original["nanos"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedNanos); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["nanos"] = transformedNanos - } - - return transformed, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeHours(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeMinutes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeSeconds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsStartTimeNanos(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDuration(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedYear, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateYear(original["year"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedYear); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["year"] = transformedYear - } - - transformedMonth, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateMonth(original["month"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMonth); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["month"] = transformedMonth - } - - transformedDay, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateDay(original["day"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDay); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["day"] = transformedDay - } - - return transformed, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateYear(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateMonth(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsSingleOccurrenceDateDay(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaily(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeek(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDaysOfWeek, err := expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeekDaysOfWeek(original["days_of_week"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDaysOfWeek); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["daysOfWeek"] = transformedDaysOfWeek - } - - return transformed, nil -} - -func expandGKEBackupBackupPlanBackupScheduleRpoConfigExclusionWindowsDaysOfWeekDaysOfWeek(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandGKEBackupBackupPlanDeactivated(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1759,13 +1146,6 @@ func expandGKEBackupBackupPlanBackupConfig(v interface{}, d tpgresource.Terrafor transformed["selectedApplications"] = transformedSelectedApplications } - transformedPermissiveMode, err := expandGKEBackupBackupPlanBackupConfigPermissiveMode(original["permissive_mode"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPermissiveMode); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["permissiveMode"] = transformedPermissiveMode - } - return transformed, nil } @@ -1883,10 +1263,6 @@ func expandGKEBackupBackupPlanBackupConfigSelectedApplicationsNamespacedNamesNam return v, nil } -func expandGKEBackupBackupPlanBackupConfigPermissiveMode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandGKEBackupBackupPlanEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_restore_plan.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_restore_plan.go index 221b1b6ca0d..bce0e9eb3c2 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_restore_plan.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkebackup/resource_gke_backup_restore_plan.go @@ -20,7 +20,6 @@ package gkebackup import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -204,13 +203,13 @@ All namespaces except those in this list will be restored.`, "namespaced_resource_restore_mode": { Type: schema.TypeString, Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"DELETE_AND_RESTORE", "FAIL_ON_CONFLICT", "MERGE_SKIP_ON_CONFLICT", "MERGE_REPLACE_VOLUME_ON_CONFLICT", "MERGE_REPLACE_ON_CONFLICT", ""}), + ValidateFunc: verify.ValidateEnum([]string{"DELETE_AND_RESTORE", "FAIL_ON_CONFLICT", ""}), Description: `Defines the behavior for handling the situation where sets of namespaced resources being restored already exist in the target cluster. This MUST be set to a value other than 'NAMESPACED_RESOURCE_RESTORE_MODE_UNSPECIFIED' if the 'namespacedResourceRestoreScope' is anything other than 'noNamespaces'. See https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/reference/rest/v1/RestoreConfig#namespacedresourcerestoremode -for more information on each mode. Possible values: ["DELETE_AND_RESTORE", "FAIL_ON_CONFLICT", "MERGE_SKIP_ON_CONFLICT", "MERGE_REPLACE_VOLUME_ON_CONFLICT", "MERGE_REPLACE_ON_CONFLICT"]`, +for more information on each mode. Possible values: ["DELETE_AND_RESTORE", "FAIL_ON_CONFLICT"]`, }, "no_namespaces": { Type: schema.TypeBool, @@ -219,75 +218,6 @@ for more information on each mode. Possible values: ["DELETE_AND_RESTORE", "FAIL Specifying this field to "False" is not allowed.`, ExactlyOneOf: []string{"restore_config.0.all_namespaces", "restore_config.0.excluded_namespaces", "restore_config.0.selected_namespaces", "restore_config.0.selected_applications", "restore_config.0.no_namespaces"}, }, - "restore_order": { - Type: schema.TypeList, - Optional: true, - Description: `It contains custom ordering to use on a Restore.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "group_kind_dependencies": { - Type: schema.TypeList, - Required: true, - Description: `A list of group kind dependency pairs -that is used by Backup for GKE to -generate a group kind restore order.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "requiring": { - Type: schema.TypeList, - Required: true, - Description: `The requiring group kind requires that the satisfying -group kind be restored first.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resource_group": { - Type: schema.TypeString, - Optional: true, - Description: `API Group of a Kubernetes resource, e.g. -"apiextensions.k8s.io", "storage.k8s.io", etc. -Use empty string for core group.`, - }, - "resource_kind": { - Type: schema.TypeString, - Optional: true, - Description: `Kind of a Kubernetes resource, e.g. -"CustomResourceDefinition", "StorageClass", etc.`, - }, - }, - }, - }, - "satisfying": { - Type: schema.TypeList, - Required: true, - Description: `The satisfying group kind must be restored first -in order to satisfy the dependency.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resource_group": { - Type: schema.TypeString, - Optional: true, - Description: `API Group of a Kubernetes resource, e.g. -"apiextensions.k8s.io", "storage.k8s.io", etc. -Use empty string for core group.`, - }, - "resource_kind": { - Type: schema.TypeString, - Optional: true, - Description: `Kind of a Kubernetes resource, e.g. -"CustomResourceDefinition", "StorageClass", etc.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, "selected_applications": { Type: schema.TypeList, Optional: true, @@ -467,32 +397,6 @@ If not specified, it will be treated as 'NO_VOLUME_DATA_RESTORATION'. See https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/reference/rest/v1/RestoreConfig#VolumeDataRestorePolicy for more information on each policy option. Possible values: ["RESTORE_VOLUME_DATA_FROM_BACKUP", "REUSE_VOLUME_HANDLE_FROM_BACKUP", "NO_VOLUME_DATA_RESTORATION"]`, }, - "volume_data_restore_policy_bindings": { - Type: schema.TypeList, - Optional: true, - Description: `A table that binds volumes by their scope to a restore policy. Bindings -must have a unique scope. Any volumes not scoped in the bindings are -subject to the policy defined in volume_data_restore_policy.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "policy": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"RESTORE_VOLUME_DATA_FROM_BACKUP", "REUSE_VOLUME_HANDLE_FROM_BACKUP", "NO_VOLUME_DATA_RESTORATION"}), - Description: `Specifies the mechanism to be used to restore this volume data. -See https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/reference/rest/v1/RestoreConfig#VolumeDataRestorePolicy -for more information on each policy option. Possible values: ["RESTORE_VOLUME_DATA_FROM_BACKUP", "REUSE_VOLUME_HANDLE_FROM_BACKUP", "NO_VOLUME_DATA_RESTORATION"]`, - }, - "volume_type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"GCE_PERSISTENT_DISK"}), - Description: `The volume type, as determined by the PVC's -bound PV, to apply the policy to. Possible values: ["GCE_PERSISTENT_DISK"]`, - }, - }, - }, - }, }, }, }, @@ -616,7 +520,6 @@ func resourceGKEBackupRestorePlanCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -625,7 +528,6 @@ func resourceGKEBackupRestorePlanCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating RestorePlan: %s", err) @@ -692,14 +594,12 @@ func resourceGKEBackupRestorePlanRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEBackupRestorePlan %q", d.Id())) @@ -787,7 +687,6 @@ func resourceGKEBackupRestorePlanUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating RestorePlan %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -823,7 +722,6 @@ func resourceGKEBackupRestorePlanUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -871,8 +769,6 @@ func resourceGKEBackupRestorePlanDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting RestorePlan %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -882,7 +778,6 @@ func resourceGKEBackupRestorePlanDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "RestorePlan") @@ -987,10 +882,6 @@ func flattenGKEBackupRestorePlanRestoreConfig(v interface{}, d *schema.ResourceD flattenGKEBackupRestorePlanRestoreConfigClusterResourceConflictPolicy(original["clusterResourceConflictPolicy"], d, config) transformed["transformation_rules"] = flattenGKEBackupRestorePlanRestoreConfigTransformationRules(original["transformationRules"], d, config) - transformed["volume_data_restore_policy_bindings"] = - flattenGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindings(original["volumeDataRestorePolicyBindings"], d, config) - transformed["restore_order"] = - flattenGKEBackupRestorePlanRestoreConfigRestoreOrder(original["restoreOrder"], d, config) return []interface{}{transformed} } func flattenGKEBackupRestorePlanRestoreConfigAllNamespaces(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1281,111 +1172,6 @@ func flattenGKEBackupRestorePlanRestoreConfigTransformationRulesFieldActionsValu return v } -func flattenGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "policy": flattenGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsPolicy(original["policy"], d, config), - "volume_type": flattenGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsVolumeType(original["volumeType"], d, config), - }) - } - return transformed -} -func flattenGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsVolumeType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrder(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["group_kind_dependencies"] = - flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependencies(original["groupKindDependencies"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependencies(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "satisfying": flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfying(original["satisfying"], d, config), - "requiring": flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiring(original["requiring"], d, config), - }) - } - return transformed -} -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfying(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["resource_group"] = - flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceGroup(original["resourceGroup"], d, config) - transformed["resource_kind"] = - flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceKind(original["resourceKind"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceGroup(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceKind(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiring(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["resource_group"] = - flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceGroup(original["resourceGroup"], d, config) - transformed["resource_kind"] = - flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceKind(original["resourceKind"], d, config) - return []interface{}{transformed} -} -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceGroup(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceKind(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenGKEBackupRestorePlanState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1508,20 +1294,6 @@ func expandGKEBackupRestorePlanRestoreConfig(v interface{}, d tpgresource.Terraf transformed["transformationRules"] = transformedTransformationRules } - transformedVolumeDataRestorePolicyBindings, err := expandGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindings(original["volume_data_restore_policy_bindings"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedVolumeDataRestorePolicyBindings); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["volumeDataRestorePolicyBindings"] = transformedVolumeDataRestorePolicyBindings - } - - transformedRestoreOrder, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrder(original["restore_order"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRestoreOrder); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["restoreOrder"] = transformedRestoreOrder - } - return transformed, nil } @@ -1946,159 +1718,6 @@ func expandGKEBackupRestorePlanRestoreConfigTransformationRulesFieldActionsValue return v, nil } -func expandGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPolicy, err := expandGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsPolicy(original["policy"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPolicy); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["policy"] = transformedPolicy - } - - transformedVolumeType, err := expandGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsVolumeType(original["volume_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedVolumeType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["volumeType"] = transformedVolumeType - } - - req = append(req, transformed) - } - return req, nil -} - -func expandGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupRestorePlanRestoreConfigVolumeDataRestorePolicyBindingsVolumeType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrder(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedGroupKindDependencies, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependencies(original["group_kind_dependencies"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedGroupKindDependencies); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["groupKindDependencies"] = transformedGroupKindDependencies - } - - return transformed, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependencies(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSatisfying, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfying(original["satisfying"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSatisfying); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["satisfying"] = transformedSatisfying - } - - transformedRequiring, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiring(original["requiring"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequiring); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requiring"] = transformedRequiring - } - - req = append(req, transformed) - } - return req, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfying(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedResourceGroup, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceGroup(original["resource_group"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceGroup); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceGroup"] = transformedResourceGroup - } - - transformedResourceKind, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceKind(original["resource_kind"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceKind); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceKind"] = transformedResourceKind - } - - return transformed, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceGroup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesSatisfyingResourceKind(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiring(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedResourceGroup, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceGroup(original["resource_group"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceGroup); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceGroup"] = transformedResourceGroup - } - - transformedResourceKind, err := expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceKind(original["resource_kind"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceKind); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceKind"] = transformedResourceKind - } - - return transformed, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceGroup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEBackupRestorePlanRestoreConfigRestoreOrderGroupKindDependenciesRequiringResourceKind(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandGKEBackupRestorePlanEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub/resource_gke_hub_membership.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub/resource_gke_hub_membership.go index a2777bd0494..782035e870a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub/resource_gke_hub_membership.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub/resource_gke_hub_membership.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -226,7 +225,6 @@ func resourceGKEHubMembershipCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -235,7 +233,6 @@ func resourceGKEHubMembershipCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Membership: %s", err) @@ -302,14 +299,12 @@ func resourceGKEHubMembershipRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHubMembership %q", d.Id())) @@ -376,7 +371,6 @@ func resourceGKEHubMembershipUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Membership %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("authority") { @@ -408,7 +402,6 @@ func resourceGKEHubMembershipUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -456,8 +449,6 @@ func resourceGKEHubMembershipDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Membership %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -467,7 +458,6 @@ func resourceGKEHubMembershipDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Membership") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_feature.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_feature.go index 372f0e30d77..a5148d3fd6a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_feature.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_feature.go @@ -20,7 +20,6 @@ package gkehub2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -83,11 +82,6 @@ func ResourceGKEHub2Feature() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Optional: true, - Description: `Enables the installation of ConfigSync. If set to true, ConfigSync resources will be created and the other ConfigSync fields will be applied if exist. If set to false, all other ConfigSync fields will be ignored, ConfigSync resources will be deleted. If omitted, ConfigSync resources will be managed depends on the presence of the git or oci field.`, - }, "git": { Type: schema.TypeList, Optional: true, @@ -179,11 +173,6 @@ func ResourceGKEHub2Feature() *schema.Resource { }, }, }, - "prevent_drift": { - Type: schema.TypeBool, - Optional: true, - Description: `Set to true to enable the Config Sync admission webhook to prevent drifts. If set to 'false', disables the Config Sync admission webhook and does not prevent drifts.`, - }, "source_format": { Type: schema.TypeString, Optional: true, @@ -738,7 +727,7 @@ func resourceGKEHub2FeatureCreate(d *schema.ResourceData, meta interface{}) erro fleetDefaultMemberConfigProp, err := expandGKEHub2FeatureFleetDefaultMemberConfig(d.Get("fleet_default_member_config"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("fleet_default_member_config"); ok || !reflect.DeepEqual(v, fleetDefaultMemberConfigProp) { + } else if v, ok := d.GetOkExists("fleet_default_member_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(fleetDefaultMemberConfigProp)) && (ok || !reflect.DeepEqual(v, fleetDefaultMemberConfigProp)) { obj["fleetDefaultMemberConfig"] = fleetDefaultMemberConfigProp } labelsProp, err := expandGKEHub2FeatureEffectiveLabels(d.Get("effective_labels"), d, config) @@ -767,7 +756,6 @@ func resourceGKEHub2FeatureCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -776,7 +764,6 @@ func resourceGKEHub2FeatureCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Feature: %s", err) @@ -839,14 +826,12 @@ func resourceGKEHub2FeatureRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHub2Feature %q", d.Id())) @@ -915,7 +900,7 @@ func resourceGKEHub2FeatureUpdate(d *schema.ResourceData, meta interface{}) erro fleetDefaultMemberConfigProp, err := expandGKEHub2FeatureFleetDefaultMemberConfig(d.Get("fleet_default_member_config"), d, config) if err != nil { return err - } else if v, ok := d.GetOkExists("fleet_default_member_config"); ok || !reflect.DeepEqual(v, fleetDefaultMemberConfigProp) { + } else if v, ok := d.GetOkExists("fleet_default_member_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, fleetDefaultMemberConfigProp)) { obj["fleetDefaultMemberConfig"] = fleetDefaultMemberConfigProp } labelsProp, err := expandGKEHub2FeatureEffectiveLabels(d.Get("effective_labels"), d, config) @@ -931,7 +916,6 @@ func resourceGKEHub2FeatureUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Feature %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("spec") { @@ -967,7 +951,6 @@ func resourceGKEHub2FeatureUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1015,8 +998,6 @@ func resourceGKEHub2FeatureDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Feature %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1026,7 +1007,6 @@ func resourceGKEHub2FeatureDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Feature") @@ -1359,10 +1339,6 @@ func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(v i transformed := make(map[string]interface{}) transformed["source_format"] = flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncSourceFormat(original["sourceFormat"], d, config) - transformed["enabled"] = - flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncEnabled(original["enabled"], d, config) - transformed["prevent_drift"] = - flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncPreventDrift(original["preventDrift"], d, config) transformed["git"] = flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncGit(original["git"], d, config) transformed["oci"] = @@ -1373,14 +1349,6 @@ func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncSour return v } -func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncPreventDrift(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncGit(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -2264,20 +2232,6 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSync(v in transformed["sourceFormat"] = transformedSourceFormat } - transformedEnabled, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncEnabled(original["enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enabled"] = transformedEnabled - } - - transformedPreventDrift, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncPreventDrift(original["prevent_drift"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPreventDrift); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["preventDrift"] = transformedPreventDrift - } - transformedGit, err := expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncGit(original["git"], d, config) if err != nil { return nil, err @@ -2299,14 +2253,6 @@ func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncSourc return v, nil } -func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncPreventDrift(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandGKEHub2FeatureFleetDefaultMemberConfigConfigmanagementConfigSyncGit(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_fleet.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_fleet.go index e829f6eac53..9517edde4d1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_fleet.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_fleet.go @@ -20,7 +20,6 @@ package gkehub2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -104,8 +103,8 @@ platform policies have the following format: "mode": { Type: schema.TypeString, Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"DISABLED", "BASIC", "ENTERPRISE", ""}), - Description: `Sets which mode to use for Security Posture features. Possible values: ["DISABLED", "BASIC", "ENTERPRISE"]`, + ValidateFunc: verify.ValidateEnum([]string{"DISABLED", "BASIC", ""}), + Description: `Sets which mode to use for Security Posture features. Possible values: ["DISABLED", "BASIC"]`, }, "vulnerability_mode": { Type: schema.TypeString, @@ -212,7 +211,6 @@ func resourceGKEHub2FleetCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -221,7 +219,6 @@ func resourceGKEHub2FleetCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Fleet: %s", err) @@ -274,14 +271,12 @@ func resourceGKEHub2FleetRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHub2Fleet %q", d.Id())) @@ -351,7 +346,6 @@ func resourceGKEHub2FleetUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Fleet %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -383,7 +377,6 @@ func resourceGKEHub2FleetUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -431,8 +424,6 @@ func resourceGKEHub2FleetDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Fleet %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -442,7 +433,6 @@ func resourceGKEHub2FleetDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Fleet") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_membership_binding.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_membership_binding.go index 560dce70cff..047c3954c02 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_membership_binding.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_membership_binding.go @@ -20,7 +20,6 @@ package gkehub2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -193,7 +192,6 @@ func resourceGKEHub2MembershipBindingCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -202,7 +200,6 @@ func resourceGKEHub2MembershipBindingCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating MembershipBinding: %s", err) @@ -269,14 +266,12 @@ func resourceGKEHub2MembershipBindingRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHub2MembershipBinding %q", d.Id())) @@ -355,7 +350,6 @@ func resourceGKEHub2MembershipBindingUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating MembershipBinding %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("scope") { @@ -387,7 +381,6 @@ func resourceGKEHub2MembershipBindingUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -435,8 +428,6 @@ func resourceGKEHub2MembershipBindingDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting MembershipBinding %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -446,7 +437,6 @@ func resourceGKEHub2MembershipBindingDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "MembershipBinding") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_namespace.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_namespace.go index 8232218140d..c800235903e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_namespace.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_namespace.go @@ -20,7 +20,6 @@ package gkehub2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -203,7 +202,6 @@ func resourceGKEHub2NamespaceCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -212,7 +210,6 @@ func resourceGKEHub2NamespaceCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Namespace: %s", err) @@ -279,14 +276,12 @@ func resourceGKEHub2NamespaceRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHub2Namespace %q", d.Id())) @@ -368,7 +363,6 @@ func resourceGKEHub2NamespaceUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Namespace %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("namespace_labels") { @@ -400,7 +394,6 @@ func resourceGKEHub2NamespaceUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -448,8 +441,6 @@ func resourceGKEHub2NamespaceDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Namespace %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -459,7 +450,6 @@ func resourceGKEHub2NamespaceDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Namespace") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope.go index 79fb41d4ba2..ff8de33ada1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope.go @@ -20,7 +20,6 @@ package gkehub2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -184,7 +183,6 @@ func resourceGKEHub2ScopeCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -193,7 +191,6 @@ func resourceGKEHub2ScopeCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Scope: %s", err) @@ -260,14 +257,12 @@ func resourceGKEHub2ScopeRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHub2Scope %q", d.Id())) @@ -346,7 +341,6 @@ func resourceGKEHub2ScopeUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Scope %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("namespace_labels") { @@ -378,7 +372,6 @@ func resourceGKEHub2ScopeUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -426,8 +419,6 @@ func resourceGKEHub2ScopeDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Scope %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -437,7 +428,6 @@ func resourceGKEHub2ScopeDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Scope") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go index 9f1bca877e0..03ad75d093c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkehub2/resource_gke_hub_scope_rbac_role_binding.go @@ -20,7 +20,6 @@ package gkehub2 import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -226,7 +225,6 @@ func resourceGKEHub2ScopeRBACRoleBindingCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -235,7 +233,6 @@ func resourceGKEHub2ScopeRBACRoleBindingCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ScopeRBACRoleBinding: %s", err) @@ -302,14 +299,12 @@ func resourceGKEHub2ScopeRBACRoleBindingRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GKEHub2ScopeRBACRoleBinding %q", d.Id())) @@ -406,7 +401,6 @@ func resourceGKEHub2ScopeRBACRoleBindingUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating ScopeRBACRoleBinding %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("user") { @@ -446,7 +440,6 @@ func resourceGKEHub2ScopeRBACRoleBindingUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -494,8 +487,6 @@ func resourceGKEHub2ScopeRBACRoleBindingDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ScopeRBACRoleBinding %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -505,7 +496,6 @@ func resourceGKEHub2ScopeRBACRoleBindingDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ScopeRBACRoleBinding") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go index 5d17207e35f..ad3ca66f21b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_admin_cluster.go @@ -20,7 +20,6 @@ package gkeonprem import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -829,7 +828,6 @@ func resourceGkeonpremBareMetalAdminClusterCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -838,7 +836,6 @@ func resourceGkeonpremBareMetalAdminClusterCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BareMetalAdminCluster: %s", err) @@ -898,14 +895,12 @@ func resourceGkeonpremBareMetalAdminClusterRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GkeonpremBareMetalAdminCluster %q", d.Id())) @@ -1098,7 +1093,6 @@ func resourceGkeonpremBareMetalAdminClusterUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating BareMetalAdminCluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1174,7 +1168,6 @@ func resourceGkeonpremBareMetalAdminClusterUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go index afe6962e1a0..005c3ed4d08 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_cluster.go @@ -20,7 +20,6 @@ package gkeonprem import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -1337,7 +1336,6 @@ func resourceGkeonpremBareMetalClusterCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1346,7 +1344,6 @@ func resourceGkeonpremBareMetalClusterCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BareMetalCluster: %s", err) @@ -1406,14 +1403,12 @@ func resourceGkeonpremBareMetalClusterRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GkeonpremBareMetalCluster %q", d.Id())) @@ -1636,7 +1631,6 @@ func resourceGkeonpremBareMetalClusterUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating BareMetalCluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1724,7 +1718,6 @@ func resourceGkeonpremBareMetalClusterUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1772,8 +1765,6 @@ func resourceGkeonpremBareMetalClusterDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BareMetalCluster %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1783,7 +1774,6 @@ func resourceGkeonpremBareMetalClusterDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BareMetalCluster") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go index a2ac54718c9..e1893fa0e17 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_bare_metal_node_pool.go @@ -20,7 +20,6 @@ package gkeonprem import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -340,7 +339,6 @@ func resourceGkeonpremBareMetalNodePoolCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -349,7 +347,6 @@ func resourceGkeonpremBareMetalNodePoolCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BareMetalNodePool: %s", err) @@ -409,14 +406,12 @@ func resourceGkeonpremBareMetalNodePoolRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GkeonpremBareMetalNodePool %q", d.Id())) @@ -507,7 +502,6 @@ func resourceGkeonpremBareMetalNodePoolUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating BareMetalNodePool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -543,7 +537,6 @@ func resourceGkeonpremBareMetalNodePoolUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -591,8 +584,6 @@ func resourceGkeonpremBareMetalNodePoolDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BareMetalNodePool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -602,7 +593,6 @@ func resourceGkeonpremBareMetalNodePoolDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BareMetalNodePool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go index 49c1c9bac23..c6ecfbb7cd9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_cluster.go @@ -20,7 +20,6 @@ package gkeonprem import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -256,11 +255,6 @@ full access to the cluster.`, Optional: true, Description: `A human readable description of this VMware User Cluster.`, }, - "disable_bundled_ingress": { - Type: schema.TypeBool, - Optional: true, - Description: `Disable bundled ingress.`, - }, "enable_control_plane_v2": { Type: schema.TypeBool, Optional: true, @@ -986,12 +980,6 @@ func resourceGkeonpremVmwareClusterCreate(d *schema.ResourceData, meta interface } else if v, ok := d.GetOkExists("enable_control_plane_v2"); !tpgresource.IsEmptyValue(reflect.ValueOf(enableControlPlaneV2Prop)) && (ok || !reflect.DeepEqual(v, enableControlPlaneV2Prop)) { obj["enableControlPlaneV2"] = enableControlPlaneV2Prop } - disableBundledIngressProp, err := expandGkeonpremVmwareClusterDisableBundledIngress(d.Get("disable_bundled_ingress"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("disable_bundled_ingress"); !tpgresource.IsEmptyValue(reflect.ValueOf(disableBundledIngressProp)) && (ok || !reflect.DeepEqual(v, disableBundledIngressProp)) { - obj["disableBundledIngress"] = disableBundledIngressProp - } upgradePolicyProp, err := expandGkeonpremVmwareClusterUpgradePolicy(d.Get("upgrade_policy"), d, config) if err != nil { return err @@ -1030,7 +1018,6 @@ func resourceGkeonpremVmwareClusterCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1039,7 +1026,6 @@ func resourceGkeonpremVmwareClusterCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VmwareCluster: %s", err) @@ -1099,14 +1085,12 @@ func resourceGkeonpremVmwareClusterRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GkeonpremVmwareCluster %q", d.Id())) @@ -1161,9 +1145,6 @@ func resourceGkeonpremVmwareClusterRead(d *schema.ResourceData, meta interface{} if err := d.Set("enable_control_plane_v2", flattenGkeonpremVmwareClusterEnableControlPlaneV2(res["enableControlPlaneV2"], d, config)); err != nil { return fmt.Errorf("Error reading VmwareCluster: %s", err) } - if err := d.Set("disable_bundled_ingress", flattenGkeonpremVmwareClusterDisableBundledIngress(res["disableBundledIngress"], d, config)); err != nil { - return fmt.Errorf("Error reading VmwareCluster: %s", err) - } if err := d.Set("upgrade_policy", flattenGkeonpremVmwareClusterUpgradePolicy(res["upgradePolicy"], d, config)); err != nil { return fmt.Errorf("Error reading VmwareCluster: %s", err) } @@ -1298,12 +1279,6 @@ func resourceGkeonpremVmwareClusterUpdate(d *schema.ResourceData, meta interface } else if v, ok := d.GetOkExists("enable_control_plane_v2"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enableControlPlaneV2Prop)) { obj["enableControlPlaneV2"] = enableControlPlaneV2Prop } - disableBundledIngressProp, err := expandGkeonpremVmwareClusterDisableBundledIngress(d.Get("disable_bundled_ingress"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("disable_bundled_ingress"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, disableBundledIngressProp)) { - obj["disableBundledIngress"] = disableBundledIngressProp - } upgradePolicyProp, err := expandGkeonpremVmwareClusterUpgradePolicy(d.Get("upgrade_policy"), d, config) if err != nil { return err @@ -1329,7 +1304,6 @@ func resourceGkeonpremVmwareClusterUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating VmwareCluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1380,10 +1354,6 @@ func resourceGkeonpremVmwareClusterUpdate(d *schema.ResourceData, meta interface updateMask = append(updateMask, "enableControlPlaneV2") } - if d.HasChange("disable_bundled_ingress") { - updateMask = append(updateMask, "disableBundledIngress") - } - if d.HasChange("upgrade_policy") { updateMask = append(updateMask, "upgradePolicy") } @@ -1417,7 +1387,6 @@ func resourceGkeonpremVmwareClusterUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1465,8 +1434,6 @@ func resourceGkeonpremVmwareClusterDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting VmwareCluster %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1476,7 +1443,6 @@ func resourceGkeonpremVmwareClusterDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VmwareCluster") @@ -2280,10 +2246,6 @@ func flattenGkeonpremVmwareClusterEnableControlPlaneV2(v interface{}, d *schema. return v } -func flattenGkeonpremVmwareClusterDisableBundledIngress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenGkeonpremVmwareClusterUpgradePolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -3364,10 +3326,6 @@ func expandGkeonpremVmwareClusterEnableControlPlaneV2(v interface{}, d tpgresour return v, nil } -func expandGkeonpremVmwareClusterDisableBundledIngress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandGkeonpremVmwareClusterUpgradePolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go index 9ab00492f86..1b91dfd09e2 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/gkeonprem/resource_gkeonprem_vmware_node_pool.go @@ -20,7 +20,6 @@ package gkeonprem import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -411,7 +410,6 @@ func resourceGkeonpremVmwareNodePoolCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -420,7 +418,6 @@ func resourceGkeonpremVmwareNodePoolCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VmwareNodePool: %s", err) @@ -480,14 +477,12 @@ func resourceGkeonpremVmwareNodePoolRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("GkeonpremVmwareNodePool %q", d.Id())) @@ -590,7 +585,6 @@ func resourceGkeonpremVmwareNodePoolUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating VmwareNodePool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -630,7 +624,6 @@ func resourceGkeonpremVmwareNodePoolUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -678,8 +671,6 @@ func resourceGkeonpremVmwareNodePoolDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting VmwareNodePool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -689,7 +680,6 @@ func resourceGkeonpremVmwareNodePoolDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VmwareNodePool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_consent_store.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_consent_store.go index d3ff55d27b3..c1ee0c37a4a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_consent_store.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_consent_store.go @@ -20,7 +20,6 @@ package healthcare import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -160,7 +159,6 @@ func resourceHealthcareConsentStoreCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -169,7 +167,6 @@ func resourceHealthcareConsentStoreCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ConsentStore: %s", err) @@ -206,14 +203,12 @@ func resourceHealthcareConsentStoreRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("HealthcareConsentStore %q", d.Id())) @@ -273,7 +268,6 @@ func resourceHealthcareConsentStoreUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating ConsentStore %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("default_consent_ttl") { @@ -309,7 +303,6 @@ func resourceHealthcareConsentStoreUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -344,8 +337,6 @@ func resourceHealthcareConsentStoreDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ConsentStore %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -355,7 +346,6 @@ func resourceHealthcareConsentStoreDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ConsentStore") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dataset.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dataset.go index c424e7dbb3d..e84c54690f7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dataset.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dataset.go @@ -20,7 +20,6 @@ package healthcare import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -66,27 +65,6 @@ func ResourceHealthcareDataset() *schema.Resource { ForceNew: true, Description: `The resource name for the Dataset.`, }, - "encryption_spec": { - Type: schema.TypeList, - Computed: true, - Optional: true, - ForceNew: true, - Description: `A nested object resource`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "kms_key_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `KMS encryption key that is used to secure this dataset and its sub-resources. The key used for -encryption and the dataset must be in the same location. If empty, the default Google encryption -key will be used to secure this dataset. The format is -projects/{projectId}/locations/{locationId}/keyRings/{keyRingId}/cryptoKeys/{keyId}.`, - }, - }, - }, - }, "time_zone": { Type: schema.TypeString, Computed: true, @@ -131,12 +109,6 @@ func resourceHealthcareDatasetCreate(d *schema.ResourceData, meta interface{}) e } else if v, ok := d.GetOkExists("time_zone"); !tpgresource.IsEmptyValue(reflect.ValueOf(timeZoneProp)) && (ok || !reflect.DeepEqual(v, timeZoneProp)) { obj["timeZone"] = timeZoneProp } - encryptionSpecProp, err := expandHealthcareDatasetEncryptionSpec(d.Get("encryption_spec"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("encryption_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(encryptionSpecProp)) && (ok || !reflect.DeepEqual(v, encryptionSpecProp)) { - obj["encryptionSpec"] = encryptionSpecProp - } url, err := tpgresource.ReplaceVars(d, config, "{{HealthcareBasePath}}projects/{{project}}/locations/{{location}}/datasets?datasetId={{name}}") if err != nil { @@ -157,7 +129,6 @@ func resourceHealthcareDatasetCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -166,7 +137,6 @@ func resourceHealthcareDatasetCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.HealthcareDatasetNotInitialized}, }) if err != nil { @@ -210,14 +180,12 @@ func resourceHealthcareDatasetRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.HealthcareDatasetNotInitialized}, }) if err != nil { @@ -246,9 +214,6 @@ func resourceHealthcareDatasetRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("time_zone", flattenHealthcareDatasetTimeZone(res["timeZone"], d, config)); err != nil { return fmt.Errorf("Error reading Dataset: %s", err) } - if err := d.Set("encryption_spec", flattenHealthcareDatasetEncryptionSpec(res["encryptionSpec"], d, config)); err != nil { - return fmt.Errorf("Error reading Dataset: %s", err) - } return nil } @@ -282,7 +247,6 @@ func resourceHealthcareDatasetUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Dataset %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("time_zone") { @@ -310,7 +274,6 @@ func resourceHealthcareDatasetUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.HealthcareDatasetNotInitialized}, }) @@ -352,8 +315,6 @@ func resourceHealthcareDatasetDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Dataset %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -363,7 +324,6 @@ func resourceHealthcareDatasetDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.HealthcareDatasetNotInitialized}, }) if err != nil { @@ -402,23 +362,6 @@ func flattenHealthcareDatasetTimeZone(v interface{}, d *schema.ResourceData, con return v } -func flattenHealthcareDatasetEncryptionSpec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["kms_key_name"] = - flattenHealthcareDatasetEncryptionSpecKmsKeyName(original["kmsKeyName"], d, config) - return []interface{}{transformed} -} -func flattenHealthcareDatasetEncryptionSpecKmsKeyName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandHealthcareDatasetName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -427,29 +370,6 @@ func expandHealthcareDatasetTimeZone(v interface{}, d tpgresource.TerraformResou return v, nil } -func expandHealthcareDatasetEncryptionSpec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKmsKeyName, err := expandHealthcareDatasetEncryptionSpecKmsKeyName(original["kms_key_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKmsKeyName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["kmsKeyName"] = transformedKmsKeyName - } - - return transformed, nil -} - -func expandHealthcareDatasetEncryptionSpecKmsKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func resourceHealthcareDatasetDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { // Take the returned long form of the name and use it as `self_link`. // Then modify the name to be the user specified form. diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dicom_store.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dicom_store.go index 7c8e37cfc1c..1474712b186 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dicom_store.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_dicom_store.go @@ -20,7 +20,6 @@ package healthcare import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -108,11 +107,6 @@ was published. Notifications are only sent if the topic is non-empty. Topic name project. service-PROJECT_NUMBER@gcp-sa-healthcare.iam.gserviceaccount.com must have publisher permissions on the given Cloud Pub/Sub topic. Not having adequate permissions will cause the calls that send notifications to fail.`, }, - "send_for_bulk_import": { - Type: schema.TypeBool, - Optional: true, - Description: `Indicates whether or not to send Pub/Sub notifications on bulk import. Only supported for DICOM imports.`, - }, }, }, }, @@ -179,7 +173,6 @@ func resourceHealthcareDicomStoreCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -188,7 +181,6 @@ func resourceHealthcareDicomStoreCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DicomStore: %s", err) @@ -225,14 +217,12 @@ func resourceHealthcareDicomStoreRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("HealthcareDicomStore %q", d.Id())) @@ -298,7 +288,6 @@ func resourceHealthcareDicomStoreUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating DicomStore %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("notification_config") { @@ -330,7 +319,6 @@ func resourceHealthcareDicomStoreUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -365,8 +353,6 @@ func resourceHealthcareDicomStoreDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DicomStore %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -376,7 +362,6 @@ func resourceHealthcareDicomStoreDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DicomStore") @@ -435,18 +420,12 @@ func flattenHealthcareDicomStoreNotificationConfig(v interface{}, d *schema.Reso transformed := make(map[string]interface{}) transformed["pubsub_topic"] = flattenHealthcareDicomStoreNotificationConfigPubsubTopic(original["pubsubTopic"], d, config) - transformed["send_for_bulk_import"] = - flattenHealthcareDicomStoreNotificationConfigSendForBulkImport(original["sendForBulkImport"], d, config) return []interface{}{transformed} } func flattenHealthcareDicomStoreNotificationConfigPubsubTopic(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } -func flattenHealthcareDicomStoreNotificationConfigSendForBulkImport(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenHealthcareDicomStoreTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -486,13 +465,6 @@ func expandHealthcareDicomStoreNotificationConfig(v interface{}, d tpgresource.T transformed["pubsubTopic"] = transformedPubsubTopic } - transformedSendForBulkImport, err := expandHealthcareDicomStoreNotificationConfigSendForBulkImport(original["send_for_bulk_import"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSendForBulkImport); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sendForBulkImport"] = transformedSendForBulkImport - } - return transformed, nil } @@ -500,10 +472,6 @@ func expandHealthcareDicomStoreNotificationConfigPubsubTopic(v interface{}, d tp return v, nil } -func expandHealthcareDicomStoreNotificationConfigSendForBulkImport(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandHealthcareDicomStoreEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_fhir_store.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_fhir_store.go index 656d3630359..ae6b55c2866 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_fhir_store.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_fhir_store.go @@ -20,7 +20,6 @@ package healthcare import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -163,7 +162,6 @@ Please refer to the field 'effective_labels' for all of the labels present on th "notification_config": { Type: schema.TypeList, Optional: true, - Deprecated: "`notification_config` is deprecated and will be removed in a future major release. Use `notification_configs` instead.", Description: `A nested object resource`, MaxItems: 1, Elem: &schema.Resource{ @@ -181,43 +179,6 @@ Cloud Pub/Sub topic. Not having adequate permissions will cause the calls that s }, }, }, - "notification_configs": { - Type: schema.TypeList, - Optional: true, - Description: `A list of notifcation configs that configure the notification for every resource mutation in this FHIR store.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pubsub_topic": { - Type: schema.TypeString, - Required: true, - Description: `The Cloud Pub/Sub topic that notifications of changes are published on. Supplied by the client. -PubsubMessage.Data will contain the resource name. PubsubMessage.MessageId is the ID of this message. -It is guaranteed to be unique within the topic. PubsubMessage.PublishTime is the time at which the message -was published. Notifications are only sent if the topic is non-empty. Topic names must be scoped to a -project. service-PROJECT_NUMBER@gcp-sa-healthcare.iam.gserviceaccount.com must have publisher permissions on the given -Cloud Pub/Sub topic. Not having adequate permissions will cause the calls that send notifications to fail.`, - }, - "send_full_resource": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether to send full FHIR resource to this Pub/Sub topic for Create and Update operation. -Note that setting this to true does not guarantee that all resources will be sent in the format of -full FHIR resource. When a resource change is too large or during heavy traffic, only the resource name will be -sent. Clients should always check the "payloadType" label from a Pub/Sub message to determine whether -it needs to fetch the full resource as a separate operation.`, - }, - "send_previous_resource_on_delete": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether to send full FHIR resource to this Pub/Sub topic for deleting FHIR resource. Note that setting this to -true does not guarantee that all previous resources will be sent in the format of full FHIR resource. When a -resource change is too large or during heavy traffic, only the resource name will be sent. Clients should always -check the "payloadType" label from a Pub/Sub message to determine whether it needs to fetch the full previous -resource as a separate operation.`, - }, - }, - }, - }, "stream_configs": { Type: schema.TypeList, Optional: true, @@ -402,12 +363,6 @@ func resourceHealthcareFhirStoreCreate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("default_search_handling_strict"); !tpgresource.IsEmptyValue(reflect.ValueOf(defaultSearchHandlingStrictProp)) && (ok || !reflect.DeepEqual(v, defaultSearchHandlingStrictProp)) { obj["defaultSearchHandlingStrict"] = defaultSearchHandlingStrictProp } - notificationConfigsProp, err := expandHealthcareFhirStoreNotificationConfigs(d.Get("notification_configs"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("notification_configs"); !tpgresource.IsEmptyValue(reflect.ValueOf(notificationConfigsProp)) && (ok || !reflect.DeepEqual(v, notificationConfigsProp)) { - obj["notificationConfigs"] = notificationConfigsProp - } labelsProp, err := expandHealthcareFhirStoreEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -428,7 +383,6 @@ func resourceHealthcareFhirStoreCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -437,7 +391,6 @@ func resourceHealthcareFhirStoreCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FhirStore: %s", err) @@ -474,14 +427,12 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("HealthcareFhirStore %q", d.Id())) @@ -532,9 +483,6 @@ func resourceHealthcareFhirStoreRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("default_search_handling_strict", flattenHealthcareFhirStoreDefaultSearchHandlingStrict(res["defaultSearchHandlingStrict"], d, config)); err != nil { return fmt.Errorf("Error reading FhirStore: %s", err) } - if err := d.Set("notification_configs", flattenHealthcareFhirStoreNotificationConfigs(res["notificationConfigs"], d, config)); err != nil { - return fmt.Errorf("Error reading FhirStore: %s", err) - } if err := d.Set("terraform_labels", flattenHealthcareFhirStoreTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading FhirStore: %s", err) } @@ -585,12 +533,6 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("default_search_handling_strict"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, defaultSearchHandlingStrictProp)) { obj["defaultSearchHandlingStrict"] = defaultSearchHandlingStrictProp } - notificationConfigsProp, err := expandHealthcareFhirStoreNotificationConfigs(d.Get("notification_configs"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("notification_configs"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, notificationConfigsProp)) { - obj["notificationConfigs"] = notificationConfigsProp - } labelsProp, err := expandHealthcareFhirStoreEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -604,7 +546,6 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating FhirStore %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("complex_data_type_reference_parsing") { @@ -627,10 +568,6 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) updateMask = append(updateMask, "defaultSearchHandlingStrict") } - if d.HasChange("notification_configs") { - updateMask = append(updateMask, "notificationConfigs") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -656,7 +593,6 @@ func resourceHealthcareFhirStoreUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -691,8 +627,6 @@ func resourceHealthcareFhirStoreDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FhirStore %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -702,7 +636,6 @@ func resourceHealthcareFhirStoreDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FhirStore") @@ -898,38 +831,6 @@ func flattenHealthcareFhirStoreDefaultSearchHandlingStrict(v interface{}, d *sch return v } -func flattenHealthcareFhirStoreNotificationConfigs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "pubsub_topic": flattenHealthcareFhirStoreNotificationConfigsPubsubTopic(original["pubsubTopic"], d, config), - "send_full_resource": flattenHealthcareFhirStoreNotificationConfigsSendFullResource(original["sendFullResource"], d, config), - "send_previous_resource_on_delete": flattenHealthcareFhirStoreNotificationConfigsSendPreviousResourceOnDelete(original["sendPreviousResourceOnDelete"], d, config), - }) - } - return transformed -} -func flattenHealthcareFhirStoreNotificationConfigsPubsubTopic(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenHealthcareFhirStoreNotificationConfigsSendFullResource(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenHealthcareFhirStoreNotificationConfigsSendPreviousResourceOnDelete(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenHealthcareFhirStoreTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -1142,54 +1043,6 @@ func expandHealthcareFhirStoreDefaultSearchHandlingStrict(v interface{}, d tpgre return v, nil } -func expandHealthcareFhirStoreNotificationConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPubsubTopic, err := expandHealthcareFhirStoreNotificationConfigsPubsubTopic(original["pubsub_topic"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPubsubTopic); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["pubsubTopic"] = transformedPubsubTopic - } - - transformedSendFullResource, err := expandHealthcareFhirStoreNotificationConfigsSendFullResource(original["send_full_resource"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSendFullResource); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sendFullResource"] = transformedSendFullResource - } - - transformedSendPreviousResourceOnDelete, err := expandHealthcareFhirStoreNotificationConfigsSendPreviousResourceOnDelete(original["send_previous_resource_on_delete"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSendPreviousResourceOnDelete); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["sendPreviousResourceOnDelete"] = transformedSendPreviousResourceOnDelete - } - - req = append(req, transformed) - } - return req, nil -} - -func expandHealthcareFhirStoreNotificationConfigsPubsubTopic(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandHealthcareFhirStoreNotificationConfigsSendFullResource(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandHealthcareFhirStoreNotificationConfigsSendPreviousResourceOnDelete(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandHealthcareFhirStoreEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_hl7_v2_store.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_hl7_v2_store.go index 2b8c769bd0e..0fb464e8871 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_hl7_v2_store.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/healthcare/resource_healthcare_hl7_v2_store.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -283,7 +282,6 @@ func resourceHealthcareHl7V2StoreCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -292,7 +290,6 @@ func resourceHealthcareHl7V2StoreCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Hl7V2Store: %s", err) @@ -329,14 +326,12 @@ func resourceHealthcareHl7V2StoreRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("HealthcareHl7V2Store %q", d.Id())) @@ -429,7 +424,6 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Hl7V2Store %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("reject_duplicate_message") { @@ -475,7 +469,6 @@ func resourceHealthcareHl7V2StoreUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -510,8 +503,6 @@ func resourceHealthcareHl7V2StoreDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Hl7V2Store %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -521,7 +512,6 @@ func resourceHealthcareHl7V2StoreDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Hl7V2Store") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_access_boundary_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_access_boundary_policy.go index 1610d39f390..a0bbf3c1af6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_access_boundary_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_access_boundary_policy.go @@ -20,7 +20,6 @@ package iam2 import ( "fmt" "log" - "net/http" "reflect" "time" @@ -185,7 +184,6 @@ func resourceIAM2AccessBoundaryPolicyCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -194,7 +192,6 @@ func resourceIAM2AccessBoundaryPolicyCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AccessBoundaryPolicy: %s", err) @@ -241,14 +238,12 @@ func resourceIAM2AccessBoundaryPolicyRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IAM2AccessBoundaryPolicy %q", d.Id())) @@ -302,7 +297,6 @@ func resourceIAM2AccessBoundaryPolicyUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating AccessBoundaryPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -317,7 +311,6 @@ func resourceIAM2AccessBoundaryPolicyUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -358,8 +351,6 @@ func resourceIAM2AccessBoundaryPolicyDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AccessBoundaryPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -369,7 +360,6 @@ func resourceIAM2AccessBoundaryPolicyDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AccessBoundaryPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_deny_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_deny_policy.go index 6be7800eb85..c1f4f52bdea 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_deny_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iam2/resource_iam_deny_policy.go @@ -20,7 +20,6 @@ package iam2 import ( "fmt" "log" - "net/http" "reflect" "time" @@ -208,7 +207,6 @@ func resourceIAM2DenyPolicyCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -217,7 +215,6 @@ func resourceIAM2DenyPolicyCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DenyPolicy: %s", err) @@ -264,14 +261,12 @@ func resourceIAM2DenyPolicyRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IAM2DenyPolicy %q", d.Id())) @@ -325,7 +320,6 @@ func resourceIAM2DenyPolicyUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating DenyPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -340,7 +334,6 @@ func resourceIAM2DenyPolicyUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -381,8 +374,6 @@ func resourceIAM2DenyPolicyDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DenyPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -392,7 +383,6 @@ func resourceIAM2DenyPolicyDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DenyPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_workload_identity_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_beta_workload_identity_pool.go similarity index 100% rename from terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_workload_identity_pool.go rename to terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_beta_workload_identity_pool.go diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_workload_identity_pool_provider.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_beta_workload_identity_pool_provider.go similarity index 100% rename from terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_workload_identity_pool_provider.go rename to terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/data_source_iam_beta_workload_identity_pool_provider.go diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool.go index 7d097726c1f..aa83adee3b4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool.go @@ -20,7 +20,6 @@ package iambeta import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -185,7 +184,6 @@ func resourceIAMBetaWorkloadIdentityPoolCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -194,7 +192,6 @@ func resourceIAMBetaWorkloadIdentityPoolCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating WorkloadIdentityPool: %s", err) @@ -247,14 +244,12 @@ func resourceIAMBetaWorkloadIdentityPoolRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IAMBetaWorkloadIdentityPool %q", d.Id())) @@ -336,7 +331,6 @@ func resourceIAMBetaWorkloadIdentityPoolUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating WorkloadIdentityPool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -372,7 +366,6 @@ func resourceIAMBetaWorkloadIdentityPoolUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -420,8 +413,6 @@ func resourceIAMBetaWorkloadIdentityPoolDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting WorkloadIdentityPool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -431,7 +422,6 @@ func resourceIAMBetaWorkloadIdentityPoolDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "WorkloadIdentityPool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool_provider.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool_provider.go index c1fcde21c1a..af84504d0fa 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool_provider.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iambeta/resource_iam_workload_identity_pool_provider.go @@ -20,7 +20,6 @@ package iambeta import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -402,7 +401,6 @@ func resourceIAMBetaWorkloadIdentityPoolProviderCreate(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -411,7 +409,6 @@ func resourceIAMBetaWorkloadIdentityPoolProviderCreate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating WorkloadIdentityPoolProvider: %s", err) @@ -464,14 +461,12 @@ func resourceIAMBetaWorkloadIdentityPoolProviderRead(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IAMBetaWorkloadIdentityPoolProvider %q", d.Id())) @@ -598,7 +593,6 @@ func resourceIAMBetaWorkloadIdentityPoolProviderUpdate(d *schema.ResourceData, m } log.Printf("[DEBUG] Updating WorkloadIdentityPoolProvider %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -656,7 +650,6 @@ func resourceIAMBetaWorkloadIdentityPoolProviderUpdate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -704,8 +697,6 @@ func resourceIAMBetaWorkloadIdentityPoolProviderDelete(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting WorkloadIdentityPoolProvider %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -715,7 +706,6 @@ func resourceIAMBetaWorkloadIdentityPoolProviderDelete(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "WorkloadIdentityPoolProvider") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool.go index 72227a0bb8c..3d97acde37d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool.go @@ -20,7 +20,6 @@ package iamworkforcepool import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -235,7 +234,6 @@ func resourceIAMWorkforcePoolWorkforcePoolCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -244,7 +242,6 @@ func resourceIAMWorkforcePoolWorkforcePoolCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating WorkforcePool: %s", err) @@ -291,14 +288,12 @@ func resourceIAMWorkforcePoolWorkforcePoolRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IAMWorkforcePoolWorkforcePool %q", d.Id())) @@ -385,7 +380,6 @@ func resourceIAMWorkforcePoolWorkforcePoolUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating WorkforcePool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -425,7 +419,6 @@ func resourceIAMWorkforcePoolWorkforcePoolUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -467,8 +460,6 @@ func resourceIAMWorkforcePoolWorkforcePoolDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting WorkforcePool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -478,7 +469,6 @@ func resourceIAMWorkforcePoolWorkforcePoolDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "WorkforcePool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go index 353e494235b..f3b6edf5bb8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool/resource_iam_workforce_pool_provider.go @@ -20,7 +20,6 @@ package iamworkforcepool import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -190,88 +189,6 @@ However, existing tokens still grant access.`, Optional: true, Description: `A user-specified display name for the provider. Cannot exceed 32 characters.`, }, - "extra_attributes_oauth2_client": { - Type: schema.TypeList, - Optional: true, - Description: `The configuration for OAuth 2.0 client used to get the additional user -attributes. This should be used when users can't get the desired claims -in authentication credentials. Currently this configuration is only -supported with OIDC protocol.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "attributes_type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"AZURE_AD_GROUPS_MAIL"}), - Description: `Represents the IdP and type of claims that should be fetched. -* AZURE_AD_GROUPS_MAIL: Used to get the user's group claims from the Azure AD identity provider using configuration provided -in ExtraAttributesOAuth2Client and 'mail' property of the 'microsoft.graph.group' object is used for claim mapping. -See https://learn.microsoft.com/en-us/graph/api/resources/group?view=graph-rest-1.0#properties for more details on -'microsoft.graph.group' properties. The attributes obtained from idntity provider are mapped to 'assertion.groups'. Possible values: ["AZURE_AD_GROUPS_MAIL"]`, - }, - "client_id": { - Type: schema.TypeString, - Required: true, - Description: `The OAuth 2.0 client ID for retrieving extra attributes from the identity provider. Required to get the Access Token using client credentials grant flow.`, - }, - "client_secret": { - Type: schema.TypeList, - Required: true, - Description: `The OAuth 2.0 client secret for retrieving extra attributes from the identity provider. Required to get the Access Token using client credentials grant flow.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "value": { - Type: schema.TypeList, - Optional: true, - Description: `The value of the client secret.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "plain_text": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - Description: `The plain text of the client secret value.`, - }, - "thumbprint": { - Type: schema.TypeString, - Computed: true, - Description: `A thumbprint to represent the current client secret value.`, - }, - }, - }, - ExactlyOneOf: []string{"extra_attributes_oauth2_client.0.client_secret.0.value"}, - }, - }, - }, - }, - "issuer_uri": { - Type: schema.TypeString, - Required: true, - Description: `The OIDC identity provider's issuer URI. Must be a valid URI using the 'https' scheme. Required to get the OIDC discovery document.`, - }, - "query_parameters": { - Type: schema.TypeList, - Optional: true, - Description: `Represents the parameters to control which claims are fetched from an IdP.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "filter": { - Type: schema.TypeString, - Optional: true, - Description: `The filter used to request specific records from IdP. In case of attributes type as AZURE_AD_GROUPS_MAIL, it represents the -filter used to request specific groups for users from IdP. By default, all of the groups associated with the user are fetched. The -groups should be mail enabled and security enabled. See https://learn.microsoft.com/en-us/graph/search-query-parameter for more details.`, - }, - }, - }, - }, - }, - }, - }, "oidc": { Type: schema.TypeList, Optional: true, @@ -492,12 +409,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderCreate(d *schema.ResourceData, } else if v, ok := d.GetOkExists("oidc"); !tpgresource.IsEmptyValue(reflect.ValueOf(oidcProp)) && (ok || !reflect.DeepEqual(v, oidcProp)) { obj["oidc"] = oidcProp } - extraAttributesOauth2ClientProp, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2Client(d.Get("extra_attributes_oauth2_client"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("extra_attributes_oauth2_client"); !tpgresource.IsEmptyValue(reflect.ValueOf(extraAttributesOauth2ClientProp)) && (ok || !reflect.DeepEqual(v, extraAttributesOauth2ClientProp)) { - obj["extraAttributesOauth2Client"] = extraAttributesOauth2ClientProp - } url, err := tpgresource.ReplaceVars(d, config, "{{IAMWorkforcePoolBasePath}}locations/{{location}}/workforcePools/{{workforce_pool_id}}/providers?workforcePoolProviderId={{provider_id}}") if err != nil { @@ -512,7 +423,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -521,7 +431,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating WorkforcePoolProvider: %s", err) @@ -544,37 +453,20 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderCreate(d *schema.ResourceData, return fmt.Errorf("Error waiting to create WorkforcePoolProvider: %s", err) } - createdOidcClientSecret := d.Get("oidc.0.client_secret.0.value.0.plain_text") - createdExtraAttributesClientSecret := d.Get("extra_attributes_oauth2_client.0.client_secret.0.value.0.plain_text") - - if (createdOidcClientSecret != nil && createdOidcClientSecret != "") || (createdExtraAttributesClientSecret != nil && createdExtraAttributesClientSecret != "") { + createdClientSecret := d.Get("oidc.0.client_secret.0.value.0.plain_text") + if createdClientSecret != nil && createdClientSecret != "" { // After the create, reading from the API returns a new thumbprint // for the client secret value, which clears the plain_text. We set the plain_text since // this case should not warrant a diff. if err := resourceIAMWorkforcePoolWorkforcePoolProviderRead(d, meta); err != nil { return err } - - // Populate ExtraAttributesOauth2Client the client secret plain text - if createdExtraAttributesClientSecret != nil && createdExtraAttributesClientSecret != "" { - extraAttributesOauth2Client := d.Get("extra_attributes_oauth2_client") - clientSecret := extraAttributesOauth2Client.([]interface{})[0].(map[string]interface{})["client_secret"] - clientSecretValue := clientSecret.([]interface{})[0].(map[string]interface{})["value"] - clientSecretValue.([]interface{})[0].(map[string]interface{})["plain_text"] = createdExtraAttributesClientSecret - if err := d.Set("extra_attributes_oauth2_client", extraAttributesOauth2Client); err != nil { - return err - } - } - - // Populate OIDC the client secret plain text - if createdOidcClientSecret != nil && createdOidcClientSecret != "" { - oidc := d.Get("oidc") - clientSecret := oidc.([]interface{})[0].(map[string]interface{})["client_secret"] - clientSecretValue := clientSecret.([]interface{})[0].(map[string]interface{})["value"] - clientSecretValue.([]interface{})[0].(map[string]interface{})["plain_text"] = createdOidcClientSecret - if err := d.Set("oidc", oidc); err != nil { - return err - } + oidc := d.Get("oidc") + clientSecret := oidc.([]interface{})[0].(map[string]interface{})["client_secret"] + clientSecretValue := clientSecret.([]interface{})[0].(map[string]interface{})["value"] + clientSecretValue.([]interface{})[0].(map[string]interface{})["plain_text"] = createdClientSecret + if err := d.Set("oidc", oidc); err != nil { + return err } return nil } @@ -603,14 +495,12 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderRead(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IAMWorkforcePoolWorkforcePoolProvider %q", d.Id())) @@ -655,9 +545,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderRead(d *schema.ResourceData, m if err := d.Set("oidc", flattenIAMWorkforcePoolWorkforcePoolProviderOidc(res["oidc"], d, config)); err != nil { return fmt.Errorf("Error reading WorkforcePoolProvider: %s", err) } - if err := d.Set("extra_attributes_oauth2_client", flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2Client(res["extraAttributesOauth2Client"], d, config)); err != nil { - return fmt.Errorf("Error reading WorkforcePoolProvider: %s", err) - } return nil } @@ -714,12 +601,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, } else if v, ok := d.GetOkExists("oidc"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, oidcProp)) { obj["oidc"] = oidcProp } - extraAttributesOauth2ClientProp, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2Client(d.Get("extra_attributes_oauth2_client"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("extra_attributes_oauth2_client"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, extraAttributesOauth2ClientProp)) { - obj["extraAttributesOauth2Client"] = extraAttributesOauth2ClientProp - } url, err := tpgresource.ReplaceVars(d, config, "{{IAMWorkforcePoolBasePath}}locations/{{location}}/workforcePools/{{workforce_pool_id}}/providers/{{provider_id}}") if err != nil { @@ -727,7 +608,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating WorkforcePoolProvider %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -757,10 +637,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, if d.HasChange("oidc") { updateMask = append(updateMask, "oidc") } - - if d.HasChange("extra_attributes_oauth2_client") { - updateMask = append(updateMask, "extraAttributesOauth2Client") - } // updateMask is a URL parameter but not present in the schema, so ReplaceVars // won't set it url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) @@ -783,7 +659,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -801,36 +676,24 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderUpdate(d *schema.ResourceData, } } - if d.HasChange("oidc") || d.HasChange("extra_attributes_oauth2_client") { - updatedOidcClientSecret := d.Get("oidc.0.client_secret.0.value.0.plain_text") - updatedExtraAttributesOauth2ClientSecret := d.Get("extra_attributes_oauth2_client.0.client_secret.0.value.0.plain_text") - // After the update, reading from the API returns a different thumbprint - // for the client secret value, which clears the plain_text. We set the plain_text since - // this case should not warrant a diff. - if err := resourceIAMWorkforcePoolWorkforcePoolProviderRead(d, meta); err != nil { - return err - } - - if updatedOidcClientSecret != nil && updatedOidcClientSecret != "" { + if d.HasChange("oidc") { + updatedClientSecret := d.Get("oidc.0.client_secret.0.value.0.plain_text") + if updatedClientSecret != nil && updatedClientSecret != "" { + // After the update, reading from the API returns a different thumbprint + // for the client secret value, which clears the plain_text. We set the plain_text since + // this case should not warrant a diff. + if err := resourceIAMWorkforcePoolWorkforcePoolProviderRead(d, meta); err != nil { + return err + } oidc := d.Get("oidc") clientSecret := oidc.([]interface{})[0].(map[string]interface{})["client_secret"] clientSecretValue := clientSecret.([]interface{})[0].(map[string]interface{})["value"] - clientSecretValue.([]interface{})[0].(map[string]interface{})["plain_text"] = updatedOidcClientSecret + clientSecretValue.([]interface{})[0].(map[string]interface{})["plain_text"] = updatedClientSecret if err := d.Set("oidc", oidc); err != nil { return err } + return nil } - - if updatedExtraAttributesOauth2ClientSecret != nil && updatedExtraAttributesOauth2ClientSecret != "" { - extraAttributesOauth2Client := d.Get("extra_attributes_oauth2_client") - clientSecret := extraAttributesOauth2Client.([]interface{})[0].(map[string]interface{})["client_secret"] - clientSecretValue := clientSecret.([]interface{})[0].(map[string]interface{})["value"] - clientSecretValue.([]interface{})[0].(map[string]interface{})["plain_text"] = updatedExtraAttributesOauth2ClientSecret - if err := d.Set("extra_attributes_oauth2_client", extraAttributesOauth2Client); err != nil { - return err - } - } - return nil } return resourceIAMWorkforcePoolWorkforcePoolProviderRead(d, meta) } @@ -856,8 +719,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting WorkforcePoolProvider %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -867,7 +728,6 @@ func resourceIAMWorkforcePoolWorkforcePoolProviderDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "WorkforcePoolProvider") @@ -1042,87 +902,6 @@ func flattenIAMWorkforcePoolWorkforcePoolProviderOidcJwksJson(v interface{}, d * return v } -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2Client(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["issuer_uri"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientIssuerUri(original["issuerUri"], d, config) - transformed["client_id"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientId(original["clientId"], d, config) - transformed["client_secret"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecret(original["clientSecret"], d, config) - transformed["attributes_type"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientAttributesType(original["attributesType"], d, config) - transformed["query_parameters"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParameters(original["queryParameters"], d, config) - return []interface{}{transformed} -} -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientIssuerUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecret(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["value"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValue(original["value"], d, config) - return []interface{}{transformed} -} -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["thumbprint"] = original["thumbprint"] - // Trigger a diff based on the plain_text if there is no change in the thumbprint, - // otherwise leave plain_text empty to always trigger a diff. - if original["thumbprint"].(string) == d.Get("extra_attributes_oauth2_client.0.client_secret.0.value.0.thumbprint").(string) { - transformed["plain_text"] = d.Get("extra_attributes_oauth2_client.0.client_secret.0.value.0.plain_text") - } - return []interface{}{transformed} -} - -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientAttributesType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParameters(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["filter"] = - flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParametersFilter(original["filter"], d, config) - return []interface{}{transformed} -} -func flattenIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParametersFilter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandIAMWorkforcePoolWorkforcePoolProviderDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1330,141 +1109,6 @@ func expandIAMWorkforcePoolWorkforcePoolProviderOidcJwksJson(v interface{}, d tp return v, nil } -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2Client(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedIssuerUri, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientIssuerUri(original["issuer_uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedIssuerUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["issuerUri"] = transformedIssuerUri - } - - transformedClientId, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientId(original["client_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedClientId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["clientId"] = transformedClientId - } - - transformedClientSecret, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecret(original["client_secret"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedClientSecret); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["clientSecret"] = transformedClientSecret - } - - transformedAttributesType, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientAttributesType(original["attributes_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAttributesType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["attributesType"] = transformedAttributesType - } - - transformedQueryParameters, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParameters(original["query_parameters"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedQueryParameters); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["queryParameters"] = transformedQueryParameters - } - - return transformed, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientIssuerUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecret(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedValue, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["value"] = transformedValue - } - - return transformed, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPlainText, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValuePlainText(original["plain_text"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPlainText); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["plainText"] = transformedPlainText - } - - transformedThumbprint, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValueThumbprint(original["thumbprint"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedThumbprint); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["thumbprint"] = transformedThumbprint - } - - return transformed, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValuePlainText(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientClientSecretValueThumbprint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientAttributesType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParameters(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedFilter, err := expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParametersFilter(original["filter"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFilter); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["filter"] = transformedFilter - } - - return transformed, nil -} - -func expandIAMWorkforcePoolWorkforcePoolProviderExtraAttributesOauth2ClientQueryParametersFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func resourceIAMWorkforcePoolWorkforcePoolProviderDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { if v := res["state"]; v == "DELETED" { return nil, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_brand.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_brand.go index 8b57193d6f7..2eba4137cc0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_brand.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_brand.go @@ -20,7 +20,6 @@ package iap import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -132,7 +131,6 @@ func resourceIapBrandCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -141,7 +139,6 @@ func resourceIapBrandCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Brand: %s", err) @@ -252,14 +249,12 @@ func resourceIapBrandRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IapBrand %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_client.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_client.go index b521e33ee1a..0141b32b7f3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_client.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_client.go @@ -20,7 +20,6 @@ package iap import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -105,7 +104,6 @@ func resourceIapClientCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -114,7 +112,6 @@ func resourceIapClientCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IapClient409Operation}, }) if err != nil { @@ -160,14 +157,12 @@ func resourceIapClientRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IapClient409Operation}, }) if err != nil { @@ -208,8 +203,6 @@ func resourceIapClientDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Client %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -219,7 +212,6 @@ func resourceIapClientDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IapClient409Operation}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_tunnel_dest_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_tunnel_dest_group.go index c137e66a1ff..7a2ef915e3e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_tunnel_dest_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/iap/resource_iap_tunnel_dest_group.go @@ -20,7 +20,6 @@ package iap import ( "fmt" "log" - "net/http" "reflect" "time" @@ -138,7 +137,6 @@ func resourceIapTunnelDestGroupCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -147,7 +145,6 @@ func resourceIapTunnelDestGroupCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TunnelDestGroup: %s", err) @@ -193,14 +190,12 @@ func resourceIapTunnelDestGroupRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IapTunnelDestGroup %q", d.Id())) @@ -258,7 +253,6 @@ func resourceIapTunnelDestGroupUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating TunnelDestGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -273,7 +267,6 @@ func resourceIapTunnelDestGroupUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -312,8 +305,6 @@ func resourceIapTunnelDestGroupDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TunnelDestGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -323,7 +314,6 @@ func resourceIapTunnelDestGroupDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TunnelDestGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_config.go index a5bc861d092..bcceaaefc25 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -421,7 +420,6 @@ email/password or email link.`, }, "sms_region_config": { Type: schema.TypeList, - Computed: true, Optional: true, Description: `Configures the regions where users are allowed to send verification SMS for the project or tenant. This is based on the calling code of the destination phone number.`, MaxItems: 1, @@ -566,14 +564,12 @@ func resourceIdentityPlatformConfigRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformConfig %q", d.Id())) @@ -703,7 +699,6 @@ func resourceIdentityPlatformConfigUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating Config %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("autodelete_anonymous_users") { @@ -767,7 +762,6 @@ func resourceIdentityPlatformConfigUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go index 8a1fdc98677..7a5d1d8280c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_default_supported_idp_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -157,7 +156,6 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigCreate(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -166,7 +164,6 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigCreate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DefaultSupportedIdpConfig: %s", err) @@ -212,14 +209,12 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigRead(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformDefaultSupportedIdpConfig %q", d.Id())) @@ -286,7 +281,6 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigUpdate(d *schema.ResourceD } log.Printf("[DEBUG] Updating DefaultSupportedIdpConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("client_id") { @@ -322,7 +316,6 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigUpdate(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -363,8 +356,6 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigDelete(d *schema.ResourceD billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DefaultSupportedIdpConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -374,7 +365,6 @@ func resourceIdentityPlatformDefaultSupportedIdpConfigDelete(d *schema.ResourceD UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DefaultSupportedIdpConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go index b8f88abfb6a..4d62efb1545 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_inbound_saml_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -215,7 +214,6 @@ func resourceIdentityPlatformInboundSamlConfigCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -224,7 +222,6 @@ func resourceIdentityPlatformInboundSamlConfigCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating InboundSamlConfig: %s", err) @@ -267,14 +264,12 @@ func resourceIdentityPlatformInboundSamlConfigRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformInboundSamlConfig %q", d.Id())) @@ -350,7 +345,6 @@ func resourceIdentityPlatformInboundSamlConfigUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating InboundSamlConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -390,7 +384,6 @@ func resourceIdentityPlatformInboundSamlConfigUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -431,8 +424,6 @@ func resourceIdentityPlatformInboundSamlConfigDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting InboundSamlConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -442,7 +433,6 @@ func resourceIdentityPlatformInboundSamlConfigDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "InboundSamlConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go index da33f880a7a..e4896b36ec9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_oauth_idp_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -160,7 +159,6 @@ func resourceIdentityPlatformOauthIdpConfigCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -169,7 +167,6 @@ func resourceIdentityPlatformOauthIdpConfigCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating OauthIdpConfig: %s", err) @@ -212,14 +209,12 @@ func resourceIdentityPlatformOauthIdpConfigRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformOauthIdpConfig %q", d.Id())) @@ -304,7 +299,6 @@ func resourceIdentityPlatformOauthIdpConfigUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating OauthIdpConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -348,7 +342,6 @@ func resourceIdentityPlatformOauthIdpConfigUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -389,8 +382,6 @@ func resourceIdentityPlatformOauthIdpConfigDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting OauthIdpConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -400,7 +391,6 @@ func resourceIdentityPlatformOauthIdpConfigDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "OauthIdpConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_project_default_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_project_default_config.go index f33f61bb41f..e4f5f197295 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_project_default_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_project_default_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -213,7 +212,6 @@ func resourceIdentityPlatformProjectDefaultConfigCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -222,7 +220,6 @@ func resourceIdentityPlatformProjectDefaultConfigCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ProjectDefaultConfig: %s", err) @@ -268,14 +265,12 @@ func resourceIdentityPlatformProjectDefaultConfigRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformProjectDefaultConfig %q", d.Id())) @@ -324,7 +319,6 @@ func resourceIdentityPlatformProjectDefaultConfigUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating ProjectDefaultConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("sign_in") { @@ -352,7 +346,6 @@ func resourceIdentityPlatformProjectDefaultConfigUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -393,8 +386,6 @@ func resourceIdentityPlatformProjectDefaultConfigDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ProjectDefaultConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -404,7 +395,6 @@ func resourceIdentityPlatformProjectDefaultConfigDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ProjectDefaultConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant.go index 9b8dc949a20..159b3ced210 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -144,7 +143,6 @@ func resourceIdentityPlatformTenantCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -153,7 +151,6 @@ func resourceIdentityPlatformTenantCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Tenant: %s", err) @@ -214,14 +211,12 @@ func resourceIdentityPlatformTenantRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformTenant %q", d.Id())) @@ -297,7 +292,6 @@ func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating Tenant %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -337,7 +331,6 @@ func resourceIdentityPlatformTenantUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -378,8 +371,6 @@ func resourceIdentityPlatformTenantDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Tenant %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -389,7 +380,6 @@ func resourceIdentityPlatformTenantDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Tenant") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go index 2efc6ef4286..ec0263b5186 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_default_supported_idp_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -163,7 +162,6 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigCreate(d *schema.Res billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -172,7 +170,6 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigCreate(d *schema.Res UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TenantDefaultSupportedIdpConfig: %s", err) @@ -218,14 +215,12 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigRead(d *schema.Resou billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformTenantDefaultSupportedIdpConfig %q", d.Id())) @@ -292,7 +287,6 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigUpdate(d *schema.Res } log.Printf("[DEBUG] Updating TenantDefaultSupportedIdpConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("client_id") { @@ -328,7 +322,6 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigUpdate(d *schema.Res UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -369,8 +362,6 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigDelete(d *schema.Res billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TenantDefaultSupportedIdpConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -380,7 +371,6 @@ func resourceIdentityPlatformTenantDefaultSupportedIdpConfigDelete(d *schema.Res UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TenantDefaultSupportedIdpConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go index 178a4cc1187..38c563e21cf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_inbound_saml_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -221,7 +220,6 @@ func resourceIdentityPlatformTenantInboundSamlConfigCreate(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -230,7 +228,6 @@ func resourceIdentityPlatformTenantInboundSamlConfigCreate(d *schema.ResourceDat UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TenantInboundSamlConfig: %s", err) @@ -273,14 +270,12 @@ func resourceIdentityPlatformTenantInboundSamlConfigRead(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformTenantInboundSamlConfig %q", d.Id())) @@ -356,7 +351,6 @@ func resourceIdentityPlatformTenantInboundSamlConfigUpdate(d *schema.ResourceDat } log.Printf("[DEBUG] Updating TenantInboundSamlConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -396,7 +390,6 @@ func resourceIdentityPlatformTenantInboundSamlConfigUpdate(d *schema.ResourceDat UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -437,8 +430,6 @@ func resourceIdentityPlatformTenantInboundSamlConfigDelete(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TenantInboundSamlConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -448,7 +439,6 @@ func resourceIdentityPlatformTenantInboundSamlConfigDelete(d *schema.ResourceDat UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TenantInboundSamlConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go index 12f4c23b092..36c767b5b42 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/identityplatform/resource_identity_platform_tenant_oauth_idp_config.go @@ -20,7 +20,6 @@ package identityplatform import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -166,7 +165,6 @@ func resourceIdentityPlatformTenantOauthIdpConfigCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -175,7 +173,6 @@ func resourceIdentityPlatformTenantOauthIdpConfigCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TenantOauthIdpConfig: %s", err) @@ -218,14 +215,12 @@ func resourceIdentityPlatformTenantOauthIdpConfigRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IdentityPlatformTenantOauthIdpConfig %q", d.Id())) @@ -310,7 +305,6 @@ func resourceIdentityPlatformTenantOauthIdpConfigUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating TenantOauthIdpConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -354,7 +348,6 @@ func resourceIdentityPlatformTenantOauthIdpConfigUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -395,8 +388,6 @@ func resourceIdentityPlatformTenantOauthIdpConfigDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TenantOauthIdpConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -406,7 +397,6 @@ func resourceIdentityPlatformTenantOauthIdpConfigDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TenantOauthIdpConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_connection.go index c2f9cf33168..1ecb5325744 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_connection.go @@ -20,13 +20,12 @@ package integrationconnectors import ( "fmt" "log" - "net/http" "reflect" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -37,16 +36,16 @@ import ( // waitforConnectionReady waits for an connecion to leave the // "CREATING" state, to indicate that it's ready. func waitforConnectionReady(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceIntegrationConnectorsConnectionRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) status := d.Get("status").([]interface{}) state := status[0].(map[string]interface{})["state"] log.Printf("[DEBUG] Connection %q has state %v.", name, state) if state == "CREATING" || state == "UPDATING" { - return retry.RetryableError(fmt.Errorf("Connection %q has state %q.", name, state)) + return resource.RetryableError(fmt.Errorf("Connection %q has state %q.", name, state)) } log.Printf("[DEBUG] Connection %q has state %q.", name, state) return nil @@ -1241,7 +1240,6 @@ func resourceIntegrationConnectorsConnectionCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1250,7 +1248,6 @@ func resourceIntegrationConnectorsConnectionCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Connection: %s", err) @@ -1317,14 +1314,12 @@ func resourceIntegrationConnectorsConnectionRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IntegrationConnectorsConnection %q", d.Id())) @@ -1520,7 +1515,6 @@ func resourceIntegrationConnectorsConnectionUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating Connection %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1600,7 +1594,6 @@ func resourceIntegrationConnectorsConnectionUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1651,8 +1644,6 @@ func resourceIntegrationConnectorsConnectionDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Connection %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1662,7 +1653,6 @@ func resourceIntegrationConnectorsConnectionDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Connection") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go index e135284a8a1..daaf42fc4b4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_endpoint_attachment.go @@ -20,7 +20,6 @@ package integrationconnectors import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -78,11 +77,6 @@ func ResourceIntegrationConnectorsEndpointAttachment() *schema.Resource { Optional: true, Description: `Description of the resource.`, }, - "endpoint_global_access": { - Type: schema.TypeBool, - Optional: true, - Description: `Enable global access for endpoint attachment.`, - }, "labels": { Type: schema.TypeMap, Optional: true, @@ -152,12 +146,6 @@ func resourceIntegrationConnectorsEndpointAttachmentCreate(d *schema.ResourceDat } else if v, ok := d.GetOkExists("service_attachment"); !tpgresource.IsEmptyValue(reflect.ValueOf(serviceAttachmentProp)) && (ok || !reflect.DeepEqual(v, serviceAttachmentProp)) { obj["serviceAttachment"] = serviceAttachmentProp } - endpointGlobalAccessProp, err := expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(d.Get("endpoint_global_access"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("endpoint_global_access"); !tpgresource.IsEmptyValue(reflect.ValueOf(endpointGlobalAccessProp)) && (ok || !reflect.DeepEqual(v, endpointGlobalAccessProp)) { - obj["endpointGlobalAccess"] = endpointGlobalAccessProp - } labelsProp, err := expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -184,7 +172,6 @@ func resourceIntegrationConnectorsEndpointAttachmentCreate(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -193,7 +180,6 @@ func resourceIntegrationConnectorsEndpointAttachmentCreate(d *schema.ResourceDat UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EndpointAttachment: %s", err) @@ -256,14 +242,12 @@ func resourceIntegrationConnectorsEndpointAttachmentRead(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IntegrationConnectorsEndpointAttachment %q", d.Id())) @@ -291,9 +275,6 @@ func resourceIntegrationConnectorsEndpointAttachmentRead(d *schema.ResourceData, if err := d.Set("endpoint_ip", flattenIntegrationConnectorsEndpointAttachmentEndpointIp(res["endpointIp"], d, config)); err != nil { return fmt.Errorf("Error reading EndpointAttachment: %s", err) } - if err := d.Set("endpoint_global_access", flattenIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(res["endpointGlobalAccess"], d, config)); err != nil { - return fmt.Errorf("Error reading EndpointAttachment: %s", err) - } if err := d.Set("terraform_labels", flattenIntegrationConnectorsEndpointAttachmentTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading EndpointAttachment: %s", err) } @@ -326,12 +307,6 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { obj["description"] = descriptionProp } - endpointGlobalAccessProp, err := expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(d.Get("endpoint_global_access"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("endpoint_global_access"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, endpointGlobalAccessProp)) { - obj["endpointGlobalAccess"] = endpointGlobalAccessProp - } labelsProp, err := expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -345,17 +320,12 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat } log.Printf("[DEBUG] Updating EndpointAttachment %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { updateMask = append(updateMask, "description") } - if d.HasChange("endpoint_global_access") { - updateMask = append(updateMask, "endpointGlobalAccess") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -381,7 +351,6 @@ func resourceIntegrationConnectorsEndpointAttachmentUpdate(d *schema.ResourceDat UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -429,8 +398,6 @@ func resourceIntegrationConnectorsEndpointAttachmentDelete(d *schema.ResourceDat billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EndpointAttachment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -440,7 +407,6 @@ func resourceIntegrationConnectorsEndpointAttachmentDelete(d *schema.ResourceDat UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EndpointAttachment") @@ -513,10 +479,6 @@ func flattenIntegrationConnectorsEndpointAttachmentEndpointIp(v interface{}, d * return v } -func flattenIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenIntegrationConnectorsEndpointAttachmentTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -544,10 +506,6 @@ func expandIntegrationConnectorsEndpointAttachmentServiceAttachment(v interface{ return v, nil } -func expandIntegrationConnectorsEndpointAttachmentEndpointGlobalAccess(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandIntegrationConnectorsEndpointAttachmentEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go deleted file mode 100644 index 50d7d4149a5..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_managed_zone.go +++ /dev/null @@ -1,583 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package integrationconnectors - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceIntegrationConnectorsManagedZone() *schema.Resource { - return &schema.Resource{ - Create: resourceIntegrationConnectorsManagedZoneCreate, - Read: resourceIntegrationConnectorsManagedZoneRead, - Update: resourceIntegrationConnectorsManagedZoneUpdate, - Delete: resourceIntegrationConnectorsManagedZoneDelete, - - Importer: &schema.ResourceImporter{ - State: resourceIntegrationConnectorsManagedZoneImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(5 * time.Minute), - Delete: schema.DefaultTimeout(5 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "dns": { - Type: schema.TypeString, - Required: true, - Description: `DNS Name of the resource.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Name of Managed Zone needs to be created.`, - }, - "target_project": { - Type: schema.TypeString, - Required: true, - Description: `The name of the Target Project.`, - }, - "target_vpc": { - Type: schema.TypeString, - Required: true, - Description: `The name of the Target Project VPC Network.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the resource.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `Resource labels to represent user provided metadata. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the Namespace was created in UTC.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the Namespace was updated in UTC.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceIntegrationConnectorsManagedZoneCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandIntegrationConnectorsManagedZoneDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - dnsProp, err := expandIntegrationConnectorsManagedZoneDns(d.Get("dns"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dns"); !tpgresource.IsEmptyValue(reflect.ValueOf(dnsProp)) && (ok || !reflect.DeepEqual(v, dnsProp)) { - obj["dns"] = dnsProp - } - targetProjectProp, err := expandIntegrationConnectorsManagedZoneTargetProject(d.Get("target_project"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_project"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetProjectProp)) && (ok || !reflect.DeepEqual(v, targetProjectProp)) { - obj["targetProject"] = targetProjectProp - } - targetVpcProp, err := expandIntegrationConnectorsManagedZoneTargetVpc(d.Get("target_vpc"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_vpc"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetVpcProp)) && (ok || !reflect.DeepEqual(v, targetVpcProp)) { - obj["targetVpc"] = targetVpcProp - } - labelsProp, err := expandIntegrationConnectorsManagedZoneEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationConnectorsBasePath}}projects/{{project}}/locations/global/managedZones?managedZoneId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new ManagedZone: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ManagedZone: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ManagedZone: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/managedZones/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // Use the resource in the operation response to populate - // identity fields and d.Id() before read - var opRes map[string]interface{} - err = IntegrationConnectorsOperationWaitTimeWithResponse( - config, res, &opRes, project, "Creating ManagedZone", userAgent, - d.Timeout(schema.TimeoutCreate)) - if err != nil { - // The resource didn't actually create - d.SetId("") - - return fmt.Errorf("Error waiting to create ManagedZone: %s", err) - } - - // This may have caused the ID to update - update it if so. - id, err = tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/managedZones/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating ManagedZone %q: %#v", d.Id(), res) - - return resourceIntegrationConnectorsManagedZoneRead(d, meta) -} - -func resourceIntegrationConnectorsManagedZoneRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationConnectorsBasePath}}projects/{{project}}/locations/global/managedZones/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ManagedZone: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IntegrationConnectorsManagedZone %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - - if err := d.Set("create_time", flattenIntegrationConnectorsManagedZoneCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("update_time", flattenIntegrationConnectorsManagedZoneUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("description", flattenIntegrationConnectorsManagedZoneDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("labels", flattenIntegrationConnectorsManagedZoneLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("dns", flattenIntegrationConnectorsManagedZoneDns(res["dns"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("target_project", flattenIntegrationConnectorsManagedZoneTargetProject(res["targetProject"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("target_vpc", flattenIntegrationConnectorsManagedZoneTargetVpc(res["targetVpc"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("terraform_labels", flattenIntegrationConnectorsManagedZoneTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - if err := d.Set("effective_labels", flattenIntegrationConnectorsManagedZoneEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedZone: %s", err) - } - - return nil -} - -func resourceIntegrationConnectorsManagedZoneUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ManagedZone: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandIntegrationConnectorsManagedZoneDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - dnsProp, err := expandIntegrationConnectorsManagedZoneDns(d.Get("dns"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dns"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dnsProp)) { - obj["dns"] = dnsProp - } - targetProjectProp, err := expandIntegrationConnectorsManagedZoneTargetProject(d.Get("target_project"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_project"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetProjectProp)) { - obj["targetProject"] = targetProjectProp - } - targetVpcProp, err := expandIntegrationConnectorsManagedZoneTargetVpc(d.Get("target_vpc"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_vpc"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetVpcProp)) { - obj["targetVpc"] = targetVpcProp - } - labelsProp, err := expandIntegrationConnectorsManagedZoneEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationConnectorsBasePath}}projects/{{project}}/locations/global/managedZones/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating ManagedZone %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("dns") { - updateMask = append(updateMask, "dns") - } - - if d.HasChange("target_project") { - updateMask = append(updateMask, "targetProject") - } - - if d.HasChange("target_vpc") { - updateMask = append(updateMask, "targetVpc") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating ManagedZone %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating ManagedZone %q: %#v", d.Id(), res) - } - - err = IntegrationConnectorsOperationWaitTime( - config, res, project, "Updating ManagedZone", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceIntegrationConnectorsManagedZoneRead(d, meta) -} - -func resourceIntegrationConnectorsManagedZoneDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ManagedZone: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationConnectorsBasePath}}projects/{{project}}/locations/global/managedZones/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting ManagedZone %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ManagedZone") - } - - err = IntegrationConnectorsOperationWaitTime( - config, res, project, "Deleting ManagedZone", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting ManagedZone %q: %#v", d.Id(), res) - return nil -} - -func resourceIntegrationConnectorsManagedZoneImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/global/managedZones/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/managedZones/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenIntegrationConnectorsManagedZoneCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationConnectorsManagedZoneUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationConnectorsManagedZoneDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationConnectorsManagedZoneLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenIntegrationConnectorsManagedZoneDns(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationConnectorsManagedZoneTargetProject(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationConnectorsManagedZoneTargetVpc(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationConnectorsManagedZoneTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenIntegrationConnectorsManagedZoneEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandIntegrationConnectorsManagedZoneDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationConnectorsManagedZoneDns(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationConnectorsManagedZoneTargetProject(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationConnectorsManagedZoneTargetVpc(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationConnectorsManagedZoneEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_managed_zone_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_managed_zone_sweeper.go deleted file mode 100644 index 644163ad8dc..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors/resource_integration_connectors_managed_zone_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package integrationconnectors - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("IntegrationConnectorsManagedZone", testSweepIntegrationConnectorsManagedZone) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepIntegrationConnectorsManagedZone(region string) error { - resourceName := "IntegrationConnectorsManagedZone" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://connectors.googleapis.com/v1/projects/{{project}}/locations/global/managedZones", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["managedZones"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://connectors.googleapis.com/v1/projects/{{project}}/locations/global/managedZones/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_auth_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_auth_config.go deleted file mode 100644 index 54e3cacf0b9..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_auth_config.go +++ /dev/null @@ -1,1942 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package integrations - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceIntegrationsAuthConfig() *schema.Resource { - return &schema.Resource{ - Create: resourceIntegrationsAuthConfigCreate, - Read: resourceIntegrationsAuthConfigRead, - Update: resourceIntegrationsAuthConfigUpdate, - Delete: resourceIntegrationsAuthConfigDelete, - - Importer: &schema.ResourceImporter{ - State: resourceIntegrationsAuthConfigImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "display_name": { - Type: schema.TypeString, - Required: true, - Description: `The name of the auth config.`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Location in which client needs to be provisioned.`, - }, - "client_certificate": { - Type: schema.TypeList, - Optional: true, - Description: `Raw client certificate`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "encrypted_private_key": { - Type: schema.TypeString, - Required: true, - Description: `The ssl certificate encoded in PEM format. This string must include the begin header and end footer lines.`, - }, - "ssl_certificate": { - Type: schema.TypeString, - Required: true, - Description: `The ssl certificate encoded in PEM format. This string must include the begin header and end footer lines.`, - }, - "passphrase": { - Type: schema.TypeString, - Optional: true, - Description: `'passphrase' should be left unset if private key is not encrypted. -Note that 'passphrase' is not the password for web server, but an extra layer of security to protected private key.`, - }, - }, - }, - }, - "decrypted_credential": { - Type: schema.TypeList, - Optional: true, - Description: `Raw auth credentials.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "credential_type": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Credential type associated with auth configs.`, - }, - "auth_token": { - Type: schema.TypeList, - Optional: true, - Description: `Auth token credential.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "token": { - Type: schema.TypeString, - Optional: true, - Description: `The token for the auth type.`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - Description: `Authentication type, e.g. "Basic", "Bearer", etc.`, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.username_and_password", "decrypted_credential.0.oauth2_authorization_code", "decrypted_credential.0.oauth2_client_credentials", "decrypted_credential.0.jwt", "decrypted_credential.0.service_account_credentials", "decrypted_credential.0.oidc_token"}, - }, - "jwt": { - Type: schema.TypeList, - Optional: true, - Description: `JWT credential.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "jwt_header": { - Type: schema.TypeString, - Optional: true, - Description: `Identifies which algorithm is used to generate the signature.`, - }, - "jwt_payload": { - Type: schema.TypeString, - Optional: true, - Description: `Contains a set of claims. The JWT specification defines seven Registered Claim Names which are the standard fields commonly included in tokens. Custom claims are usually also included, depending on the purpose of the token.`, - }, - "secret": { - Type: schema.TypeString, - Optional: true, - Description: `User's pre-shared secret to sign the token.`, - }, - "jwt": { - Type: schema.TypeString, - Computed: true, - Description: `The token calculated by the header, payload and signature.`, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.username_and_password", "decrypted_credential.0.oauth2_authorization_code", "decrypted_credential.0.oauth2_client_credentials", "decrypted_credential.0.auth_token", "decrypted_credential.0.service_account_credentials", "decrypted_credential.0.oidc_token"}, - }, - "oauth2_authorization_code": { - Type: schema.TypeList, - Optional: true, - Description: `OAuth2 authorization code credential.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "auth_endpoint": { - Type: schema.TypeString, - Optional: true, - Description: `The auth url endpoint to send the auth code request to.`, - }, - "client_id": { - Type: schema.TypeString, - Optional: true, - Description: `The client's id.`, - }, - "client_secret": { - Type: schema.TypeString, - Optional: true, - Description: `The client's secret.`, - }, - "scope": { - Type: schema.TypeString, - Optional: true, - Description: `A space-delimited list of requested scope permissions.`, - }, - "token_endpoint": { - Type: schema.TypeString, - Optional: true, - Description: `The token url endpoint to send the token request to.`, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.username_and_password", "decrypted_credential.0.oauth2_client_credentials", "decrypted_credential.0.jwt", "decrypted_credential.0.auth_token", "decrypted_credential.0.service_account_credentials", "decrypted_credential.0.oidc_token"}, - }, - "oauth2_client_credentials": { - Type: schema.TypeList, - Optional: true, - Description: `OAuth2 client credentials.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "client_id": { - Type: schema.TypeString, - Optional: true, - Description: `The client's ID.`, - }, - "client_secret": { - Type: schema.TypeString, - Optional: true, - Description: `The client's secret.`, - }, - "request_type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"REQUEST_TYPE_UNSPECIFIED", "REQUEST_BODY", "QUERY_PARAMETERS", "ENCODED_HEADER", ""}), - Description: `Represent how to pass parameters to fetch access token Possible values: ["REQUEST_TYPE_UNSPECIFIED", "REQUEST_BODY", "QUERY_PARAMETERS", "ENCODED_HEADER"]`, - }, - "scope": { - Type: schema.TypeString, - Optional: true, - Description: `A space-delimited list of requested scope permissions.`, - }, - "token_endpoint": { - Type: schema.TypeString, - Optional: true, - Description: `The token endpoint is used by the client to obtain an access token by presenting its authorization grant or refresh token.`, - }, - "token_params": { - Type: schema.TypeList, - Optional: true, - Description: `Token parameters for the auth request.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "entries": { - Type: schema.TypeList, - Optional: true, - Description: `A list of parameter map entries.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeList, - Optional: true, - Description: `Key of the map entry.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "literal_value": { - Type: schema.TypeList, - Optional: true, - Description: `Passing a literal value`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "string_value": { - Type: schema.TypeString, - Optional: true, - Description: `String.`, - }, - }, - }, - }, - }, - }, - }, - "value": { - Type: schema.TypeList, - Optional: true, - Description: `Value of the map entry.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "literal_value": { - Type: schema.TypeList, - Optional: true, - Description: `Passing a literal value`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "string_value": { - Type: schema.TypeString, - Optional: true, - Description: `String.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.username_and_password", "decrypted_credential.0.oauth2_authorization_code", "decrypted_credential.0.jwt", "decrypted_credential.0.auth_token", "decrypted_credential.0.service_account_credentials", "decrypted_credential.0.oidc_token"}, - }, - "oidc_token": { - Type: schema.TypeList, - Optional: true, - Description: `Google OIDC ID Token.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "audience": { - Type: schema.TypeString, - Optional: true, - Description: `Audience to be used when generating OIDC token. The audience claim identifies the recipients that the JWT is intended for.`, - }, - "service_account_email": { - Type: schema.TypeString, - Optional: true, - Description: `The service account email to be used as the identity for the token.`, - }, - "token": { - Type: schema.TypeString, - Computed: true, - Description: `ID token obtained for the service account.`, - }, - "token_expire_time": { - Type: schema.TypeString, - Computed: true, - Description: `The approximate time until the token retrieved is valid. - -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".`, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.username_and_password", "decrypted_credential.0.oauth2_authorization_code", "decrypted_credential.0.oauth2_client_credentials", "decrypted_credential.0.jwt", "decrypted_credential.0.auth_token", "decrypted_credential.0.service_account_credentials"}, - }, - "service_account_credentials": { - Type: schema.TypeList, - Optional: true, - Description: `Service account credential.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "scope": { - Type: schema.TypeString, - Optional: true, - Description: `A space-delimited list of requested scope permissions.`, - }, - "service_account": { - Type: schema.TypeString, - Optional: true, - Description: `Name of the service account that has the permission to make the request.`, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.username_and_password", "decrypted_credential.0.oauth2_authorization_code", "decrypted_credential.0.oauth2_client_credentials", "decrypted_credential.0.jwt", "decrypted_credential.0.auth_token", "decrypted_credential.0.oidc_token"}, - }, - "username_and_password": { - Type: schema.TypeList, - Optional: true, - Description: `Username and password credential.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "password": { - Type: schema.TypeString, - Optional: true, - Description: `Password to be used.`, - }, - "username": { - Type: schema.TypeString, - Optional: true, - Description: `Username to be used.`, - }, - }, - }, - ConflictsWith: []string{"decrypted_credential.0.oauth2_authorization_code", "decrypted_credential.0.oauth2_client_credentials", "decrypted_credential.0.jwt", "decrypted_credential.0.auth_token", "decrypted_credential.0.service_account_credentials", "decrypted_credential.0.oidc_token"}, - }, - }, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `A description of the auth config.`, - }, - "expiry_notification_duration": { - Type: schema.TypeList, - Optional: true, - Description: `User can define the time to receive notification after which the auth config becomes invalid. Support up to 30 days. Support granularity in hours. - -A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "override_valid_time": { - Type: schema.TypeString, - Optional: true, - Description: `User provided expiry time to override. For the example of Salesforce, username/password credentials can be valid for 6 months depending on the instance settings. - -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".`, - }, - "visibility": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"PRIVATE", "CLIENT_VISIBLE", ""}), - Description: `The visibility of the auth config. Possible values: ["PRIVATE", "CLIENT_VISIBLE"]`, - }, - "certificate_id": { - Type: schema.TypeString, - Computed: true, - Description: `Certificate id for client certificate.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp when the auth config is 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".`, - }, - "creator_email": { - Type: schema.TypeString, - Computed: true, - Description: `The creator's email address. Generated based on the End User Credentials/LOAS role of the user making the call.`, - }, - "credential_type": { - Type: schema.TypeString, - Computed: true, - Description: `Credential type of the encrypted credential.`, - }, - "encrypted_credential": { - Type: schema.TypeString, - Computed: true, - Description: `Auth credential encrypted by Cloud KMS. Can be decrypted as Credential with proper KMS key. - -A base64-encoded string.`, - }, - "last_modifier_email": { - Type: schema.TypeString, - Computed: true, - Description: `The last modifier's email address. Generated based on the End User Credentials/LOAS role of the user making the call.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `Resource name of the auth config.`, - }, - "reason": { - Type: schema.TypeString, - Computed: true, - Description: `The reason / details of the current status.`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `The status of the auth config.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp when the auth config is modified. - -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".`, - }, - "valid_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time until the auth config is valid. Empty or max value is considered the auth config won't expire. - -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".`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceIntegrationsAuthConfigCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - displayNameProp, err := expandIntegrationsAuthConfigDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - descriptionProp, err := expandIntegrationsAuthConfigDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - visibilityProp, err := expandIntegrationsAuthConfigVisibility(d.Get("visibility"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("visibility"); !tpgresource.IsEmptyValue(reflect.ValueOf(visibilityProp)) && (ok || !reflect.DeepEqual(v, visibilityProp)) { - obj["visibility"] = visibilityProp - } - expiryNotificationDurationProp, err := expandIntegrationsAuthConfigExpiryNotificationDuration(d.Get("expiry_notification_duration"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("expiry_notification_duration"); !tpgresource.IsEmptyValue(reflect.ValueOf(expiryNotificationDurationProp)) && (ok || !reflect.DeepEqual(v, expiryNotificationDurationProp)) { - obj["expiryNotificationDuration"] = expiryNotificationDurationProp - } - overrideValidTimeProp, err := expandIntegrationsAuthConfigOverrideValidTime(d.Get("override_valid_time"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("override_valid_time"); !tpgresource.IsEmptyValue(reflect.ValueOf(overrideValidTimeProp)) && (ok || !reflect.DeepEqual(v, overrideValidTimeProp)) { - obj["overrideValidTime"] = overrideValidTimeProp - } - decryptedCredentialProp, err := expandIntegrationsAuthConfigDecryptedCredential(d.Get("decrypted_credential"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("decrypted_credential"); !tpgresource.IsEmptyValue(reflect.ValueOf(decryptedCredentialProp)) && (ok || !reflect.DeepEqual(v, decryptedCredentialProp)) { - obj["decryptedCredential"] = decryptedCredentialProp - } - client_certificateProp, err := expandIntegrationsAuthConfigClientCertificate(d.Get("client_certificate"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("client_certificate"); !tpgresource.IsEmptyValue(reflect.ValueOf(client_certificateProp)) && (ok || !reflect.DeepEqual(v, client_certificateProp)) { - obj["client_certificate"] = client_certificateProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "{{name}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}projects/{{project}}/locations/{{location}}/authConfigs") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new AuthConfig: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AuthConfig: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - // Move client certificate to url param from request body - if cc, ok := obj["client_certificate"]; ok { - ccm := cc.(map[string]any) - - params := map[string]string{ - "clientCertificate.sslCertificate": ccm["ssl_certificate"].(string), - "clientCertificate.encryptedPrivateKey": ccm["encrypted_private_key"].(string), - } - if pp, ok := ccm["passphrase"]; ok { - params["clientCertificate.passphrase"] = pp.(string) - } - url, err = transport_tpg.AddQueryParams(url, params) - if err != nil { - return err - } - delete(obj, "client_certificate") - } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating AuthConfig: %s", err) - } - if err := d.Set("name", flattenIntegrationsAuthConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // `name` is autogenerated from the api so needs to be set post-create - name, ok := res["name"] - if !ok { - respBody, ok := res["response"] - if !ok { - return fmt.Errorf("Create response didn't contain critical fields. Create may not have succeeded.") - } - - name, ok = respBody.(map[string]interface{})["name"] - if !ok { - return fmt.Errorf("Create response didn't contain critical fields. Create may not have succeeded.") - } - } - if err := d.Set("name", name.(string)); err != nil { - return fmt.Errorf("Error setting name: %s", err) - } - d.SetId(name.(string)) - - log.Printf("[DEBUG] Finished creating AuthConfig %q: %#v", d.Id(), res) - - return resourceIntegrationsAuthConfigRead(d, meta) -} - -func resourceIntegrationsAuthConfigRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AuthConfig: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IntegrationsAuthConfig %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - - if err := d.Set("name", flattenIntegrationsAuthConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("display_name", flattenIntegrationsAuthConfigDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("description", flattenIntegrationsAuthConfigDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("certificate_id", flattenIntegrationsAuthConfigCertificateId(res["certificateId"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("credential_type", flattenIntegrationsAuthConfigCredentialType(res["credentialType"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("creator_email", flattenIntegrationsAuthConfigCreatorEmail(res["creatorEmail"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("create_time", flattenIntegrationsAuthConfigCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("last_modifier_email", flattenIntegrationsAuthConfigLastModifierEmail(res["lastModifierEmail"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("update_time", flattenIntegrationsAuthConfigUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("visibility", flattenIntegrationsAuthConfigVisibility(res["visibility"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("state", flattenIntegrationsAuthConfigState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("reason", flattenIntegrationsAuthConfigReason(res["reason"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("expiry_notification_duration", flattenIntegrationsAuthConfigExpiryNotificationDuration(res["expiryNotificationDuration"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("valid_time", flattenIntegrationsAuthConfigValidTime(res["validTime"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("override_valid_time", flattenIntegrationsAuthConfigOverrideValidTime(res["overrideValidTime"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("encrypted_credential", flattenIntegrationsAuthConfigEncryptedCredential(res["encryptedCredential"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - if err := d.Set("decrypted_credential", flattenIntegrationsAuthConfigDecryptedCredential(res["decryptedCredential"], d, config)); err != nil { - return fmt.Errorf("Error reading AuthConfig: %s", err) - } - - return nil -} - -func resourceIntegrationsAuthConfigUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AuthConfig: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - displayNameProp, err := expandIntegrationsAuthConfigDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - descriptionProp, err := expandIntegrationsAuthConfigDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - visibilityProp, err := expandIntegrationsAuthConfigVisibility(d.Get("visibility"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("visibility"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, visibilityProp)) { - obj["visibility"] = visibilityProp - } - expiryNotificationDurationProp, err := expandIntegrationsAuthConfigExpiryNotificationDuration(d.Get("expiry_notification_duration"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("expiry_notification_duration"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, expiryNotificationDurationProp)) { - obj["expiryNotificationDuration"] = expiryNotificationDurationProp - } - overrideValidTimeProp, err := expandIntegrationsAuthConfigOverrideValidTime(d.Get("override_valid_time"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("override_valid_time"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, overrideValidTimeProp)) { - obj["overrideValidTime"] = overrideValidTimeProp - } - decryptedCredentialProp, err := expandIntegrationsAuthConfigDecryptedCredential(d.Get("decrypted_credential"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("decrypted_credential"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, decryptedCredentialProp)) { - obj["decryptedCredential"] = decryptedCredentialProp - } - client_certificateProp, err := expandIntegrationsAuthConfigClientCertificate(d.Get("client_certificate"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("client_certificate"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, client_certificateProp)) { - obj["client_certificate"] = client_certificateProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "{{name}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating AuthConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) - params := map[string]string{} - - // Move client certificate to url param from request body - if cc, ok := obj["client_certificate"]; ok { - ccm := cc.(map[string]any) - - params["clientCertificate.sslCertificate"] = ccm["ssl_certificate"].(string) - params["clientCertificate.encryptedPrivateKey"] = ccm["encrypted_private_key"].(string) - if pp, ok := ccm["passphrase"]; ok { - params["clientCertificate.passphrase"] = pp.(string) - } - delete(obj, "client_certificate") - } - - // By default allow all fields to be updated via terraform - params["updateMask"] = "*" - - url, err = transport_tpg.AddQueryParams(url, params) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating AuthConfig %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating AuthConfig %q: %#v", d.Id(), res) - } - - return resourceIntegrationsAuthConfigRead(d, meta) -} - -func resourceIntegrationsAuthConfigDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for AuthConfig: %s", err) - } - billingProject = project - - lockName, err := tpgresource.ReplaceVars(d, config, "{{name}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting AuthConfig %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "AuthConfig") - } - - log.Printf("[DEBUG] Finished deleting AuthConfig %q: %#v", d.Id(), res) - return nil -} - -func resourceIntegrationsAuthConfigImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - - config := meta.(*transport_tpg.Config) - - // current import_formats can't import fields with forward slashes in their value - if err := tpgresource.ParseImportId([]string{"(?P[^ ]+) (?P[^ ]+)", "(?P[^ ]+)"}, d, config); err != nil { - return nil, err - } - - return []*schema.ResourceData{d}, nil -} - -func flattenIntegrationsAuthConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigCertificateId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigCredentialType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigCreatorEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigLastModifierEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigVisibility(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigReason(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigExpiryNotificationDuration(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigValidTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigOverrideValidTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigEncryptedCredential(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredential(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["credential_type"] = - flattenIntegrationsAuthConfigDecryptedCredentialCredentialType(original["credentialType"], d, config) - transformed["username_and_password"] = - flattenIntegrationsAuthConfigDecryptedCredentialUsernameAndPassword(original["usernameAndPassword"], d, config) - transformed["oauth2_authorization_code"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCode(original["oauth2AuthorizationCode"], d, config) - transformed["oauth2_client_credentials"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentials(original["oauth2ClientCredentials"], d, config) - transformed["jwt"] = - flattenIntegrationsAuthConfigDecryptedCredentialJwt(original["jwt"], d, config) - transformed["auth_token"] = - flattenIntegrationsAuthConfigDecryptedCredentialAuthToken(original["authToken"], d, config) - transformed["service_account_credentials"] = - flattenIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentials(original["serviceAccountCredentials"], d, config) - transformed["oidc_token"] = - flattenIntegrationsAuthConfigDecryptedCredentialOidcToken(original["oidcToken"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialCredentialType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - -func flattenIntegrationsAuthConfigDecryptedCredentialUsernameAndPassword(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["username"] = - flattenIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordUsername(original["username"], d, config) - transformed["password"] = - flattenIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordPassword(original["password"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordUsername(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordPassword(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["client_id"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientId(original["clientId"], d, config) - transformed["client_secret"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientSecret(original["clientSecret"], d, config) - transformed["scope"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeScope(original["scope"], d, config) - transformed["auth_endpoint"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeAuthEndpoint(original["authEndpoint"], d, config) - transformed["token_endpoint"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeTokenEndpoint(original["tokenEndpoint"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientSecret(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeScope(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeAuthEndpoint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeTokenEndpoint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentials(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["client_id"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientId(original["clientId"], d, config) - transformed["client_secret"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientSecret(original["clientSecret"], d, config) - transformed["token_endpoint"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenEndpoint(original["tokenEndpoint"], d, config) - transformed["scope"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsScope(original["scope"], d, config) - transformed["token_params"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParams(original["tokenParams"], d, config) - transformed["request_type"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsRequestType(original["requestType"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientSecret(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenEndpoint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsScope(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParams(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["entries"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntries(original["entries"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntries(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "key": flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKey(original["key"], d, config), - "value": flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValue(original["value"], d, config), - }) - } - return transformed -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["literal_value"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValue(original["literalValue"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["string_value"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValueStringValue(original["stringValue"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValueStringValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["literal_value"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValue(original["literalValue"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["string_value"] = - flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValueStringValue(original["stringValue"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValueStringValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsRequestType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialJwt(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["jwt_header"] = - flattenIntegrationsAuthConfigDecryptedCredentialJwtJwtHeader(original["jwtHeader"], d, config) - transformed["jwt_payload"] = - flattenIntegrationsAuthConfigDecryptedCredentialJwtJwtPayload(original["jwtPayload"], d, config) - transformed["secret"] = - flattenIntegrationsAuthConfigDecryptedCredentialJwtSecret(original["secret"], d, config) - transformed["jwt"] = - flattenIntegrationsAuthConfigDecryptedCredentialJwtJwt(original["jwt"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialJwtJwtHeader(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialJwtJwtPayload(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialJwtSecret(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialJwtJwt(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialAuthToken(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["type"] = - flattenIntegrationsAuthConfigDecryptedCredentialAuthTokenType(original["type"], d, config) - transformed["token"] = - flattenIntegrationsAuthConfigDecryptedCredentialAuthTokenToken(original["token"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialAuthTokenType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialAuthTokenToken(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentials(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["service_account"] = - flattenIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsServiceAccount(original["serviceAccount"], d, config) - transformed["scope"] = - flattenIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsScope(original["scope"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsServiceAccount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsScope(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOidcToken(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["service_account_email"] = - flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenServiceAccountEmail(original["serviceAccountEmail"], d, config) - transformed["audience"] = - flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenAudience(original["audience"], d, config) - transformed["token"] = - flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenToken(original["token"], d, config) - transformed["token_expire_time"] = - flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenTokenExpireTime(original["tokenExpireTime"], d, config) - return []interface{}{transformed} -} -func flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenServiceAccountEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenAudience(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenToken(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenIntegrationsAuthConfigDecryptedCredentialOidcTokenTokenExpireTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandIntegrationsAuthConfigDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigVisibility(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigExpiryNotificationDuration(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigOverrideValidTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredential(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCredentialType, err := expandIntegrationsAuthConfigDecryptedCredentialCredentialType(original["credential_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCredentialType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["credentialType"] = transformedCredentialType - } - - transformedUsernameAndPassword, err := expandIntegrationsAuthConfigDecryptedCredentialUsernameAndPassword(original["username_and_password"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUsernameAndPassword); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["usernameAndPassword"] = transformedUsernameAndPassword - } - - transformedOauth2AuthorizationCode, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCode(original["oauth2_authorization_code"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOauth2AuthorizationCode); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["oauth2AuthorizationCode"] = transformedOauth2AuthorizationCode - } - - transformedOauth2ClientCredentials, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentials(original["oauth2_client_credentials"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOauth2ClientCredentials); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["oauth2ClientCredentials"] = transformedOauth2ClientCredentials - } - - transformedJwt, err := expandIntegrationsAuthConfigDecryptedCredentialJwt(original["jwt"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedJwt); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["jwt"] = transformedJwt - } - - transformedAuthToken, err := expandIntegrationsAuthConfigDecryptedCredentialAuthToken(original["auth_token"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthToken); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authToken"] = transformedAuthToken - } - - transformedServiceAccountCredentials, err := expandIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentials(original["service_account_credentials"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAccountCredentials); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAccountCredentials"] = transformedServiceAccountCredentials - } - - transformedOidcToken, err := expandIntegrationsAuthConfigDecryptedCredentialOidcToken(original["oidc_token"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedOidcToken); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["oidcToken"] = transformedOidcToken - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialCredentialType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialUsernameAndPassword(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedUsername, err := expandIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordUsername(original["username"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUsername); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["username"] = transformedUsername - } - - transformedPassword, err := expandIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordPassword(original["password"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPassword); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["password"] = transformedPassword - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordUsername(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialUsernameAndPasswordPassword(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedClientId, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientId(original["client_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedClientId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["clientId"] = transformedClientId - } - - transformedClientSecret, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientSecret(original["client_secret"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedClientSecret); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["clientSecret"] = transformedClientSecret - } - - transformedScope, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeScope(original["scope"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedScope); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["scope"] = transformedScope - } - - transformedAuthEndpoint, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeAuthEndpoint(original["auth_endpoint"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthEndpoint); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authEndpoint"] = transformedAuthEndpoint - } - - transformedTokenEndpoint, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeTokenEndpoint(original["token_endpoint"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTokenEndpoint); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tokenEndpoint"] = transformedTokenEndpoint - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeClientSecret(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeScope(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeAuthEndpoint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2AuthorizationCodeTokenEndpoint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentials(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedClientId, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientId(original["client_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedClientId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["clientId"] = transformedClientId - } - - transformedClientSecret, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientSecret(original["client_secret"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedClientSecret); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["clientSecret"] = transformedClientSecret - } - - transformedTokenEndpoint, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenEndpoint(original["token_endpoint"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTokenEndpoint); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tokenEndpoint"] = transformedTokenEndpoint - } - - transformedScope, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsScope(original["scope"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedScope); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["scope"] = transformedScope - } - - transformedTokenParams, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParams(original["token_params"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTokenParams); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tokenParams"] = transformedTokenParams - } - - transformedRequestType, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsRequestType(original["request_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRequestType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["requestType"] = transformedRequestType - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsClientSecret(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenEndpoint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsScope(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParams(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEntries, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntries(original["entries"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEntries); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["entries"] = transformedEntries - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntries(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKey, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKey(original["key"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKey); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["key"] = transformedKey - } - - transformedValue, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["value"] = transformedValue - } - - req = append(req, transformed) - } - return req, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKey(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedLiteralValue, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValue(original["literal_value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLiteralValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["literalValue"] = transformedLiteralValue - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedStringValue, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValueStringValue(original["string_value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStringValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["stringValue"] = transformedStringValue - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesKeyLiteralValueStringValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedLiteralValue, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValue(original["literal_value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLiteralValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["literalValue"] = transformedLiteralValue - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedStringValue, err := expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValueStringValue(original["string_value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStringValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["stringValue"] = transformedStringValue - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsTokenParamsEntriesValueLiteralValueStringValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOauth2ClientCredentialsRequestType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialJwt(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedJwtHeader, err := expandIntegrationsAuthConfigDecryptedCredentialJwtJwtHeader(original["jwt_header"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedJwtHeader); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["jwtHeader"] = transformedJwtHeader - } - - transformedJwtPayload, err := expandIntegrationsAuthConfigDecryptedCredentialJwtJwtPayload(original["jwt_payload"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedJwtPayload); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["jwtPayload"] = transformedJwtPayload - } - - transformedSecret, err := expandIntegrationsAuthConfigDecryptedCredentialJwtSecret(original["secret"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSecret); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["secret"] = transformedSecret - } - - transformedJwt, err := expandIntegrationsAuthConfigDecryptedCredentialJwtJwt(original["jwt"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedJwt); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["jwt"] = transformedJwt - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialJwtJwtHeader(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialJwtJwtPayload(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialJwtSecret(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialJwtJwt(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialAuthToken(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedType, err := expandIntegrationsAuthConfigDecryptedCredentialAuthTokenType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - transformedToken, err := expandIntegrationsAuthConfigDecryptedCredentialAuthTokenToken(original["token"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedToken); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["token"] = transformedToken - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialAuthTokenType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialAuthTokenToken(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentials(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedServiceAccount, err := expandIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsServiceAccount(original["service_account"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAccount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAccount"] = transformedServiceAccount - } - - transformedScope, err := expandIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsScope(original["scope"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedScope); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["scope"] = transformedScope - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsServiceAccount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialServiceAccountCredentialsScope(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOidcToken(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedServiceAccountEmail, err := expandIntegrationsAuthConfigDecryptedCredentialOidcTokenServiceAccountEmail(original["service_account_email"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAccountEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAccountEmail"] = transformedServiceAccountEmail - } - - transformedAudience, err := expandIntegrationsAuthConfigDecryptedCredentialOidcTokenAudience(original["audience"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAudience); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["audience"] = transformedAudience - } - - transformedToken, err := expandIntegrationsAuthConfigDecryptedCredentialOidcTokenToken(original["token"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedToken); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["token"] = transformedToken - } - - transformedTokenExpireTime, err := expandIntegrationsAuthConfigDecryptedCredentialOidcTokenTokenExpireTime(original["token_expire_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTokenExpireTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["tokenExpireTime"] = transformedTokenExpireTime - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOidcTokenServiceAccountEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOidcTokenAudience(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOidcTokenToken(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigDecryptedCredentialOidcTokenTokenExpireTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigClientCertificate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSslCertificate, err := expandIntegrationsAuthConfigClientCertificateSslCertificate(original["ssl_certificate"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSslCertificate); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["ssl_certificate"] = transformedSslCertificate - } - - transformedEncryptedPrivateKey, err := expandIntegrationsAuthConfigClientCertificateEncryptedPrivateKey(original["encrypted_private_key"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEncryptedPrivateKey); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["encrypted_private_key"] = transformedEncryptedPrivateKey - } - - transformedPassphrase, err := expandIntegrationsAuthConfigClientCertificatePassphrase(original["passphrase"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPassphrase); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["passphrase"] = transformedPassphrase - } - - return transformed, nil -} - -func expandIntegrationsAuthConfigClientCertificateSslCertificate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigClientCertificateEncryptedPrivateKey(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsAuthConfigClientCertificatePassphrase(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_auth_config_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_auth_config_sweeper.go deleted file mode 100644 index 07de3f2d922..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_auth_config_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package integrations - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("IntegrationsAuthConfig", testSweepIntegrationsAuthConfig) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepIntegrationsAuthConfig(region string) error { - resourceName := "IntegrationsAuthConfig" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://integrations.googleapis.com/v1/projects/{{project}}/locations/{{location}}/authConfigs", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["authConfigs"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://integrations.googleapis.com/v1/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_client.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_client.go deleted file mode 100644 index 6c013ce7ea8..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_client.go +++ /dev/null @@ -1,469 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package integrations - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceIntegrationsClient() *schema.Resource { - return &schema.Resource{ - Create: resourceIntegrationsClientCreate, - Read: resourceIntegrationsClientRead, - Delete: resourceIntegrationsClientDelete, - - Importer: &schema.ResourceImporter{ - State: resourceIntegrationsClientImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Location in which client needs to be provisioned.`, - }, - "cloud_kms_config": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Cloud KMS config for AuthModule to encrypt/decrypt credentials.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `A Cloud KMS key is a named object containing one or more key versions, along -with metadata for the key. A key exists on exactly one key ring tied to a -specific location.`, - }, - "kms_location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Location name of the key ring, e.g. "us-west1".`, - }, - "kms_ring": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `A key ring organizes keys in a specific Google Cloud location and allows you to -manage access control on groups of keys. A key ring's name does not need to be -unique across a Google Cloud project, but must be unique within a given location.`, - }, - "key_version": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Each version of a key contains key material used for encryption or signing. -A key's version is represented by an integer, starting at 1. To decrypt data -or verify a signature, you must use the same key version that was used to -encrypt or sign the data.`, - }, - "kms_project_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The Google Cloud project id of the project where the kms key stored. If empty, -the kms key is stored at the same project as customer's project and ecrypted -with CMEK, otherwise, the kms key is stored in the tenant project and -encrypted with GMEK.`, - }, - }, - }, - ConflictsWith: []string{"provision_gmek"}, - }, - "create_sample_integrations": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `Indicates if sample integrations should be created along with provisioning.`, - ConflictsWith: []string{"create_sample_workflows"}, - }, - "create_sample_workflows": { - Type: schema.TypeBool, - Optional: true, - Deprecated: "`create_sample_workflows` is deprecated and will be removed in a future major release. Use `create_sample_integrations` instead.", - ForceNew: true, - Description: `Indicates if sample workflow should be created along with provisioning.`, - ConflictsWith: []string{"create_sample_integrations"}, - }, - "provision_gmek": { - Type: schema.TypeBool, - Optional: true, - Deprecated: "`provision_gmek` is deprecated and will be removed in a future major release. Client would be provisioned as gmek if `cloud_kms_config` is not given.", - ForceNew: true, - Description: `Indicates provision with GMEK or CMEK.`, - ConflictsWith: []string{"cloud_kms_config"}, - }, - "run_as_service_account": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `User input run-as service account, if empty, will bring up a new default service account.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceIntegrationsClientCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - cloudKmsConfigProp, err := expandIntegrationsClientCloudKmsConfig(d.Get("cloud_kms_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("cloud_kms_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(cloudKmsConfigProp)) && (ok || !reflect.DeepEqual(v, cloudKmsConfigProp)) { - obj["cloudKmsConfig"] = cloudKmsConfigProp - } - createSampleWorkflowsProp, err := expandIntegrationsClientCreateSampleWorkflows(d.Get("create_sample_workflows"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("create_sample_workflows"); !tpgresource.IsEmptyValue(reflect.ValueOf(createSampleWorkflowsProp)) && (ok || !reflect.DeepEqual(v, createSampleWorkflowsProp)) { - obj["createSampleWorkflows"] = createSampleWorkflowsProp - } - createSampleIntegrationsProp, err := expandIntegrationsClientCreateSampleIntegrations(d.Get("create_sample_integrations"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("create_sample_integrations"); !tpgresource.IsEmptyValue(reflect.ValueOf(createSampleIntegrationsProp)) && (ok || !reflect.DeepEqual(v, createSampleIntegrationsProp)) { - obj["createSampleIntegrations"] = createSampleIntegrationsProp - } - provisionGmekProp, err := expandIntegrationsClientProvisionGmek(d.Get("provision_gmek"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("provision_gmek"); !tpgresource.IsEmptyValue(reflect.ValueOf(provisionGmekProp)) && (ok || !reflect.DeepEqual(v, provisionGmekProp)) { - obj["provisionGmek"] = provisionGmekProp - } - runAsServiceAccountProp, err := expandIntegrationsClientRunAsServiceAccount(d.Get("run_as_service_account"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("run_as_service_account"); !tpgresource.IsEmptyValue(reflect.ValueOf(runAsServiceAccountProp)) && (ok || !reflect.DeepEqual(v, runAsServiceAccountProp)) { - obj["runAsServiceAccount"] = runAsServiceAccountProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "Client/{{location}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}projects/{{project}}/locations/{{location}}/clients:provision") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new Client: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Client: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - // Translate `createSampleIntegrations` to `createSampleWorkflows` - if val, ok := obj["createSampleIntegrations"]; ok { - delete(obj, "createSampleIntegrations") - obj["createSampleWorkflows"] = val - } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating Client: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/clients") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating Client %q: %#v", d.Id(), res) - - return resourceIntegrationsClientRead(d, meta) -} - -func resourceIntegrationsClientRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}projects/{{project}}/locations/{{location}}/clients") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Client: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("IntegrationsClient %q", d.Id())) - } - - res, err = resourceIntegrationsClientDecoder(d, meta, res) - if err != nil { - return err - } - - if res == nil { - // Decoding the object has resulted in it being gone. It may be marked deleted - log.Printf("[DEBUG] Removing IntegrationsClient because it no longer exists.") - d.SetId("") - return nil - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading Client: %s", err) - } - - return nil -} - -func resourceIntegrationsClientDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Client: %s", err) - } - billingProject = project - - lockName, err := tpgresource.ReplaceVars(d, config, "Client/{{location}}") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{IntegrationsBasePath}}projects/{{project}}/locations/{{location}}/clients:deprovision") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting Client %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "Client") - } - - log.Printf("[DEBUG] Finished deleting Client %q: %#v", d.Id(), res) - return nil -} - -func resourceIntegrationsClientImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/clients$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/clients") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func expandIntegrationsClientCloudKmsConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKmsLocation, err := expandIntegrationsClientCloudKmsConfigKmsLocation(original["kms_location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKmsLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["kmsLocation"] = transformedKmsLocation - } - - transformedKmsRing, err := expandIntegrationsClientCloudKmsConfigKmsRing(original["kms_ring"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKmsRing); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["kmsRing"] = transformedKmsRing - } - - transformedKey, err := expandIntegrationsClientCloudKmsConfigKey(original["key"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKey); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["key"] = transformedKey - } - - transformedKeyVersion, err := expandIntegrationsClientCloudKmsConfigKeyVersion(original["key_version"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKeyVersion); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["keyVersion"] = transformedKeyVersion - } - - transformedKmsProjectId, err := expandIntegrationsClientCloudKmsConfigKmsProjectId(original["kms_project_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKmsProjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["kmsProjectId"] = transformedKmsProjectId - } - - return transformed, nil -} - -func expandIntegrationsClientCloudKmsConfigKmsLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientCloudKmsConfigKmsRing(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientCloudKmsConfigKey(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientCloudKmsConfigKeyVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientCloudKmsConfigKmsProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientCreateSampleWorkflows(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientCreateSampleIntegrations(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientProvisionGmek(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandIntegrationsClientRunAsServiceAccount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func resourceIntegrationsClientDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - // Since Client resource doesnt have any properties, - // Adding this decoder as placeholder else the linter will - // complain that the returned `res` is never used afterwards. - return res, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_client_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_client_sweeper.go deleted file mode 100644 index 4fc383f7553..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/integrations/resource_integrations_client_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package integrations - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("IntegrationsClient", testSweepIntegrationsClient) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepIntegrationsClient(region string) error { - resourceName := "IntegrationsClient" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://integrations.googleapis.com/v1/projects/{{project}}/locations/{{location}}/clients", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["clients"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://integrations.googleapis.com/v1/projects/{{project}}/locations/{{location}}/clients:deprovision" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/data_source_google_kms_crypto_keys.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/data_source_google_kms_crypto_keys.go deleted file mode 100644 index 9ca2091d3e4..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/data_source_google_kms_crypto_keys.go +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package kms - -import ( - "fmt" - "log" - "net/http" - "regexp" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleKmsCryptoKeys() *schema.Resource { - dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceKMSCryptoKey().Schema) - tpgresource.AddOptionalFieldsToSchema(dsSchema, "name") - tpgresource.AddOptionalFieldsToSchema(dsSchema, "key_ring") - - // We need to explicitly add the id field to the schema used for individual keys - // Currently the id field in the google_kms_crypto_key resource is implied/added by the SDK - dsSchema["id"] = &schema.Schema{ - Type: schema.TypeString, - Computed: true, - } - - return &schema.Resource{ - Read: dataSourceGoogleKmsCryptoKeysRead, - Schema: map[string]*schema.Schema{ - "key_ring": { - Type: schema.TypeString, - Required: true, - Description: `The key ring that the keys belongs to. Format: 'projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}'.`, - }, - "filter": { - Type: schema.TypeString, - Optional: true, - Description: ` - The filter argument is used to add a filter query parameter that limits which keys are retrieved by the data source: ?filter={{filter}}. - Example values: - - * "name:my-key-" will retrieve keys that contain "my-key-" anywhere in their name. Note: names take the form projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}/cryptoKeys/{{cryptoKey}}. - * "name=projects/my-project/locations/global/keyRings/my-key-ring/cryptoKeys/my-key-1" will only retrieve a key with that exact name. - - [See the documentation about using filters](https://cloud.google.com/kms/docs/sorting-and-filtering) - `, - }, - "keys": { - Type: schema.TypeList, - Computed: true, - Description: "A list of all the retrieved keys from the provided key ring", - Elem: &schema.Resource{ - Schema: dsSchema, - }, - }, - }, - } -} - -func dataSourceGoogleKmsCryptoKeysRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - - keyRingId, err := parseKmsKeyRingId(d.Get("key_ring").(string), config) - if err != nil { - return err - } - - id := fmt.Sprintf("%s/cryptoKeys", keyRingId.KeyRingId()) - if filter, ok := d.GetOk("filter"); ok { - id += "/filter=" + filter.(string) - } - d.SetId(id) - - log.Printf("[DEBUG] Searching for keys in key ring %s", keyRingId.KeyRingId()) - keys, err := dataSourceKMSCryptoKeysList(d, meta, keyRingId.KeyRingId()) - if err != nil { - return err - } - - if len(keys) > 0 { - log.Printf("[DEBUG] Found %d keys in key ring %s", len(keys), keyRingId.KeyRingId()) - value, err := flattenKMSKeysList(d, config, keys, keyRingId.KeyRingId()) - if err != nil { - return fmt.Errorf("error flattening keys list: %s", err) - } - if err := d.Set("keys", value); err != nil { - return fmt.Errorf("error setting keys: %s", err) - } - } else { - log.Printf("[DEBUG] Found 0 keys in key ring %s", keyRingId.KeyRingId()) - } - - return nil -} - -// dataSourceKMSCryptoKeysList calls the list endpoint for Crypto Key resources and collects all keys in a slice. -// This function handles pagination by collecting the resources returned by multiple calls to the list endpoint. -// This function also handles server-side filtering by setting the filter query parameter on each API call. -func dataSourceKMSCryptoKeysList(d *schema.ResourceData, meta interface{}, keyRingId string) ([]interface{}, error) { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return nil, err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{KMSBasePath}}{{key_ring}}/cryptoKeys") - if err != nil { - return nil, err - } - - billingProject := "" - - if parts := regexp.MustCompile(`projects\/([^\/]+)\/`).FindStringSubmatch(url); parts != nil { - billingProject = parts[1] - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // Always include the filter param, and optionally include the pageToken parameter for subsequent requests - var params = make(map[string]string, 0) - if filter, ok := d.GetOk("filter"); ok { - log.Printf("[DEBUG] Search for keys in key ring %s is using filter ?filter=%s", keyRingId, filter.(string)) - params["filter"] = filter.(string) - } - - cryptoKeys := make([]interface{}, 0) - for { - // Depending on previous iterations, params might contain a pageToken param - url, err = transport_tpg.AddQueryParams(url, params) - if err != nil { - return nil, err - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - // ErrorRetryPredicates used to allow retrying if rate limits are hit when requesting multiple pages in a row - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429RetryableQuotaError}, - }) - if err != nil { - return nil, transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSCryptoKeys %q", d.Id())) - } - - if res == nil { - // Decoding the object has resulted in it being gone. It may be marked deleted - log.Printf("[DEBUG] Removing KMSCryptoKey because it no longer exists.") - d.SetId("") - return nil, nil - } - - // Store info from this page - if v, ok := res["cryptoKeys"].([]interface{}); ok { - cryptoKeys = append(cryptoKeys, v...) - } - - // Handle pagination for next loop, or break loop - v, ok := res["nextPageToken"] - if ok { - params["pageToken"] = v.(string) - } - if !ok { - break - } - } - return cryptoKeys, nil -} - -// flattenKMSKeysList flattens a list of crypto keys from a given crypto key ring -func flattenKMSKeysList(d *schema.ResourceData, config *transport_tpg.Config, keysList []interface{}, keyRingId string) ([]interface{}, error) { - var keys []interface{} - for _, k := range keysList { - key := k.(map[string]interface{}) - parsedId, err := ParseKmsCryptoKeyId(key["name"].(string), config) - if err != nil { - return nil, err - } - - data := map[string]interface{}{} - // The google_kms_crypto_key resource and dataset set - // id as the value of name (projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}/cryptoKeys/{{name}}) - // and set name is set as just {{name}}. - data["id"] = key["name"] - data["name"] = parsedId.Name - data["key_ring"] = keyRingId - - data["labels"] = flattenKMSCryptoKeyLabels(key["labels"], d, config) - data["primary"] = flattenKMSCryptoKeyPrimary(key["primary"], d, config) - data["purpose"] = flattenKMSCryptoKeyPurpose(key["purpose"], d, config) - data["rotation_period"] = flattenKMSCryptoKeyRotationPeriod(key["rotationPeriod"], d, config) - data["version_template"] = flattenKMSCryptoKeyVersionTemplate(key["versionTemplate"], d, config) - data["destroy_scheduled_duration"] = flattenKMSCryptoKeyDestroyScheduledDuration(key["destroyScheduledDuration"], d, config) - data["import_only"] = flattenKMSCryptoKeyImportOnly(key["importOnly"], d, config) - data["crypto_key_backend"] = flattenKMSCryptoKeyCryptoKeyBackend(key["cryptoKeyBackend"], d, config) - keys = append(keys, data) - } - - return keys, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/data_source_google_kms_key_rings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/data_source_google_kms_key_rings.go deleted file mode 100644 index 35b027cf781..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/data_source_google_kms_key_rings.go +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package kms - -import ( - "fmt" - "log" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleKmsKeyRings() *schema.Resource { - return &schema.Resource{ - Read: dataSourceGoogleKmsKeyRingsRead, - Schema: map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Optional: true, - Description: `Project ID of the project.`, - }, - "location": { - Type: schema.TypeString, - Required: true, - Description: `The canonical id for the location. For example: "us-east1".`, - }, - "filter": { - Type: schema.TypeString, - Optional: true, - Description: ` - The filter argument is used to add a filter query parameter that limits which keys are retrieved by the data source: ?filter={{filter}}. - Example values: - - * "name:my-key-" will retrieve key rings that contain "my-key-" anywhere in their name. Note: names take the form projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}. - * "name=projects/my-project/locations/global/keyRings/my-key-ring" will only retrieve a key ring with that exact name. - - [See the documentation about using filters](https://cloud.google.com/kms/docs/sorting-and-filtering) - `, - }, - "key_rings": { - Type: schema.TypeList, - Computed: true, - Description: "A list of all the retrieved key rings", - Elem: &schema.Resource{ - // schema isn't used from resource_kms_key_ring due to having project and location fields which are empty when grabbed in a list. - Schema: map[string]*schema.Schema{ - "id": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func dataSourceGoogleKmsKeyRingsRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/keyRings") - if err != nil { - return err - } - if filter, ok := d.GetOk("filter"); ok { - id += "/filter=" + filter.(string) - } - d.SetId(id) - - log.Printf("[DEBUG] Searching for keyrings") - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for keyRings: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - var keyRings []interface{} - - params := make(map[string]string) - if filter, ok := d.GetOk("filter"); ok { - log.Printf("[DEBUG] Search for key rings using filter ?filter=%s", filter.(string)) - params["filter"] = filter.(string) - if err != nil { - return err - } - } - - url, err := tpgresource.ReplaceVars(d, config, "{{KMSBasePath}}projects/{{project}}/locations/{{location}}/keyRings") - if err != nil { - return err - } - - for { - url, err = transport_tpg.AddQueryParams(url, params) - if err != nil { - return err - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429RetryableQuotaError}, - }) - if err != nil { - return fmt.Errorf("Error retrieving buckets: %s", err) - } - - if res["keyRings"] == nil { - break - } - pageKeyRings, err := flattenKMSKeyRingsList(config, res["keyRings"]) - if err != nil { - return fmt.Errorf("error flattening key rings list: %s", err) - } - keyRings = append(keyRings, pageKeyRings...) - - pToken, ok := res["nextPageToken"] - if ok && pToken != nil && pToken.(string) != "" { - params["pageToken"] = pToken.(string) - } else { - break - } - } - - log.Printf("[DEBUG] Found %d key rings", len(keyRings)) - if err := d.Set("key_rings", keyRings); err != nil { - return fmt.Errorf("error setting key rings: %s", err) - } - - return nil -} - -// flattenKMSKeyRingsList flattens a list of key rings -func flattenKMSKeyRingsList(config *transport_tpg.Config, keyRingsList interface{}) ([]interface{}, error) { - var keyRings []interface{} - for _, k := range keyRingsList.([]interface{}) { - keyRing := k.(map[string]interface{}) - - parsedId, err := parseKmsKeyRingId(keyRing["name"].(string), config) - if err != nil { - return nil, err - } - - data := map[string]interface{}{} - // The google_kms_key_rings resource and dataset set - // id as the value of name (projects/{{project}}/locations/{{location}}/keyRings/{{name}}) - // and set name is set as just {{name}}. - data["id"] = keyRing["name"] - data["name"] = parsedId.Name - - keyRings = append(keyRings, data) - } - - return keyRings, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/kms_operation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/kms_operation.go deleted file mode 100644 index 9e87561645d..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/kms_operation.go +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package kms - -import ( - "encoding/json" - "errors" - "fmt" - "time" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -type KMSOperationWaiter struct { - Config *transport_tpg.Config - UserAgent string - Project string - tpgresource.CommonOperationWaiter -} - -func (w *KMSOperationWaiter) QueryOp() (interface{}, error) { - if w == nil { - return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") - } - // Returns the proper get. - url := fmt.Sprintf("%s%s", w.Config.KMSBasePath, w.CommonOperationWaiter.Op.Name) - - return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: w.Config, - Method: "GET", - Project: w.Project, - RawURL: url, - UserAgent: w.UserAgent, - }) -} - -func createKMSWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*KMSOperationWaiter, error) { - w := &KMSOperationWaiter{ - Config: config, - UserAgent: userAgent, - Project: project, - } - if err := w.CommonOperationWaiter.SetOp(op); err != nil { - return nil, err - } - return w, nil -} - -// nolint: deadcode,unused -func KMSOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { - w, err := createKMSWaiter(config, op, project, activity, userAgent) - if err != nil { - return err - } - if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil { - return err - } - rawResponse := []byte(w.CommonOperationWaiter.Op.Response) - if len(rawResponse) == 0 { - return errors.New("`resource` not set in operation response") - } - return json.Unmarshal(rawResponse, response) -} - -func KMSOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { - if val, ok := op["name"]; !ok || val == "" { - // This was a synchronous call - there is no operation to wait for. - return nil - } - w, err := createKMSWaiter(config, op, project, activity, userAgent) - if err != nil { - // If w is nil, the op was synchronous. - return err - } - return tpgresource.OperationWait(w, activity, timeout, config.PollInterval) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key.go index c83316c7f3c..deca75a29b6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -80,21 +79,13 @@ Format: ''projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}''.`, ForceNew: true, Description: `The resource name for the CryptoKey.`, }, - "crypto_key_backend": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `The resource name of the backend environment associated with all CryptoKeyVersions within this CryptoKey. -The resource name is in the format "projects/*/locations/*/ekmConnections/*" and only applies to "EXTERNAL_VPC" keys.`, - }, "destroy_scheduled_duration": { Type: schema.TypeString, Computed: true, Optional: true, ForceNew: true, Description: `The period of time that versions of this key spend in the DESTROY_SCHEDULED state before transitioning to DESTROYED. -If not specified at creation time, the default duration is 30 days.`, +If not specified at creation time, the default duration is 24 hours.`, }, "import_only": { Type: schema.TypeBool, @@ -137,8 +128,7 @@ letter 's' (seconds). It must be greater than a day (ie, 86400).`, Optional: true, ForceNew: true, Description: `If set to true, the request will create a CryptoKey without any CryptoKeyVersions. -You must use the 'google_kms_crypto_key_version' resource to create a new CryptoKeyVersion -or 'google_kms_key_ring_import_job' resource to import the CryptoKeyVersion.`, +You must use the 'google_kms_key_ring_import_job' resource to import the CryptoKeyVersion.`, }, "version_template": { Type: schema.TypeList, @@ -240,12 +230,6 @@ func resourceKMSCryptoKeyCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("import_only"); !tpgresource.IsEmptyValue(reflect.ValueOf(importOnlyProp)) && (ok || !reflect.DeepEqual(v, importOnlyProp)) { obj["importOnly"] = importOnlyProp } - cryptoKeyBackendProp, err := expandKMSCryptoKeyCryptoKeyBackend(d.Get("crypto_key_backend"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("crypto_key_backend"); !tpgresource.IsEmptyValue(reflect.ValueOf(cryptoKeyBackendProp)) && (ok || !reflect.DeepEqual(v, cryptoKeyBackendProp)) { - obj["cryptoKeyBackend"] = cryptoKeyBackendProp - } labelsProp, err := expandKMSCryptoKeyEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -275,7 +259,6 @@ func resourceKMSCryptoKeyCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -284,7 +267,6 @@ func resourceKMSCryptoKeyCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CryptoKey: %s", err) @@ -325,14 +307,12 @@ func resourceKMSCryptoKeyRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSCryptoKey %q", d.Id())) @@ -371,9 +351,6 @@ func resourceKMSCryptoKeyRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("import_only", flattenKMSCryptoKeyImportOnly(res["importOnly"], d, config)); err != nil { return fmt.Errorf("Error reading CryptoKey: %s", err) } - if err := d.Set("crypto_key_backend", flattenKMSCryptoKeyCryptoKeyBackend(res["cryptoKeyBackend"], d, config)); err != nil { - return fmt.Errorf("Error reading CryptoKey: %s", err) - } if err := d.Set("terraform_labels", flattenKMSCryptoKeyTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading CryptoKey: %s", err) } @@ -424,7 +401,6 @@ func resourceKMSCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating CryptoKey %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("rotation_period") { @@ -464,7 +440,6 @@ func resourceKMSCryptoKeyUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -618,10 +593,6 @@ func flattenKMSCryptoKeyImportOnly(v interface{}, d *schema.ResourceData, config return v } -func flattenKMSCryptoKeyCryptoKeyBackend(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenKMSCryptoKeyTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -691,10 +662,6 @@ func expandKMSCryptoKeyImportOnly(v interface{}, d tpgresource.TerraformResource return v, nil } -func expandKMSCryptoKeyCryptoKeyBackend(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandKMSCryptoKeyEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key_version.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key_version.go index 68e5472cd93..34fa11a6f6f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key_version.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_crypto_key_version.go @@ -20,7 +20,6 @@ package kms import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -57,26 +56,6 @@ func ResourceKMSCryptoKeyVersion() *schema.Resource { Description: `The name of the cryptoKey associated with the CryptoKeyVersions. Format: ''projects/{{project}}/locations/{{location}}/keyRings/{{keyring}}/cryptoKeys/{{cryptoKey}}''`, }, - "external_protection_level_options": { - Type: schema.TypeList, - Optional: true, - Description: `ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "ekm_connection_key_path": { - Type: schema.TypeString, - Optional: true, - Description: `The path to the external key material on the EKM when using EkmConnection e.g., "v0/my/key". Set this field instead of externalKeyUri when using an EkmConnection.`, - }, - "external_key_uri": { - Type: schema.TypeString, - Optional: true, - Description: `The URI for an external resource that this CryptoKeyVersion represents.`, - }, - }, - }, - }, "state": { Type: schema.TypeString, Computed: true, @@ -133,7 +112,6 @@ Only provided for key versions with protectionLevel HSM.`, "external_protection_level_options": { Type: schema.TypeList, Optional: true, - Deprecated: "`externalProtectionLevelOptions` is being un-nested from the `attestation` field. Please use the top level `externalProtectionLevelOptions` field instead.", Description: `ExternalProtectionLevelOptions stores a group of additional fields for configuring a CryptoKeyVersion that are specific to the EXTERNAL protection level and EXTERNAL_VPC protection levels.`, MaxItems: 1, Elem: &schema.Resource{ @@ -198,12 +176,6 @@ func resourceKMSCryptoKeyVersionCreate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("state"); !tpgresource.IsEmptyValue(reflect.ValueOf(stateProp)) && (ok || !reflect.DeepEqual(v, stateProp)) { obj["state"] = stateProp } - externalProtectionLevelOptionsProp, err := expandKMSCryptoKeyVersionExternalProtectionLevelOptions(d.Get("external_protection_level_options"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("external_protection_level_options"); !tpgresource.IsEmptyValue(reflect.ValueOf(externalProtectionLevelOptionsProp)) && (ok || !reflect.DeepEqual(v, externalProtectionLevelOptionsProp)) { - obj["externalProtectionLevelOptions"] = externalProtectionLevelOptionsProp - } url, err := tpgresource.ReplaceVars(d, config, "{{KMSBasePath}}{{crypto_key}}/cryptoKeyVersions") if err != nil { @@ -218,7 +190,6 @@ func resourceKMSCryptoKeyVersionCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -227,7 +198,6 @@ func resourceKMSCryptoKeyVersionCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CryptoKeyVersion: %s", err) @@ -267,14 +237,12 @@ func resourceKMSCryptoKeyVersionRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSCryptoKeyVersion %q", d.Id())) @@ -298,9 +266,6 @@ func resourceKMSCryptoKeyVersionRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("attestation", flattenKMSCryptoKeyVersionAttestation(res["attestation"], d, config)); err != nil { return fmt.Errorf("Error reading CryptoKeyVersion: %s", err) } - if err := d.Set("external_protection_level_options", flattenKMSCryptoKeyVersionExternalProtectionLevelOptions(res["externalProtectionLevelOptions"], d, config)); err != nil { - return fmt.Errorf("Error reading CryptoKeyVersion: %s", err) - } return nil } @@ -321,12 +286,6 @@ func resourceKMSCryptoKeyVersionUpdate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("state"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, stateProp)) { obj["state"] = stateProp } - externalProtectionLevelOptionsProp, err := expandKMSCryptoKeyVersionExternalProtectionLevelOptions(d.Get("external_protection_level_options"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("external_protection_level_options"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, externalProtectionLevelOptionsProp)) { - obj["externalProtectionLevelOptions"] = externalProtectionLevelOptionsProp - } url, err := tpgresource.ReplaceVars(d, config, "{{KMSBasePath}}{{name}}") if err != nil { @@ -334,42 +293,17 @@ func resourceKMSCryptoKeyVersionUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating CryptoKeyVersion %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("state") { updateMask = append(updateMask, "state") } - - if d.HasChange("external_protection_level_options") { - updateMask = append(updateMask, "externalProtectionLevelOptions") - } // updateMask is a URL parameter but not present in the schema, so ReplaceVars // won't set it url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) if err != nil { return err } - // The generated code does not support conditional update masks. - newUpdateMask := []string{} - if d.HasChange("state") { - newUpdateMask = append(newUpdateMask, "state") - } - - // Validate updated fields based on protection level (EXTERNAL vs EXTERNAL_VPC) - if d.HasChange("external_protection_level_options") { - if d.Get("protection_level") == "EXTERNAL" { - newUpdateMask = append(newUpdateMask, "externalProtectionLevelOptions.externalKeyUri") - } else if d.Get("protection_level") == "EXTERNAL_VPC" { - newUpdateMask = append(newUpdateMask, "externalProtectionLevelOptions.ekmConnectionKeyPath") - } - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")}) - if err != nil { - return err - } // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -386,7 +320,6 @@ func resourceKMSCryptoKeyVersionUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -543,63 +476,6 @@ func flattenKMSCryptoKeyVersionAttestationExternalProtectionLevelOptionsEkmConne return v } -func flattenKMSCryptoKeyVersionExternalProtectionLevelOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["external_key_uri"] = - flattenKMSCryptoKeyVersionExternalProtectionLevelOptionsExternalKeyUri(original["externalKeyUri"], d, config) - transformed["ekm_connection_key_path"] = - flattenKMSCryptoKeyVersionExternalProtectionLevelOptionsEkmConnectionKeyPath(original["ekmConnectionKeyPath"], d, config) - return []interface{}{transformed} -} -func flattenKMSCryptoKeyVersionExternalProtectionLevelOptionsExternalKeyUri(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenKMSCryptoKeyVersionExternalProtectionLevelOptionsEkmConnectionKeyPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandKMSCryptoKeyVersionState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func expandKMSCryptoKeyVersionExternalProtectionLevelOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExternalKeyUri, err := expandKMSCryptoKeyVersionExternalProtectionLevelOptionsExternalKeyUri(original["external_key_uri"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExternalKeyUri); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["externalKeyUri"] = transformedExternalKeyUri - } - - transformedEkmConnectionKeyPath, err := expandKMSCryptoKeyVersionExternalProtectionLevelOptionsEkmConnectionKeyPath(original["ekm_connection_key_path"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEkmConnectionKeyPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["ekmConnectionKeyPath"] = transformedEkmConnectionKeyPath - } - - return transformed, nil -} - -func expandKMSCryptoKeyVersionExternalProtectionLevelOptionsExternalKeyUri(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandKMSCryptoKeyVersionExternalProtectionLevelOptionsEkmConnectionKeyPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_ekm_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_ekm_connection.go index 6cace2c4819..68709d22265 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_ekm_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_ekm_connection.go @@ -20,7 +20,6 @@ package kms import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -248,7 +247,6 @@ func resourceKMSEkmConnectionCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -257,7 +255,6 @@ func resourceKMSEkmConnectionCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EkmConnection: %s", err) @@ -300,14 +297,12 @@ func resourceKMSEkmConnectionRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSEkmConnection %q", d.Id())) @@ -386,7 +381,6 @@ func resourceKMSEkmConnectionUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating EkmConnection %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("service_resolvers") { @@ -426,7 +420,6 @@ func resourceKMSEkmConnectionUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring.go index 46fb188f7bb..72fed68b8d1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring.go @@ -20,7 +20,6 @@ package kms import ( "fmt" "log" - "net/http" "reflect" "time" @@ -120,7 +119,6 @@ func resourceKMSKeyRingCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -129,7 +127,6 @@ func resourceKMSKeyRingCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating KeyRing: %s", err) @@ -172,14 +169,12 @@ func resourceKMSKeyRingRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSKeyRing %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring_import_job.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring_import_job.go index bf196bd6c09..3db8fa263d4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring_import_job.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_key_ring_import_job.go @@ -20,7 +20,6 @@ package kms import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -169,7 +168,6 @@ func resourceKMSKeyRingImportJobCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -178,7 +176,6 @@ func resourceKMSKeyRingImportJobCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating KeyRingImportJob: %s", err) @@ -218,14 +215,12 @@ func resourceKMSKeyRingImportJobRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSKeyRingImportJob %q", d.Id())) @@ -277,8 +272,6 @@ func resourceKMSKeyRingImportJobDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting KeyRingImportJob %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -288,7 +281,6 @@ func resourceKMSKeyRingImportJobDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "KeyRingImportJob") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_secret_ciphertext.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_secret_ciphertext.go index 722cd1cfd12..46bdb185d9c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_secret_ciphertext.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/kms/resource_kms_secret_ciphertext.go @@ -21,7 +21,6 @@ import ( "encoding/base64" "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -113,7 +112,6 @@ func resourceKMSSecretCiphertextCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -122,7 +120,6 @@ func resourceKMSSecretCiphertextCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SecretCiphertext: %s", err) @@ -178,14 +175,12 @@ func resourceKMSSecretCiphertextRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("KMSSecretCiphertext %q", d.Id())) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/logging_exclusion_folder.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/logging_exclusion_folder.go index 846288eeea0..58d9dfcb2f2 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/logging_exclusion_folder.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/logging_exclusion_folder.go @@ -13,18 +13,12 @@ import ( "google.golang.org/api/logging/v2" ) -func OptionalPrefixSuppress(prefix string) schema.SchemaDiffSuppressFunc { - return func(k, old, new string, d *schema.ResourceData) bool { - return prefix+old == new || prefix+new == old - } -} - var FolderLoggingExclusionSchema = map[string]*schema.Schema{ "folder": { Type: schema.TypeString, Required: true, ForceNew: true, - DiffSuppressFunc: OptionalPrefixSuppress("folders/"), + DiffSuppressFunc: tpgresource.OptionalPrefixSuppress("folders/"), }, } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_bucket_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_bucket_config.go index e0d33e82a07..336d3970e20 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_bucket_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_bucket_config.go @@ -95,7 +95,6 @@ See [Enabling CMEK for Logging Buckets](https://cloud.google.com/logging/docs/ro Type: schema.TypeSet, MaxItems: 20, Optional: true, - Computed: true, Description: `A list of indexed fields and related configuration data.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_settings.go index 124767478c2..7f9a48b3b73 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_settings.go @@ -20,7 +20,6 @@ package logging import ( "fmt" "log" - "net/http" "reflect" "time" @@ -132,7 +131,6 @@ func resourceLoggingFolderSettingsCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -141,7 +139,6 @@ func resourceLoggingFolderSettingsCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FolderSettings: %s", err) @@ -181,14 +178,12 @@ func resourceLoggingFolderSettingsRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("LoggingFolderSettings %q", d.Id())) @@ -251,7 +246,6 @@ func resourceLoggingFolderSettingsUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating FolderSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -266,7 +260,6 @@ func resourceLoggingFolderSettingsUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_sink.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_sink.go index a77293b10a0..8df1066da24 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_sink.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_folder_sink.go @@ -36,15 +36,10 @@ func ResourceLoggingFolderSink() *schema.Resource { schm.Schema["include_children"] = &schema.Schema{ Type: schema.TypeBool, Optional: true, + ForceNew: true, Default: false, Description: `Whether or not to include children folders in the sink export. If true, logs associated with child projects are also exported; otherwise only logs relating to the provided folder are included.`, } - schm.Schema["intercept_children"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: `Whether or not to intercept logs from child projects. If true, matching logs will not match with sinks in child resources, except _Required sinks. This sink will be visible to child resources when listing sinks.`, - } return schm } @@ -59,7 +54,6 @@ func resourceLoggingFolderSinkCreate(d *schema.ResourceData, meta interface{}) e folder := resourcemanager.ParseFolderId(d.Get("folder")) id, sink := expandResourceLoggingSink(d, "folders", folder) sink.IncludeChildren = d.Get("include_children").(bool) - sink.InterceptChildren = d.Get("intercept_children").(bool) // The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true. _, err = config.NewLoggingClient(userAgent).Folders.Sinks.Create(id.parent(), sink).UniqueWriterIdentity(true).Do() @@ -91,10 +85,6 @@ func resourceLoggingFolderSinkRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting include_children: %s", err) } - if err := d.Set("intercept_children", sink.InterceptChildren); err != nil { - return fmt.Errorf("Error setting intercept_children: %s", err) - } - return nil } @@ -106,6 +96,10 @@ func resourceLoggingFolderSinkUpdate(d *schema.ResourceData, meta interface{}) e } sink, updateMask := expandResourceLoggingSinkForUpdate(d) + // It seems the API might actually accept an update for include_children; this is not in the list of updatable + // properties though and might break in the future. Always include the value to prevent it changing. + sink.IncludeChildren = d.Get("include_children").(bool) + sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren") // The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true. _, err = config.NewLoggingClient(userAgent).Folders.Sinks.Patch(d.Id(), sink). diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_linked_dataset.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_linked_dataset.go index de027fb9bac..ea16859a85d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_linked_dataset.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_linked_dataset.go @@ -20,7 +20,6 @@ package logging import ( "fmt" "log" - "net/http" "reflect" "time" @@ -156,7 +155,6 @@ func resourceLoggingLinkedDatasetCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -165,7 +163,6 @@ func resourceLoggingLinkedDatasetCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating LinkedDataset: %s", err) @@ -226,14 +223,12 @@ func resourceLoggingLinkedDatasetRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("LoggingLinkedDataset %q", d.Id())) @@ -279,8 +274,6 @@ func resourceLoggingLinkedDatasetDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting LinkedDataset %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -290,7 +283,6 @@ func resourceLoggingLinkedDatasetDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "LinkedDataset") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_log_view.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_log_view.go index fd50ea2a5aa..969aff5a4a4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_log_view.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_log_view.go @@ -20,7 +20,6 @@ package logging import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -148,7 +147,6 @@ func resourceLoggingLogViewCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -157,7 +155,6 @@ func resourceLoggingLogViewCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating LogView: %s", err) @@ -194,14 +191,12 @@ func resourceLoggingLogViewRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("LoggingLogView %q", d.Id())) @@ -257,7 +252,6 @@ func resourceLoggingLogViewUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating LogView %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -289,7 +283,6 @@ func resourceLoggingLogViewUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -324,8 +317,6 @@ func resourceLoggingLogViewDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting LogView %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -335,7 +326,6 @@ func resourceLoggingLogViewDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "LogView") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_metric.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_metric.go index 51384cbe86c..8b575833801 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_metric.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_metric.go @@ -20,7 +20,6 @@ package logging import ( "fmt" "log" - "net/http" "reflect" "time" @@ -371,7 +370,6 @@ func resourceLoggingMetricCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -380,7 +378,6 @@ func resourceLoggingMetricCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Metric: %s", err) @@ -441,14 +438,12 @@ func resourceLoggingMetricRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("LoggingMetric %q", d.Id())) @@ -573,7 +568,6 @@ func resourceLoggingMetricUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Metric %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -588,7 +582,6 @@ func resourceLoggingMetricUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -634,8 +627,6 @@ func resourceLoggingMetricDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Metric %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -645,7 +636,6 @@ func resourceLoggingMetricDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Metric") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_settings.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_settings.go index c718fa6fd0e..fbdc82ef179 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_settings.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_settings.go @@ -20,7 +20,6 @@ package logging import ( "fmt" "log" - "net/http" "reflect" "time" @@ -132,7 +131,6 @@ func resourceLoggingOrganizationSettingsCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -141,7 +139,6 @@ func resourceLoggingOrganizationSettingsCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating OrganizationSettings: %s", err) @@ -181,14 +178,12 @@ func resourceLoggingOrganizationSettingsRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("LoggingOrganizationSettings %q", d.Id())) @@ -251,7 +246,6 @@ func resourceLoggingOrganizationSettingsUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating OrganizationSettings %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -266,7 +260,6 @@ func resourceLoggingOrganizationSettingsUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_sink.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_sink.go index cab70c1bd7d..3c7129793f3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_sink.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_organization_sink.go @@ -34,15 +34,10 @@ func ResourceLoggingOrganizationSink() *schema.Resource { schm.Schema["include_children"] = &schema.Schema{ Type: schema.TypeBool, Optional: true, + ForceNew: true, Default: false, Description: `Whether or not to include children organizations in the sink export. If true, logs associated with child projects are also exported; otherwise only logs relating to the provided organization are included.`, } - schm.Schema["intercept_children"] = &schema.Schema{ - Type: schema.TypeBool, - Optional: true, - Default: false, - Description: `Whether or not to intercept logs from child projects. If true, matching logs will not match with sinks in child resources, except _Required sinks. This sink will be visible to child resources when listing sinks.`, - } return schm } @@ -57,7 +52,6 @@ func resourceLoggingOrganizationSinkCreate(d *schema.ResourceData, meta interfac org := d.Get("org_id").(string) id, sink := expandResourceLoggingSink(d, "organizations", org) sink.IncludeChildren = d.Get("include_children").(bool) - sink.InterceptChildren = d.Get("intercept_children").(bool) // Must use a unique writer, since all destinations are in projects. // The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true. @@ -90,10 +84,6 @@ func resourceLoggingOrganizationSinkRead(d *schema.ResourceData, meta interface{ return fmt.Errorf("Error setting include_children: %s", err) } - if err := d.Set("intercept_children", sink.InterceptChildren); err != nil { - return fmt.Errorf("Error setting intercept_children: %s", err) - } - return nil } @@ -105,6 +95,10 @@ func resourceLoggingOrganizationSinkUpdate(d *schema.ResourceData, meta interfac } sink, updateMask := expandResourceLoggingSinkForUpdate(d) + // It seems the API might actually accept an update for include_children; this is not in the list of updatable + // properties though and might break in the future. Always include the value to prevent it changing. + sink.IncludeChildren = d.Get("include_children").(bool) + sink.ForceSendFields = append(sink.ForceSendFields, "IncludeChildren") // The API will reject any requests that don't explicitly set 'uniqueWriterIdentity' to true. _, err = config.NewLoggingClient(userAgent).Organizations.Sinks.Patch(d.Id(), sink). diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_sink.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_sink.go index c08e5c705cc..44ffea4e9c3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_sink.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/logging/resource_logging_sink.go @@ -7,13 +7,10 @@ import ( "strings" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-google/google/tpgresource" "google.golang.org/api/logging/v2" ) -func OptionalSurroundingSpacesSuppress(k, old, new string, d *schema.ResourceData) bool { - return strings.TrimSpace(old) == strings.TrimSpace(new) -} - func resourceLoggingSinkSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "name": { @@ -32,7 +29,7 @@ func resourceLoggingSinkSchema() map[string]*schema.Schema { "filter": { Type: schema.TypeString, Optional: true, - DiffSuppressFunc: OptionalSurroundingSpacesSuppress, + DiffSuppressFunc: tpgresource.OptionalSurroundingSpacesSuppress, Description: `The filter to apply when exporting logs. Only log entries that match the filter are exported.`, }, @@ -181,12 +178,6 @@ func expandResourceLoggingSinkForUpdate(d *schema.ResourceData) (sink *logging.L sink.BigqueryOptions = expandLoggingSinkBigqueryOptions(d.Get("bigquery_options")) updateFields = append(updateFields, "bigqueryOptions") } - if d.HasChange("include_children") { - updateFields = append(updateFields, "includeChildren") - } - if d.HasChange("intercept_children") { - updateFields = append(updateFields, "interceptChildren") - } updateMask = strings.Join(updateFields, ",") return } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance.go index 904687e1eaa..c41b2eceacf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance.go @@ -20,7 +20,6 @@ package looker import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -60,7 +59,7 @@ func ResourceLookerInstance() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^[a-z][a-z0-9-]{0,61}[a-z0-9]$`), + ValidateFunc: verify.ValidateRegexp(`^[a-z][a-z0-9-]{0,39}[a-z0-9]$`), Description: `The ID of the instance or a fully qualified identifier for the instance.`, }, "admin_settings": { @@ -336,8 +335,8 @@ disrupt service.`, ForceNew: true, ValidateFunc: verify.ValidateEnum([]string{"LOOKER_CORE_TRIAL", "LOOKER_CORE_STANDARD", "LOOKER_CORE_STANDARD_ANNUAL", "LOOKER_CORE_ENTERPRISE_ANNUAL", "LOOKER_CORE_EMBED_ANNUAL", ""}), Description: `Platform editions for a Looker instance. Each edition maps to a set of instance features, like its size. Must be one of these values: -- LOOKER_CORE_TRIAL: trial instance (Currently Unavailable) -- LOOKER_CORE_STANDARD: pay as you go standard instance (Currently Unavailable) +- LOOKER_CORE_TRIAL: trial instance +- LOOKER_CORE_STANDARD: pay as you go standard instance - LOOKER_CORE_STANDARD_ANNUAL: subscription standard instance - LOOKER_CORE_ENTERPRISE_ANNUAL: subscription enterprise instance - LOOKER_CORE_EMBED_ANNUAL: subscription embed instance Default value: "LOOKER_CORE_TRIAL" Possible values: ["LOOKER_CORE_TRIAL", "LOOKER_CORE_STANDARD", "LOOKER_CORE_STANDARD_ANNUAL", "LOOKER_CORE_ENTERPRISE_ANNUAL", "LOOKER_CORE_EMBED_ANNUAL"]`, @@ -550,7 +549,6 @@ func resourceLookerInstanceCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -559,7 +557,6 @@ func resourceLookerInstanceCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -623,14 +620,12 @@ func resourceLookerInstanceRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -788,7 +783,6 @@ func resourceLookerInstanceUpdate(d *schema.ResourceData, meta interface{}) erro } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("admin_settings") { @@ -856,7 +850,6 @@ func resourceLookerInstanceUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -905,8 +898,6 @@ func resourceLookerInstanceDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -916,7 +907,6 @@ func resourceLookerInstanceDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance_sweeper.go index 3d5de94222f..c6576dfbaa9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/looker/resource_looker_instance_sweeper.go @@ -1,5 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + package looker import ( @@ -93,7 +108,7 @@ func testSweepLookerInstance(region string) error { continue } - deleteTemplate := "https://looker.googleapis.com/v1/projects/{{project}}/locations/{{region}}/instances/{{name}}?force=true" + deleteTemplate := "https://looker.googleapis.com/v1/projects/{{project}}/locations/{{region}}/instances/{{name}}" deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/memcache/resource_memcache_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/memcache/resource_memcache_instance.go index 89f8aa0c2ed..a66d70975ab 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/memcache/resource_memcache_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/memcache/resource_memcache_instance.go @@ -20,7 +20,6 @@ package memcache import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -466,7 +465,6 @@ func resourceMemcacheInstanceCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -475,7 +473,6 @@ func resourceMemcacheInstanceCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -538,14 +535,12 @@ func resourceMemcacheInstanceRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("MemcacheInstance %q", d.Id())) @@ -654,7 +649,6 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -694,7 +688,6 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -728,8 +721,6 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -743,7 +734,6 @@ func resourceMemcacheInstanceUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) @@ -791,8 +781,6 @@ func resourceMemcacheInstanceDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -802,7 +790,6 @@ func resourceMemcacheInstanceDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_group.go index 2ae2652e97d..4dd9b35fa84 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_group.go @@ -20,7 +20,6 @@ package migrationcenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -171,7 +170,6 @@ func resourceMigrationCenterGroupCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -180,7 +178,6 @@ func resourceMigrationCenterGroupCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Group: %s", err) @@ -247,14 +244,12 @@ func resourceMigrationCenterGroupRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("MigrationCenterGroup %q", d.Id())) @@ -333,7 +328,6 @@ func resourceMigrationCenterGroupUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Group %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -369,7 +363,6 @@ func resourceMigrationCenterGroupUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -417,8 +410,6 @@ func resourceMigrationCenterGroupDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Group %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -428,7 +419,6 @@ func resourceMigrationCenterGroupDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Group") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_preference_set.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_preference_set.go index d38971d26d3..03914fac7ec 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_preference_set.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/migrationcenter/resource_migration_center_preference_set.go @@ -20,7 +20,6 @@ package migrationcenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -335,7 +334,6 @@ func resourceMigrationCenterPreferenceSetCreate(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -344,7 +342,6 @@ func resourceMigrationCenterPreferenceSetCreate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PreferenceSet: %s", err) @@ -411,14 +408,12 @@ func resourceMigrationCenterPreferenceSetRead(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("MigrationCenterPreferenceSet %q", d.Id())) @@ -491,7 +486,6 @@ func resourceMigrationCenterPreferenceSetUpdate(d *schema.ResourceData, meta int } log.Printf("[DEBUG] Updating PreferenceSet %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -527,7 +521,6 @@ func resourceMigrationCenterPreferenceSetUpdate(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -575,8 +568,6 @@ func resourceMigrationCenterPreferenceSetDelete(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PreferenceSet %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -586,7 +577,6 @@ func resourceMigrationCenterPreferenceSetDelete(d *schema.ResourceData, meta int UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PreferenceSet") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/mlengine/resource_ml_engine_model.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/mlengine/resource_ml_engine_model.go index af6da61975b..3cba31a25eb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/mlengine/resource_ml_engine_model.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/mlengine/resource_ml_engine_model.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "time" @@ -221,7 +220,6 @@ func resourceMLEngineModelCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -230,7 +228,6 @@ func resourceMLEngineModelCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Model: %s", err) @@ -273,14 +270,12 @@ func resourceMLEngineModelRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("MLEngineModel %q", d.Id())) @@ -353,8 +348,6 @@ func resourceMLEngineModelDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Model %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -364,7 +357,6 @@ func resourceMLEngineModelDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Model") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_alert_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_alert_policy.go index 9e0c6d22945..065aaef446d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_alert_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_alert_policy.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -891,10 +890,9 @@ This limit is not implemented for alert policies that are not log-based.`, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "period": { - Type: schema.TypeString, - Optional: true, - Description: `Not more than one notification per period. -A duration in seconds with up to nine fractional digits, terminated by 's'. Example "60.5s".`, + Type: schema.TypeString, + Optional: true, + Description: `Not more than one notification per period.`, }, }, }, @@ -920,27 +918,7 @@ limited capacity might not show this documentation.`, The content may not exceed 8,192 Unicode characters and may not exceed more than 10,240 bytes when encoded in UTF-8 format, whichever is smaller.`, - AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject", "documentation.0.links"}, - }, - "links": { - Type: schema.TypeList, - Optional: true, - Description: `Links to content such as playbooks, repositories, and other resources. This field can contain up to 3 entries.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "display_name": { - Type: schema.TypeString, - Optional: true, - Description: `A short display name for the link. The display name must not be empty or exceed 63 characters. Example: "playbook".`, - }, - "url": { - Type: schema.TypeString, - Optional: true, - Description: `The url of a webpage. A url can be templatized by using variables in the path or the query parameters. The total length of a URL should not exceed 2083 characters before and after variable expansion. Example: "https://my_domain.com/playbook?name=${resource.name}".`, - }, - }, - }, - AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject", "documentation.0.links"}, + AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject"}, }, "mime_type": { Type: schema.TypeString, @@ -948,7 +926,7 @@ whichever is smaller.`, Description: `The format of the content field. Presently, only the value "text/markdown" is supported.`, Default: "text/markdown", - AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject", "documentation.0.links"}, + AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject"}, }, "subject": { Type: schema.TypeString, @@ -957,7 +935,7 @@ whichever is smaller.`, exceed 10,240 bytes. In notifications generated by this policy the contents of the subject line after variable expansion will be truncated to 255 bytes or shorter at the latest UTF-8 character boundary.`, - AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject", "documentation.0.links"}, + AtLeastOneOf: []string{"documentation.0.content", "documentation.0.mime_type", "documentation.0.subject"}, }, }, }, @@ -1127,7 +1105,6 @@ func resourceMonitoringAlertPolicyCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1136,7 +1113,6 @@ func resourceMonitoringAlertPolicyCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -1202,14 +1178,12 @@ func resourceMonitoringAlertPolicyRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -1342,7 +1316,6 @@ func resourceMonitoringAlertPolicyUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating AlertPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -1402,7 +1375,6 @@ func resourceMonitoringAlertPolicyUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -1452,8 +1424,6 @@ func resourceMonitoringAlertPolicyDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AlertPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1463,7 +1433,6 @@ func resourceMonitoringAlertPolicyDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -2069,8 +2038,6 @@ func flattenMonitoringAlertPolicyDocumentation(v interface{}, d *schema.Resource flattenMonitoringAlertPolicyDocumentationMimeType(original["mimeType"], d, config) transformed["subject"] = flattenMonitoringAlertPolicyDocumentationSubject(original["subject"], d, config) - transformed["links"] = - flattenMonitoringAlertPolicyDocumentationLinks(original["links"], d, config) return []interface{}{transformed} } func flattenMonitoringAlertPolicyDocumentationContent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -2085,33 +2052,6 @@ func flattenMonitoringAlertPolicyDocumentationSubject(v interface{}, d *schema.R return v } -func flattenMonitoringAlertPolicyDocumentationLinks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "display_name": flattenMonitoringAlertPolicyDocumentationLinksDisplayName(original["displayName"], d, config), - "url": flattenMonitoringAlertPolicyDocumentationLinksUrl(original["url"], d, config), - }) - } - return transformed -} -func flattenMonitoringAlertPolicyDocumentationLinksDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenMonitoringAlertPolicyDocumentationLinksUrl(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandMonitoringAlertPolicyDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -2976,13 +2916,6 @@ func expandMonitoringAlertPolicyDocumentation(v interface{}, d tpgresource.Terra transformed["subject"] = transformedSubject } - transformedLinks, err := expandMonitoringAlertPolicyDocumentationLinks(original["links"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLinks); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["links"] = transformedLinks - } - return transformed, nil } @@ -2997,40 +2930,3 @@ func expandMonitoringAlertPolicyDocumentationMimeType(v interface{}, d tpgresour func expandMonitoringAlertPolicyDocumentationSubject(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func expandMonitoringAlertPolicyDocumentationLinks(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDisplayName, err := expandMonitoringAlertPolicyDocumentationLinksDisplayName(original["display_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDisplayName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["displayName"] = transformedDisplayName - } - - transformedUrl, err := expandMonitoringAlertPolicyDocumentationLinksUrl(original["url"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUrl); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["url"] = transformedUrl - } - - req = append(req, transformed) - } - return req, nil -} - -func expandMonitoringAlertPolicyDocumentationLinksDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandMonitoringAlertPolicyDocumentationLinksUrl(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_custom_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_custom_service.go index cdae180732d..41c7a34692e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_custom_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_custom_service.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -171,7 +170,6 @@ func resourceMonitoringServiceCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -180,7 +178,6 @@ func resourceMonitoringServiceCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -227,14 +224,12 @@ func resourceMonitoringServiceRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -310,7 +305,6 @@ func resourceMonitoringServiceUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Service %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -346,7 +340,6 @@ func resourceMonitoringServiceUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) @@ -388,8 +381,6 @@ func resourceMonitoringServiceDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Service %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -399,7 +390,6 @@ func resourceMonitoringServiceDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_group.go index 36104fce42e..68117acc5f5 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_group.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "time" @@ -156,7 +155,6 @@ func resourceMonitoringGroupCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -165,7 +163,6 @@ func resourceMonitoringGroupCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -230,14 +227,12 @@ func resourceMonitoringGroupRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -321,7 +316,6 @@ func resourceMonitoringGroupUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Group %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -336,7 +330,6 @@ func resourceMonitoringGroupUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) @@ -383,8 +376,6 @@ func resourceMonitoringGroupDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Group %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -394,7 +385,6 @@ func resourceMonitoringGroupDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_metric_descriptor.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_metric_descriptor.go index 4152713ccc6..e9796140db4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_metric_descriptor.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_metric_descriptor.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "time" @@ -279,7 +278,6 @@ func resourceMonitoringMetricDescriptorCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -288,7 +286,6 @@ func resourceMonitoringMetricDescriptorCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -383,14 +380,12 @@ func resourceMonitoringMetricDescriptorRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -509,7 +504,6 @@ func resourceMonitoringMetricDescriptorUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating MetricDescriptor %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -524,7 +518,6 @@ func resourceMonitoringMetricDescriptorUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) @@ -569,8 +562,6 @@ func resourceMonitoringMetricDescriptorDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting MetricDescriptor %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -580,7 +571,6 @@ func resourceMonitoringMetricDescriptorDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_monitored_project.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_monitored_project.go index 72c2e67417e..078a7c1564c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_monitored_project.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_monitored_project.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strconv" "strings" @@ -143,7 +142,6 @@ func resourceMonitoringMonitoredProjectCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -152,7 +150,6 @@ func resourceMonitoringMonitoredProjectCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringPermissionError}, }) if err != nil { @@ -190,7 +187,6 @@ func resourceMonitoringMonitoredProjectRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) name := d.Get("name").(string) name = tpgresource.GetResourceNameFromSelfLink(name) d.Set("name", name) @@ -207,7 +203,6 @@ func resourceMonitoringMonitoredProjectRead(d *schema.ResourceData, meta interfa Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringPermissionError}, }) if err != nil { @@ -257,8 +252,6 @@ func resourceMonitoringMonitoredProjectDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting MonitoredProject %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -268,7 +261,6 @@ func resourceMonitoringMonitoredProjectDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringPermissionError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_notification_channel.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_notification_channel.go index f0900828f7f..f8e5a2c36cf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_notification_channel.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_notification_channel.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -254,7 +253,6 @@ func resourceMonitoringNotificationChannelCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -263,7 +261,6 @@ func resourceMonitoringNotificationChannelCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -328,14 +325,12 @@ func resourceMonitoringNotificationChannelRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -463,7 +458,6 @@ func resourceMonitoringNotificationChannelUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating NotificationChannel %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -478,7 +472,6 @@ func resourceMonitoringNotificationChannelUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) @@ -525,8 +518,6 @@ func resourceMonitoringNotificationChannelDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NotificationChannel %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -536,7 +527,6 @@ func resourceMonitoringNotificationChannelDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_service.go index 7f857da5d6c..c61bb6a96d2 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_service.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -183,7 +182,6 @@ func resourceMonitoringGenericServiceCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -192,7 +190,6 @@ func resourceMonitoringGenericServiceCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -239,14 +236,12 @@ func resourceMonitoringGenericServiceRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -311,7 +306,6 @@ func resourceMonitoringGenericServiceUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating GenericService %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -343,7 +337,6 @@ func resourceMonitoringGenericServiceUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) @@ -385,8 +378,6 @@ func resourceMonitoringGenericServiceDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GenericService %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -396,7 +387,6 @@ func resourceMonitoringGenericServiceDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_slo.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_slo.go index 2a7af5db83a..f24ffa23bba 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_slo.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_slo.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -833,7 +832,6 @@ func resourceMonitoringSloCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -842,7 +840,6 @@ func resourceMonitoringSloCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Slo: %s", err) @@ -888,14 +885,12 @@ func resourceMonitoringSloRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("MonitoringSlo %q", d.Id())) @@ -1016,7 +1011,6 @@ func resourceMonitoringSloUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Slo %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -1088,7 +1082,6 @@ func resourceMonitoringSloUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1136,8 +1129,6 @@ func resourceMonitoringSloDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Slo %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1147,7 +1138,6 @@ func resourceMonitoringSloDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Slo") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config.go index e57273c5070..ce78f6afd6b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config.go @@ -20,7 +20,6 @@ package monitoring import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -38,15 +37,6 @@ func resourceMonitoringUptimeCheckConfigHttpCheckPathDiffSuppress(k, old, new st return old == "/"+new } -func resourceMonitoringUptimeCheckConfigMonitoredResourceLabelsDiffSuppress(k, old, new string, d *schema.ResourceData) bool { - // GCP adds the project_id to the labels if unset. - // We want to suppress the diff if not set in the config. - if strings.HasSuffix(k, "project_id") && new == "" && old != "" { - return true - } - return false -} - func ResourceMonitoringUptimeCheckConfig() *schema.Resource { return &schema.Resource{ Create: resourceMonitoringUptimeCheckConfigCreate, @@ -160,7 +150,7 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource { "auth_info": { Type: schema.TypeList, Optional: true, - Description: `The authentication information using username and password. Optional when creating an HTTP check; defaults to empty. Do not use with other authentication fields.`, + Description: `The authentication information. Optional when creating an HTTP check; defaults to empty.`, MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -247,22 +237,6 @@ func ResourceMonitoringUptimeCheckConfig() *schema.Resource { Description: `The HTTP request method to use for the check. If set to 'METHOD_UNSPECIFIED' then 'request_method' defaults to 'GET'. Default value: "GET" Possible values: ["METHOD_UNSPECIFIED", "GET", "POST"]`, Default: "GET", }, - "service_agent_authentication": { - Type: schema.TypeList, - Optional: true, - Description: `The authentication information using the Monitoring Service Agent. Optional when creating an HTTPS check; defaults to empty. Do not use with other authentication fields.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "type": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED", "OIDC_TOKEN", ""}), - Description: `The type of authentication to use. Possible values: ["SERVICE_AGENT_AUTHENTICATION_TYPE_UNSPECIFIED", "OIDC_TOKEN"]`, - }, - }, - }, - }, "use_ssl": { Type: schema.TypeBool, Optional: true, @@ -287,7 +261,7 @@ configuration. The following monitored resource types are supported for uptime checks: * 'aws_ec2_instance' * 'aws_elb_load_balancer' -* 'gae_app' +* 'gae_app * 'gce_instance' * 'k8s_service' * 'servicedirectory_service' @@ -296,12 +270,11 @@ uptime checks: Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "labels": { - Type: schema.TypeMap, - Required: true, - ForceNew: true, - DiffSuppressFunc: resourceMonitoringUptimeCheckConfigMonitoredResourceLabelsDiffSuppress, - Description: `Values for all of the labels listed in the associated monitored resource descriptor. For example, Compute Engine VM instances use the labels 'project_id', 'instance_id', and 'zone'.`, - Elem: &schema.Schema{Type: schema.TypeString}, + Type: schema.TypeMap, + Required: true, + ForceNew: true, + Description: `Values for all of the labels listed in the associated monitored resource descriptor. For example, Compute Engine VM instances use the labels 'project_id', 'instance_id', and 'zone'.`, + Elem: &schema.Schema{Type: schema.TypeString}, }, "type": { Type: schema.TypeString, @@ -549,7 +522,6 @@ func resourceMonitoringUptimeCheckConfigCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -558,7 +530,6 @@ func resourceMonitoringUptimeCheckConfigCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -623,14 +594,12 @@ func resourceMonitoringUptimeCheckConfigRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) if err != nil { @@ -765,7 +734,6 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating UptimeCheckConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -821,7 +789,6 @@ func resourceMonitoringUptimeCheckConfigUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsMonitoringConcurrentEditError}, }) @@ -1007,8 +974,6 @@ func flattenMonitoringUptimeCheckConfigHttpCheck(v interface{}, d *schema.Resour flattenMonitoringUptimeCheckConfigHttpCheckCustomContentType(original["customContentType"], d, config) transformed["auth_info"] = flattenMonitoringUptimeCheckConfigHttpCheckAuthInfo(original["authInfo"], d, config) - transformed["service_agent_authentication"] = - flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(original["serviceAgentAuthentication"], d, config) transformed["port"] = flattenMonitoringUptimeCheckConfigHttpCheckPort(original["port"], d, config) transformed["headers"] = @@ -1064,23 +1029,6 @@ func flattenMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{}, return v } -func flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["type"] = - flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(original["type"], d, config) - return []interface{}{transformed} -} -func flattenMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenMonitoringUptimeCheckConfigHttpCheckPort(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -1477,13 +1425,6 @@ func expandMonitoringUptimeCheckConfigHttpCheck(v interface{}, d tpgresource.Ter transformed["authInfo"] = transformedAuthInfo } - transformedServiceAgentAuthentication, err := expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(original["service_agent_authentication"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAgentAuthentication); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAgentAuthentication"] = transformedServiceAgentAuthentication - } - transformedPort, err := expandMonitoringUptimeCheckConfigHttpCheckPort(original["port"], d, config) if err != nil { return nil, err @@ -1596,29 +1537,6 @@ func expandMonitoringUptimeCheckConfigHttpCheckAuthInfoUsername(v interface{}, d return v, nil } -func expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthentication(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedType, err := expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - return transformed, nil -} - -func expandMonitoringUptimeCheckConfigHttpCheckServiceAgentAuthenticationType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandMonitoringUptimeCheckConfigHttpCheckPort(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config_sweeper.go index 09eeeb349da..1c32a0c1840 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/monitoring/resource_monitoring_uptime_check_config_sweeper.go @@ -1,5 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + package monitoring import ( diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_active_directory.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_active_directory.go index 5e3754fdef0..9254ebfef57 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_active_directory.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_active_directory.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -95,14 +94,6 @@ A five-character random ID is generated automatically, for example, -6f9a, and a Required: true, Description: `Username for the Active Directory account with permissions to create the compute account within the specified organizational unit.`, }, - "administrators": { - Type: schema.TypeList, - Optional: true, - Description: `Domain user accounts to be added to the local Administrators group of the SMB service. Comma-separated list of domain users or groups. The Domain Admin group is automatically added when the service joins your domain as a hidden group.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, "aes_encryption": { Type: schema.TypeBool, Optional: true, @@ -280,12 +271,6 @@ func resourceNetappactiveDirectoryCreate(d *schema.ResourceData, meta interface{ } else if v, ok := d.GetOkExists("backup_operators"); !tpgresource.IsEmptyValue(reflect.ValueOf(backupOperatorsProp)) && (ok || !reflect.DeepEqual(v, backupOperatorsProp)) { obj["backupOperators"] = backupOperatorsProp } - administratorsProp, err := expandNetappactiveDirectoryAdministrators(d.Get("administrators"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("administrators"); !tpgresource.IsEmptyValue(reflect.ValueOf(administratorsProp)) && (ok || !reflect.DeepEqual(v, administratorsProp)) { - obj["administrators"] = administratorsProp - } securityOperatorsProp, err := expandNetappactiveDirectorySecurityOperators(d.Get("security_operators"), d, config) if err != nil { return err @@ -354,7 +339,6 @@ func resourceNetappactiveDirectoryCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -363,7 +347,6 @@ func resourceNetappactiveDirectoryCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating activeDirectory: %s", err) @@ -416,14 +399,12 @@ func resourceNetappactiveDirectoryRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappactiveDirectory %q", d.Id())) @@ -463,9 +444,6 @@ func resourceNetappactiveDirectoryRead(d *schema.ResourceData, meta interface{}) if err := d.Set("backup_operators", flattenNetappactiveDirectoryBackupOperators(res["backupOperators"], d, config)); err != nil { return fmt.Errorf("Error reading activeDirectory: %s", err) } - if err := d.Set("administrators", flattenNetappactiveDirectoryAdministrators(res["administrators"], d, config)); err != nil { - return fmt.Errorf("Error reading activeDirectory: %s", err) - } if err := d.Set("security_operators", flattenNetappactiveDirectorySecurityOperators(res["securityOperators"], d, config)); err != nil { return fmt.Errorf("Error reading activeDirectory: %s", err) } @@ -573,12 +551,6 @@ func resourceNetappactiveDirectoryUpdate(d *schema.ResourceData, meta interface{ } else if v, ok := d.GetOkExists("backup_operators"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, backupOperatorsProp)) { obj["backupOperators"] = backupOperatorsProp } - administratorsProp, err := expandNetappactiveDirectoryAdministrators(d.Get("administrators"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("administrators"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, administratorsProp)) { - obj["administrators"] = administratorsProp - } securityOperatorsProp, err := expandNetappactiveDirectorySecurityOperators(d.Get("security_operators"), d, config) if err != nil { return err @@ -634,7 +606,6 @@ func resourceNetappactiveDirectoryUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating activeDirectory %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("domain") { @@ -673,10 +644,6 @@ func resourceNetappactiveDirectoryUpdate(d *schema.ResourceData, meta interface{ updateMask = append(updateMask, "backupOperators") } - if d.HasChange("administrators") { - updateMask = append(updateMask, "administrators") - } - if d.HasChange("security_operators") { updateMask = append(updateMask, "securityOperators") } @@ -730,7 +697,6 @@ func resourceNetappactiveDirectoryUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -778,8 +744,6 @@ func resourceNetappactiveDirectoryDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting activeDirectory %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -789,7 +753,6 @@ func resourceNetappactiveDirectoryDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "activeDirectory") @@ -867,10 +830,6 @@ func flattenNetappactiveDirectoryBackupOperators(v interface{}, d *schema.Resour return v } -func flattenNetappactiveDirectoryAdministrators(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenNetappactiveDirectorySecurityOperators(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -973,10 +932,6 @@ func expandNetappactiveDirectoryBackupOperators(v interface{}, d tpgresource.Ter return v, nil } -func expandNetappactiveDirectoryAdministrators(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandNetappactiveDirectorySecurityOperators(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup.go deleted file mode 100644 index 47855759302..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup.go +++ /dev/null @@ -1,585 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package netapp - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceNetappbackup() *schema.Resource { - return &schema.Resource{ - Create: resourceNetappbackupCreate, - Read: resourceNetappbackupRead, - Update: resourceNetappbackupUpdate, - Delete: resourceNetappbackupDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetappbackupImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Location of the backup.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The resource name of the backup. Needs to be unique per location.`, - }, - "vault_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Name of the backup vault to store the backup in.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `A description of the backup with 2048 characters or less. Requests with longer descriptions will be rejected.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `Labels as key value pairs. Example: '{ "owner": "Bob", "department": "finance", "purpose": "testing" }'. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "source_snapshot": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `If specified, backup will be created from the given snapshot. If not specified, -there will be a new snapshot taken to initiate the backup creation. -Format: 'projects/{{projectId}}/locations/{{location}}/volumes/{{volumename}}/snapshots/{{snapshotname}}''`, - }, - "source_volume": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `ID of volumes this backup belongs to. Format: 'projects/{{projects_id}}/locations/{{location}}/volumes/{{name}}''`, - }, - "backup_type": { - Type: schema.TypeString, - Computed: true, - Description: `Type of backup, manually created or created by a backup policy. Possible Values : [TYPE_UNSPECIFIED, MANUAL, SCHEDULED]`, - }, - "chain_storage_bytes": { - Type: schema.TypeString, - Computed: true, - Description: `Backups of a volume build incrementally on top of each other. They form a "backup chain". -Total size of all backups in a chain in bytes = baseline backup size + sum(incremental backup size)`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Create time of the backup. A timestamp in RFC3339 UTC "Zulu" format. Examples: "2023-06-22T09:13:01.617Z".`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `The state of the Backup Vault. Possible Values : [STATE_UNSPECIFIED, CREATING, UPLOADING, READY, DELETING, ERROR, UPDATING]`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "volume_usage_bytes": { - Type: schema.TypeString, - Computed: true, - Description: `Size of the file system when the backup was created. When creating a new volume from the backup, the volume capacity will have to be at least as big.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetappbackupCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetappbackupDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - sourceVolumeProp, err := expandNetappbackupSourceVolume(d.Get("source_volume"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("source_volume"); !tpgresource.IsEmptyValue(reflect.ValueOf(sourceVolumeProp)) && (ok || !reflect.DeepEqual(v, sourceVolumeProp)) { - obj["sourceVolume"] = sourceVolumeProp - } - sourceSnapshotProp, err := expandNetappbackupSourceSnapshot(d.Get("source_snapshot"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("source_snapshot"); !tpgresource.IsEmptyValue(reflect.ValueOf(sourceSnapshotProp)) && (ok || !reflect.DeepEqual(v, sourceSnapshotProp)) { - obj["sourceSnapshot"] = sourceSnapshotProp - } - labelsProp, err := expandNetappbackupEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups?backupId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new backup: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for backup: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating backup: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetappOperationWaitTime( - config, res, project, "Creating backup", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create backup: %s", err) - } - - log.Printf("[DEBUG] Finished creating backup %q: %#v", d.Id(), res) - - return resourceNetappbackupRead(d, meta) -} - -func resourceNetappbackupRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for backup: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Netappbackup %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - - if err := d.Set("state", flattenNetappbackupState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("description", flattenNetappbackupDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("volume_usage_bytes", flattenNetappbackupVolumeUsageBytes(res["volumeUsageBytes"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("backup_type", flattenNetappbackupBackupType(res["backupType"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("source_volume", flattenNetappbackupSourceVolume(res["sourceVolume"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("create_time", flattenNetappbackupCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("labels", flattenNetappbackupLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("chain_storage_bytes", flattenNetappbackupChainStorageBytes(res["chainStorageBytes"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("source_snapshot", flattenNetappbackupSourceSnapshot(res["sourceSnapshot"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("terraform_labels", flattenNetappbackupTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - if err := d.Set("effective_labels", flattenNetappbackupEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading backup: %s", err) - } - - return nil -} - -func resourceNetappbackupUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for backup: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetappbackupDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - sourceSnapshotProp, err := expandNetappbackupSourceSnapshot(d.Get("source_snapshot"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("source_snapshot"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, sourceSnapshotProp)) { - obj["sourceSnapshot"] = sourceSnapshotProp - } - labelsProp, err := expandNetappbackupEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating backup %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("source_snapshot") { - updateMask = append(updateMask, "sourceSnapshot") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating backup %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating backup %q: %#v", d.Id(), res) - } - - err = NetappOperationWaitTime( - config, res, project, "Updating backup", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetappbackupRead(d, meta) -} - -func resourceNetappbackupDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for backup: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting backup %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "backup") - } - - err = NetappOperationWaitTime( - config, res, project, "Deleting backup", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting backup %q: %#v", d.Id(), res) - return nil -} - -func resourceNetappbackupImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/backupVaults/(?P[^/]+)/backups/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetappbackupState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupVolumeUsageBytes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupBackupType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupSourceVolume(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetappbackupChainStorageBytes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupSourceSnapshot(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappbackupTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetappbackupEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetappbackupDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetappbackupSourceVolume(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetappbackupSourceSnapshot(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetappbackupEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_policy.go index 6a2426d436a..72b1e4bfbe2 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_policy.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -207,7 +206,6 @@ func resourceNetappbackupPolicyCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -216,7 +214,6 @@ func resourceNetappbackupPolicyCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating backupPolicy: %s", err) @@ -269,14 +266,12 @@ func resourceNetappbackupPolicyRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappbackupPolicy %q", d.Id())) @@ -382,7 +377,6 @@ func resourceNetappbackupPolicyUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating backupPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("daily_backup_limit") { @@ -430,7 +424,6 @@ func resourceNetappbackupPolicyUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -478,8 +471,6 @@ func resourceNetappbackupPolicyDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting backupPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -489,7 +480,6 @@ func resourceNetappbackupPolicyDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "backupPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_sweeper.go deleted file mode 100644 index bf490800f8d..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package netapp - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("Netappbackup", testSweepNetappbackup) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetappbackup(region string) error { - resourceName := "Netappbackup" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://netapp.googleapis.com/v1/projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["backups"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://netapp.googleapis.com/v1/projects/{{project}}/locations/{{location}}/backupVaults/{{vault_name}}/backups/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_vault.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_vault.go index cc7fa94590e..d8a35dafbf3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_vault.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_backup_vault.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -156,7 +155,6 @@ func resourceNetappbackupVaultCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -165,7 +163,6 @@ func resourceNetappbackupVaultCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating backupVault: %s", err) @@ -218,14 +215,12 @@ func resourceNetappbackupVaultRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappbackupVault %q", d.Id())) @@ -292,7 +287,6 @@ func resourceNetappbackupVaultUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating backupVault %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -324,7 +318,6 @@ func resourceNetappbackupVaultUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -372,8 +365,6 @@ func resourceNetappbackupVaultDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting backupVault %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -383,7 +374,6 @@ func resourceNetappbackupVaultDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "backupVault") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_kmsconfig.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_kmsconfig.go index 4f73e999c4f..378adea6d2d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_kmsconfig.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_kmsconfig.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -169,7 +168,6 @@ func resourceNetappkmsconfigCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -178,7 +176,6 @@ func resourceNetappkmsconfigCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating kmsconfig: %s", err) @@ -249,14 +246,12 @@ func resourceNetappkmsconfigRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Netappkmsconfig %q", d.Id())) @@ -332,7 +327,6 @@ func resourceNetappkmsconfigUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating kmsconfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -368,7 +362,6 @@ func resourceNetappkmsconfigUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -416,8 +409,6 @@ func resourceNetappkmsconfigDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting kmsconfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -427,7 +418,6 @@ func resourceNetappkmsconfigDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "kmsconfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_storage_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_storage_pool.go index 9a9032d2040..c7172294fe7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_storage_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_storage_pool.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -65,13 +64,13 @@ func ResourceNetappstoragePool() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: `Name of the location. For zonal Flex pools specify a zone name, in all other cases a region name.`, + Description: `Name of the location. Usually a region name, expect for some STANDARD service level pools which require a zone name.`, }, "name": { Type: schema.TypeString, Required: true, ForceNew: true, - Description: `The resource name of the storage pool. Needs to be unique per location/region.`, + Description: `The resource name of the storage pool. Needs to be unique per location.`, }, "network": { Type: schema.TypeString, @@ -84,8 +83,8 @@ func ResourceNetappstoragePool() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"PREMIUM", "EXTREME", "STANDARD", "FLEX"}), - Description: `Service level of the storage pool. Possible values: ["PREMIUM", "EXTREME", "STANDARD", "FLEX"]`, + ValidateFunc: verify.ValidateEnum([]string{"PREMIUM", "EXTREME", "STANDARD"}), + Description: `Service level of the storage pool. Possible values: ["PREMIUM", "EXTREME", "STANDARD"]`, }, "active_directory": { Type: schema.TypeString, @@ -237,7 +236,6 @@ func resourceNetappstoragePoolCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -246,7 +244,6 @@ func resourceNetappstoragePoolCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating storagePool: %s", err) @@ -299,14 +296,12 @@ func resourceNetappstoragePoolRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappstoragePool %q", d.Id())) @@ -406,7 +401,6 @@ func resourceNetappstoragePoolUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating storagePool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("capacity_gib") { @@ -430,71 +424,6 @@ func resourceNetappstoragePoolUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return err } - // detect manual zone switches for service level FLEX - - if d.Get("service_level").(string) == "FLEX" { - // Check if this is zonal or regional Flex. Only continue for regional pool - _, hasZone := d.GetOk("zone") - _, hasReplicaZone := d.GetOk("replica_zone") - if hasZone && hasReplicaZone { - // For a zone switch, user needs to swap zone and replica_zone. Other changes are not allowed - if d.HasChange("zone") && d.HasChange("replica_zone") { - oldZone, newZone := d.GetChange("zone") - oldReplicaZone, newReplicaZone := d.GetChange("replica_zone") - if newZone == oldReplicaZone && newReplicaZone == oldZone { - rawurl, err := tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/storagePools/{{name}}:switch") - if err != nil { - return err - } - - reso, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: rawurl, - UserAgent: userAgent, - Timeout: d.Timeout(schema.TimeoutUpdate), - }) - if err != nil { - return fmt.Errorf("Error switching active zone for pool: %s, %v", d.Id(), err) - } - - err = NetappOperationWaitTime( - config, reso, project, "Switching active pool zone", userAgent, - d.Timeout(schema.TimeoutUpdate)) - if err != nil { - return err - } - - //remove zone and replicaZone from updateMask - n := 0 - for _, v := range updateMask { - if v != "zone" && v != "replicaZone" { - updateMask[n] = v - n++ - } - } - updateMask = updateMask[:n] - - // delete from payload too - delete(obj, "zone") - delete(obj, "replicaZone") - - // PATCH URL was already build prior to this code. We need to rebuild it to catch our changes - url, err = tpgresource.ReplaceVars(d, config, "{{NetappBasePath}}projects/{{project}}/locations/{{location}}/storagePools/{{name}}") - if err != nil { - return err - } - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - } else { - return fmt.Errorf("Incorrect zone change for pool: %s. Supported zone, replica_zone are : %s, %s", d.Id(), oldZone, oldReplicaZone) - } - } - } - } // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -511,7 +440,6 @@ func resourceNetappstoragePoolUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -559,8 +487,6 @@ func resourceNetappstoragePoolDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting storagePool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -570,7 +496,6 @@ func resourceNetappstoragePoolDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "storagePool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume.go index e40af340d64..027630b9695 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -94,35 +93,6 @@ func ResourceNetappVolume() *schema.Resource { Required: true, Description: `Name of the storage pool to create the volume in. Pool needs enough spare capacity to accomodate the volume.`, }, - "backup_config": { - Type: schema.TypeList, - Optional: true, - Description: `Backup configuration for the volume.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "backup_policies": { - Type: schema.TypeList, - Optional: true, - Description: `Specify a single backup policy ID for scheduled backups. Format: 'projects/{{projectId}}/locations/{{location}}/backupPolicies/{{backupPolicyName}}'`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "backup_vault": { - Type: schema.TypeString, - Optional: true, - Description: `ID of the backup vault to use. A backup vault is reqired to create manual or scheduled backups. -Format: 'projects/{{projectId}}/locations/{{location}}/backupVaults/{{backupVaultName}}'`, - }, - "scheduled_backup_enabled": { - Type: schema.TypeBool, - Optional: true, - Description: `When set to true, scheduled backup is enabled on the volume. Omit if no backup_policy is specified.`, - }, - }, - }, - }, "description": { Type: schema.TypeString, Optional: true, @@ -501,7 +471,7 @@ Format for SMB volumes: '\\\\netbios_prefix-four_random_hex_letters.domain_name\ "service_level": { Type: schema.TypeString, Computed: true, - Description: `Service level of the volume. Inherited from storage pool. Supported values are : PREMIUM, EXTERME, STANDARD, FLEX.`, + Description: `Service level of the volume. Inherited from storage pool.`, }, "state": { Type: schema.TypeString, @@ -636,12 +606,6 @@ func resourceNetappVolumeCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("snapshot_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(snapshotPolicyProp)) && (ok || !reflect.DeepEqual(v, snapshotPolicyProp)) { obj["snapshotPolicy"] = snapshotPolicyProp } - backupConfigProp, err := expandNetappVolumeBackupConfig(d.Get("backup_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("backup_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(backupConfigProp)) && (ok || !reflect.DeepEqual(v, backupConfigProp)) { - obj["backupConfig"] = backupConfigProp - } labelsProp, err := expandNetappVolumeEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -668,7 +632,6 @@ func resourceNetappVolumeCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -677,7 +640,6 @@ func resourceNetappVolumeCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Volume: %s", err) @@ -730,14 +692,12 @@ func resourceNetappVolumeRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappVolume %q", d.Id())) @@ -834,9 +794,6 @@ func resourceNetappVolumeRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("snapshot_policy", flattenNetappVolumeSnapshotPolicy(res["snapshotPolicy"], d, config)); err != nil { return fmt.Errorf("Error reading Volume: %s", err) } - if err := d.Set("backup_config", flattenNetappVolumeBackupConfig(res["backupConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Volume: %s", err) - } if err := d.Set("terraform_labels", flattenNetappVolumeTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading Volume: %s", err) } @@ -917,12 +874,6 @@ func resourceNetappVolumeUpdate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("snapshot_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, snapshotPolicyProp)) { obj["snapshotPolicy"] = snapshotPolicyProp } - backupConfigProp, err := expandNetappVolumeBackupConfig(d.Get("backup_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("backup_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, backupConfigProp)) { - obj["backupConfig"] = backupConfigProp - } labelsProp, err := expandNetappVolumeEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -936,7 +887,6 @@ func resourceNetappVolumeUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Volume %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("storage_pool") { @@ -975,12 +925,6 @@ func resourceNetappVolumeUpdate(d *schema.ResourceData, meta interface{}) error updateMask = append(updateMask, "snapshotPolicy") } - if d.HasChange("backup_config") { - updateMask = append(updateMask, "backup_config.backup_policies", - "backup_config.backup_vault", - "backup_config.scheduled_backup_enabled") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -1006,7 +950,6 @@ func resourceNetappVolumeUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1054,7 +997,6 @@ func resourceNetappVolumeDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) // Delete volume even when nested snapshots do exist if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "FORCE" { url = url + "?force=true" @@ -1069,7 +1011,6 @@ func resourceNetappVolumeDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Volume") @@ -1631,35 +1572,6 @@ func flattenNetappVolumeSnapshotPolicyMonthlyScheduleDaysOfMonth(v interface{}, return v } -func flattenNetappVolumeBackupConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["backup_policies"] = - flattenNetappVolumeBackupConfigBackupPolicies(original["backupPolicies"], d, config) - transformed["backup_vault"] = - flattenNetappVolumeBackupConfigBackupVault(original["backupVault"], d, config) - transformed["scheduled_backup_enabled"] = - flattenNetappVolumeBackupConfigScheduledBackupEnabled(original["scheduledBackupEnabled"], d, config) - return []interface{}{transformed} -} -func flattenNetappVolumeBackupConfigBackupPolicies(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappVolumeBackupConfigBackupVault(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetappVolumeBackupConfigScheduledBackupEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenNetappVolumeTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -2154,51 +2066,6 @@ func expandNetappVolumeSnapshotPolicyMonthlyScheduleDaysOfMonth(v interface{}, d return v, nil } -func expandNetappVolumeBackupConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedBackupPolicies, err := expandNetappVolumeBackupConfigBackupPolicies(original["backup_policies"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBackupPolicies); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["backupPolicies"] = transformedBackupPolicies - } - - transformedBackupVault, err := expandNetappVolumeBackupConfigBackupVault(original["backup_vault"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBackupVault); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["backupVault"] = transformedBackupVault - } - - transformedScheduledBackupEnabled, err := expandNetappVolumeBackupConfigScheduledBackupEnabled(original["scheduled_backup_enabled"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedScheduledBackupEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["scheduledBackupEnabled"] = transformedScheduledBackupEnabled - } - - return transformed, nil -} - -func expandNetappVolumeBackupConfigBackupPolicies(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetappVolumeBackupConfigBackupVault(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetappVolumeBackupConfigScheduledBackupEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandNetappVolumeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_replication.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_replication.go index c2518ac827a..1d2af10fc9b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_replication.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_replication.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -395,7 +394,6 @@ func resourceNetappVolumeReplicationCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -404,7 +402,6 @@ func resourceNetappVolumeReplicationCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VolumeReplication: %s", err) @@ -465,14 +462,12 @@ func resourceNetappVolumeReplicationRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappVolumeReplication %q", d.Id())) @@ -596,7 +591,6 @@ func resourceNetappVolumeReplicationUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating VolumeReplication %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("replication_schedule") { @@ -636,7 +630,6 @@ func resourceNetappVolumeReplicationUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -773,7 +766,6 @@ func resourceNetappVolumeReplicationDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) // A replication can only be deleted if mirrorState==STOPPED // We are about to delete the replication and need to stop the mirror before. // FYI: Stopping a PREPARING mirror currently doesn't work. User have to wait until @@ -817,7 +809,6 @@ func resourceNetappVolumeReplicationDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VolumeReplication") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_snapshot.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_snapshot.go index 2032dff84a0..58d505fdd1a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_snapshot.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/netapp/resource_netapp_volume_snapshot.go @@ -20,7 +20,6 @@ package netapp import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -157,7 +156,6 @@ func resourceNetappVolumeSnapshotCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -166,7 +164,6 @@ func resourceNetappVolumeSnapshotCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating VolumeSnapshot: %s", err) @@ -219,14 +216,12 @@ func resourceNetappVolumeSnapshotRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetappVolumeSnapshot %q", d.Id())) @@ -290,7 +285,6 @@ func resourceNetappVolumeSnapshotUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating VolumeSnapshot %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -322,7 +316,6 @@ func resourceNetappVolumeSnapshotUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -370,8 +363,6 @@ func resourceNetappVolumeSnapshotDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting VolumeSnapshot %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -381,7 +372,6 @@ func resourceNetappVolumeSnapshotDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "VolumeSnapshot") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_internal_range.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_internal_range.go deleted file mode 100644 index 8ee35762f43..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_internal_range.go +++ /dev/null @@ -1,724 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkconnectivity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceNetworkConnectivityInternalRange() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkConnectivityInternalRangeCreate, - Read: resourceNetworkConnectivityInternalRangeRead, - Update: resourceNetworkConnectivityInternalRangeUpdate, - Delete: resourceNetworkConnectivityInternalRangeDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkConnectivityInternalRangeImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(30 * time.Minute), - Update: schema.DefaultTimeout(30 * time.Minute), - Delete: schema.DefaultTimeout(30 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the policy based route.`, - }, - "network": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `Fully-qualified URL of the network that this route applies to, for example: projects/my-project/global/networks/my-network.`, - }, - "peering": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"FOR_SELF", "FOR_PEER", "NOT_SHARED"}), - Description: `The type of peering set for this internal range. Possible values: ["FOR_SELF", "FOR_PEER", "NOT_SHARED"]`, - }, - "usage": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"FOR_VPC", "EXTERNAL_TO_VPC"}), - Description: `The type of usage set for this InternalRange. Possible values: ["FOR_VPC", "EXTERNAL_TO_VPC"]`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `An optional description of this resource.`, - }, - "ip_cidr_range": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The IP range that this internal range defines.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `User-defined labels. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "overlaps": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Types of resources that are allowed to overlap with the current internal range. Possible values: ["OVERLAP_ROUTE_RANGE", "OVERLAP_EXISTING_SUBNET_RANGE"]`, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidateEnum([]string{"OVERLAP_ROUTE_RANGE", "OVERLAP_EXISTING_SUBNET_RANGE"}), - }, - }, - "prefix_length": { - Type: schema.TypeInt, - Optional: true, - Description: `An alternate to ipCidrRange. Can be set when trying to create a reservation that automatically finds a free range of the given size. -If both ipCidrRange and prefixLength are set, there is an error if the range sizes do not match. Can also be used during updates to change the range size.`, - }, - "target_cidr_range": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Can be set to narrow down or pick a different address space while searching for a free range. -If not set, defaults to the "10.0.0.0/8" address space. This can be used to search in other rfc-1918 address spaces like "172.16.0.0/12" and "192.168.0.0/16" or non-rfc-1918 address spaces used in the VPC.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "users": { - Type: schema.TypeList, - Computed: true, - Description: `Output only. The list of resources that refer to this internal range. -Resources that use the internal range for their range allocation are referred to as users of the range. -Other resources mark themselves as users while doing so by creating a reference to this internal range. Having a user, based on this reference, prevents deletion of the internal range referred to. Can be empty.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkConnectivityInternalRangeCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkConnectivityInternalRangeDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - ipCidrRangeProp, err := expandNetworkConnectivityInternalRangeIpCidrRange(d.Get("ip_cidr_range"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ip_cidr_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipCidrRangeProp)) && (ok || !reflect.DeepEqual(v, ipCidrRangeProp)) { - obj["ipCidrRange"] = ipCidrRangeProp - } - networkProp, err := expandNetworkConnectivityInternalRangeNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } - usageProp, err := expandNetworkConnectivityInternalRangeUsage(d.Get("usage"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("usage"); !tpgresource.IsEmptyValue(reflect.ValueOf(usageProp)) && (ok || !reflect.DeepEqual(v, usageProp)) { - obj["usage"] = usageProp - } - peeringProp, err := expandNetworkConnectivityInternalRangePeering(d.Get("peering"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("peering"); !tpgresource.IsEmptyValue(reflect.ValueOf(peeringProp)) && (ok || !reflect.DeepEqual(v, peeringProp)) { - obj["peering"] = peeringProp - } - prefixLengthProp, err := expandNetworkConnectivityInternalRangePrefixLength(d.Get("prefix_length"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("prefix_length"); !tpgresource.IsEmptyValue(reflect.ValueOf(prefixLengthProp)) && (ok || !reflect.DeepEqual(v, prefixLengthProp)) { - obj["prefixLength"] = prefixLengthProp - } - targetCidrRangeProp, err := expandNetworkConnectivityInternalRangeTargetCidrRange(d.Get("target_cidr_range"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_cidr_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetCidrRangeProp)) && (ok || !reflect.DeepEqual(v, targetCidrRangeProp)) { - obj["targetCidrRange"] = targetCidrRangeProp - } - overlapsProp, err := expandNetworkConnectivityInternalRangeOverlaps(d.Get("overlaps"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("overlaps"); !tpgresource.IsEmptyValue(reflect.ValueOf(overlapsProp)) && (ok || !reflect.DeepEqual(v, overlapsProp)) { - obj["overlaps"] = overlapsProp - } - labelsProp, err := expandNetworkConnectivityInternalRangeEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/global/internalRanges?internalRangeId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new InternalRange: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InternalRange: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating InternalRange: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/internalRanges/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkConnectivityOperationWaitTime( - config, res, project, "Creating InternalRange", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create InternalRange: %s", err) - } - - log.Printf("[DEBUG] Finished creating InternalRange %q: %#v", d.Id(), res) - - return resourceNetworkConnectivityInternalRangeRead(d, meta) -} - -func resourceNetworkConnectivityInternalRangeRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/global/internalRanges/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InternalRange: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkConnectivityInternalRange %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - - if err := d.Set("labels", flattenNetworkConnectivityInternalRangeLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("description", flattenNetworkConnectivityInternalRangeDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("ip_cidr_range", flattenNetworkConnectivityInternalRangeIpCidrRange(res["ipCidrRange"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("network", flattenNetworkConnectivityInternalRangeNetwork(res["network"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("usage", flattenNetworkConnectivityInternalRangeUsage(res["usage"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("peering", flattenNetworkConnectivityInternalRangePeering(res["peering"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("prefix_length", flattenNetworkConnectivityInternalRangePrefixLength(res["prefixLength"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("target_cidr_range", flattenNetworkConnectivityInternalRangeTargetCidrRange(res["targetCidrRange"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("users", flattenNetworkConnectivityInternalRangeUsers(res["users"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("overlaps", flattenNetworkConnectivityInternalRangeOverlaps(res["overlaps"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkConnectivityInternalRangeTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkConnectivityInternalRangeEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading InternalRange: %s", err) - } - - return nil -} - -func resourceNetworkConnectivityInternalRangeUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InternalRange: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkConnectivityInternalRangeDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - ipCidrRangeProp, err := expandNetworkConnectivityInternalRangeIpCidrRange(d.Get("ip_cidr_range"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ip_cidr_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, ipCidrRangeProp)) { - obj["ipCidrRange"] = ipCidrRangeProp - } - networkProp, err := expandNetworkConnectivityInternalRangeNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } - usageProp, err := expandNetworkConnectivityInternalRangeUsage(d.Get("usage"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("usage"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, usageProp)) { - obj["usage"] = usageProp - } - peeringProp, err := expandNetworkConnectivityInternalRangePeering(d.Get("peering"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("peering"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, peeringProp)) { - obj["peering"] = peeringProp - } - prefixLengthProp, err := expandNetworkConnectivityInternalRangePrefixLength(d.Get("prefix_length"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("prefix_length"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, prefixLengthProp)) { - obj["prefixLength"] = prefixLengthProp - } - targetCidrRangeProp, err := expandNetworkConnectivityInternalRangeTargetCidrRange(d.Get("target_cidr_range"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_cidr_range"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetCidrRangeProp)) { - obj["targetCidrRange"] = targetCidrRangeProp - } - overlapsProp, err := expandNetworkConnectivityInternalRangeOverlaps(d.Get("overlaps"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("overlaps"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, overlapsProp)) { - obj["overlaps"] = overlapsProp - } - labelsProp, err := expandNetworkConnectivityInternalRangeEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/global/internalRanges/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating InternalRange %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("ip_cidr_range") { - updateMask = append(updateMask, "ipCidrRange") - } - - if d.HasChange("network") { - updateMask = append(updateMask, "network") - } - - if d.HasChange("usage") { - updateMask = append(updateMask, "usage") - } - - if d.HasChange("peering") { - updateMask = append(updateMask, "peering") - } - - if d.HasChange("prefix_length") { - updateMask = append(updateMask, "prefixLength") - } - - if d.HasChange("target_cidr_range") { - updateMask = append(updateMask, "targetCidrRange") - } - - if d.HasChange("overlaps") { - updateMask = append(updateMask, "overlaps") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating InternalRange %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating InternalRange %q: %#v", d.Id(), res) - } - - err = NetworkConnectivityOperationWaitTime( - config, res, project, "Updating InternalRange", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkConnectivityInternalRangeRead(d, meta) -} - -func resourceNetworkConnectivityInternalRangeDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InternalRange: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/global/internalRanges/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting InternalRange %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "InternalRange") - } - - err = NetworkConnectivityOperationWaitTime( - config, res, project, "Deleting InternalRange", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting InternalRange %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkConnectivityInternalRangeImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/global/internalRanges/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/global/internalRanges/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkConnectivityInternalRangeLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkConnectivityInternalRangeDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangeIpCidrRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangeNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - -func flattenNetworkConnectivityInternalRangeUsage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangePeering(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangePrefixLength(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenNetworkConnectivityInternalRangeTargetCidrRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangeUsers(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangeOverlaps(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityInternalRangeTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkConnectivityInternalRangeEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkConnectivityInternalRangeDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangeIpCidrRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangeNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangeUsage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangePeering(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangePrefixLength(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangeTargetCidrRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangeOverlaps(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityInternalRangeEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_internal_range_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_internal_range_sweeper.go deleted file mode 100644 index ecf9889151d..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_internal_range_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkconnectivity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkConnectivityInternalRange", testSweepNetworkConnectivityInternalRange) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkConnectivityInternalRange(region string) error { - resourceName := "NetworkConnectivityInternalRange" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networkconnectivity.googleapis.com/v1/projects/{{project}}/locations/global/internalRanges", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["internalRanges"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networkconnectivity.googleapis.com/v1/projects/{{project}}/locations/global/internalRanges/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go index 9071adb55b8..7a4c01931b1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_policy_based_route.go @@ -20,7 +20,6 @@ package networkconnectivity import ( "fmt" "log" - "net/http" "reflect" "time" @@ -330,7 +329,6 @@ func resourceNetworkConnectivityPolicyBasedRouteCreate(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -339,7 +337,6 @@ func resourceNetworkConnectivityPolicyBasedRouteCreate(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PolicyBasedRoute: %s", err) @@ -392,14 +389,12 @@ func resourceNetworkConnectivityPolicyBasedRouteRead(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkConnectivityPolicyBasedRoute %q", d.Id())) @@ -490,8 +485,6 @@ func resourceNetworkConnectivityPolicyBasedRouteDelete(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PolicyBasedRoute %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -501,7 +494,6 @@ func resourceNetworkConnectivityPolicyBasedRouteDelete(d *schema.ResourceData, m UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PolicyBasedRoute") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go deleted file mode 100644 index 7e83558b2b5..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint.go +++ /dev/null @@ -1,535 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkconnectivity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceNetworkConnectivityRegionalEndpoint() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkConnectivityRegionalEndpointCreate, - Read: resourceNetworkConnectivityRegionalEndpointRead, - Update: resourceNetworkConnectivityRegionalEndpointUpdate, - Delete: resourceNetworkConnectivityRegionalEndpointDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkConnectivityRegionalEndpointImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "access_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"GLOBAL", "REGIONAL"}), - Description: `The access type of this regional endpoint. This field is reflected in the PSC Forwarding Rule configuration to enable global access. Possible values: ["GLOBAL", "REGIONAL"]`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The location of the RegionalEndpoint.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the RegionalEndpoint.`, - }, - "target_google_api": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The service endpoint this private regional endpoint connects to. Format: '{apiname}.{region}.p.rep.googleapis.com' Example: \"cloudkms.us-central1.p.rep.googleapis.com\".`, - }, - "address": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `The IP Address of the Regional Endpoint. When no address is provided, an IP from the subnetwork is allocated. Use one of the following formats: * IPv4 address as in '10.0.0.1' * Address resource URI as in 'projects/{project}/regions/{region}/addresses/{address_name}' - -~> **Note:** This field accepts both a reference to a Compute Address resource, which is the resource name of which format is given in the description, and IP literal value. If the user chooses to input a reserved address value; they need to make sure that the reserved address is in IPv4 version, its purpose is GCE_ENDPOINT, its type is INTERNAL and its status is RESERVED. If the user chooses to input an IP literal, they need to make sure that it's a valid IPv4 address (x.x.x.x) within the subnetwork.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `A description of this resource.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `User-defined labels. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "network": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `The name of the VPC network for this private regional endpoint. Format: 'projects/{project}/global/networks/{network}'`, - }, - "subnetwork": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `The name of the subnetwork from which the IP address will be allocated. Format: 'projects/{project}/regions/{region}/subnetworks/{subnetwork}'`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time when the RegionalEndpoint was created.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - ForceNew: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "psc_forwarding_rule": { - Type: schema.TypeString, - Computed: true, - Description: `The resource reference of the PSC Forwarding Rule created on behalf of the customer. Format: '//compute.googleapis.com/projects/{project}/regions/{region}/forwardingRules/{forwarding_rule_name}'`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time when the RegionalEndpoint was updated.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkConnectivityRegionalEndpointCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkConnectivityRegionalEndpointDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - targetGoogleApiProp, err := expandNetworkConnectivityRegionalEndpointTargetGoogleApi(d.Get("target_google_api"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("target_google_api"); !tpgresource.IsEmptyValue(reflect.ValueOf(targetGoogleApiProp)) && (ok || !reflect.DeepEqual(v, targetGoogleApiProp)) { - obj["targetGoogleApi"] = targetGoogleApiProp - } - networkProp, err := expandNetworkConnectivityRegionalEndpointNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } - subnetworkProp, err := expandNetworkConnectivityRegionalEndpointSubnetwork(d.Get("subnetwork"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("subnetwork"); !tpgresource.IsEmptyValue(reflect.ValueOf(subnetworkProp)) && (ok || !reflect.DeepEqual(v, subnetworkProp)) { - obj["subnetwork"] = subnetworkProp - } - accessTypeProp, err := expandNetworkConnectivityRegionalEndpointAccessType(d.Get("access_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("access_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(accessTypeProp)) && (ok || !reflect.DeepEqual(v, accessTypeProp)) { - obj["accessType"] = accessTypeProp - } - addressProp, err := expandNetworkConnectivityRegionalEndpointAddress(d.Get("address"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("address"); !tpgresource.IsEmptyValue(reflect.ValueOf(addressProp)) && (ok || !reflect.DeepEqual(v, addressProp)) { - obj["address"] = addressProp - } - labelsProp, err := expandNetworkConnectivityRegionalEndpointEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/{{location}}/regionalEndpoints?regional_endpoint_id={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new RegionalEndpoint: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for RegionalEndpoint: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating RegionalEndpoint: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkConnectivityOperationWaitTime( - config, res, project, "Creating RegionalEndpoint", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create RegionalEndpoint: %s", err) - } - - log.Printf("[DEBUG] Finished creating RegionalEndpoint %q: %#v", d.Id(), res) - - return resourceNetworkConnectivityRegionalEndpointRead(d, meta) -} - -func resourceNetworkConnectivityRegionalEndpointRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for RegionalEndpoint: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkConnectivityRegionalEndpoint %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - - if err := d.Set("create_time", flattenNetworkConnectivityRegionalEndpointCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("update_time", flattenNetworkConnectivityRegionalEndpointUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("labels", flattenNetworkConnectivityRegionalEndpointLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("description", flattenNetworkConnectivityRegionalEndpointDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("target_google_api", flattenNetworkConnectivityRegionalEndpointTargetGoogleApi(res["targetGoogleApi"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("network", flattenNetworkConnectivityRegionalEndpointNetwork(res["network"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("subnetwork", flattenNetworkConnectivityRegionalEndpointSubnetwork(res["subnetwork"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("access_type", flattenNetworkConnectivityRegionalEndpointAccessType(res["accessType"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("psc_forwarding_rule", flattenNetworkConnectivityRegionalEndpointPscForwardingRule(res["pscForwardingRule"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("address", flattenNetworkConnectivityRegionalEndpointAddress(res["address"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkConnectivityRegionalEndpointTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkConnectivityRegionalEndpointEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading RegionalEndpoint: %s", err) - } - - return nil -} - -func resourceNetworkConnectivityRegionalEndpointUpdate(d *schema.ResourceData, meta interface{}) error { - // Only the root field "labels" and "terraform_labels" are mutable - return resourceNetworkConnectivityRegionalEndpointRead(d, meta) -} - -func resourceNetworkConnectivityRegionalEndpointDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for RegionalEndpoint: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkConnectivityBasePath}}projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting RegionalEndpoint %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "RegionalEndpoint") - } - - err = NetworkConnectivityOperationWaitTime( - config, res, project, "Deleting RegionalEndpoint", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting RegionalEndpoint %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkConnectivityRegionalEndpointImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/regionalEndpoints/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkConnectivityRegionalEndpointCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkConnectivityRegionalEndpointDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointTargetGoogleApi(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointSubnetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointAccessType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointPscForwardingRule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkConnectivityRegionalEndpointTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkConnectivityRegionalEndpointEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkConnectivityRegionalEndpointDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityRegionalEndpointTargetGoogleApi(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityRegionalEndpointNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityRegionalEndpointSubnetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityRegionalEndpointAccessType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityRegionalEndpointAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkConnectivityRegionalEndpointEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_sweeper.go deleted file mode 100644 index 8c031300045..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_regional_endpoint_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkconnectivity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkConnectivityRegionalEndpoint", testSweepNetworkConnectivityRegionalEndpoint) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkConnectivityRegionalEndpoint(region string) error { - resourceName := "NetworkConnectivityRegionalEndpoint" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networkconnectivity.googleapis.com/v1/projects/{{project}}/locations/{{location}}/regionalEndpoints", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["regionalEndpoints"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networkconnectivity.googleapis.com/v1/projects/{{project}}/locations/{{location}}/regionalEndpoints/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_service_connection_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_service_connection_policy.go index 09db324da37..b0bd1c3c199 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_service_connection_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkconnectivity/resource_network_connectivity_service_connection_policy.go @@ -20,7 +20,6 @@ package networkconnectivity import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -328,7 +327,6 @@ func resourceNetworkConnectivityServiceConnectionPolicyCreate(d *schema.Resource billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -337,7 +335,6 @@ func resourceNetworkConnectivityServiceConnectionPolicyCreate(d *schema.Resource UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ServiceConnectionPolicy: %s", err) @@ -390,14 +387,12 @@ func resourceNetworkConnectivityServiceConnectionPolicyRead(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkConnectivityServiceConnectionPolicy %q", d.Id())) @@ -499,7 +494,6 @@ func resourceNetworkConnectivityServiceConnectionPolicyUpdate(d *schema.Resource } log.Printf("[DEBUG] Updating ServiceConnectionPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -539,7 +533,6 @@ func resourceNetworkConnectivityServiceConnectionPolicyUpdate(d *schema.Resource UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -587,8 +580,6 @@ func resourceNetworkConnectivityServiceConnectionPolicyDelete(d *schema.Resource billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ServiceConnectionPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -598,7 +589,6 @@ func resourceNetworkConnectivityServiceConnectionPolicyDelete(d *schema.Resource UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ServiceConnectionPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go index 19530fee787..d694524c0b9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkmanagement/resource_network_management_connectivity_test_resource.go @@ -20,7 +20,6 @@ package networkmanagement import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -325,7 +324,6 @@ func resourceNetworkManagementConnectivityTestCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -334,7 +332,6 @@ func resourceNetworkManagementConnectivityTestCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ConnectivityTest: %s", err) @@ -401,14 +398,12 @@ func resourceNetworkManagementConnectivityTestRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkManagementConnectivityTest %q", d.Id())) @@ -508,7 +503,6 @@ func resourceNetworkManagementConnectivityTestUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating ConnectivityTest %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -565,7 +559,6 @@ func resourceNetworkManagementConnectivityTestUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -613,8 +606,6 @@ func resourceNetworkManagementConnectivityTestDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ConnectivityTest %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -624,7 +615,6 @@ func resourceNetworkManagementConnectivityTestDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ConnectivityTest") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_address_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_address_group.go index a446e253f47..7ff4ef14f79 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_address_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_address_group.go @@ -20,7 +20,6 @@ package networksecurity import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -192,7 +191,6 @@ func resourceNetworkSecurityAddressGroupCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -201,7 +199,6 @@ func resourceNetworkSecurityAddressGroupCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AddressGroup: %s", err) @@ -248,14 +245,12 @@ func resourceNetworkSecurityAddressGroupRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityAddressGroup %q", d.Id())) @@ -340,7 +335,6 @@ func resourceNetworkSecurityAddressGroupUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating AddressGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -384,7 +378,6 @@ func resourceNetworkSecurityAddressGroupUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -427,8 +420,6 @@ func resourceNetworkSecurityAddressGroupDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AddressGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -438,7 +429,6 @@ func resourceNetworkSecurityAddressGroupDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AddressGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint.go deleted file mode 100644 index 3f3b0c859b9..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint.go +++ /dev/null @@ -1,510 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceNetworkSecurityFirewallEndpoint() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkSecurityFirewallEndpointCreate, - Read: resourceNetworkSecurityFirewallEndpointRead, - Update: resourceNetworkSecurityFirewallEndpointUpdate, - Delete: resourceNetworkSecurityFirewallEndpointDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkSecurityFirewallEndpointImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(60 * time.Minute), - Update: schema.DefaultTimeout(60 * time.Minute), - Delete: schema.DefaultTimeout(60 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - ), - - Schema: map[string]*schema.Schema{ - "billing_project_id": { - Type: schema.TypeString, - Required: true, - Description: `Project to bill on endpoint uptime usage.`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The location (zone) of the firewall endpoint.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the firewall endpoint resource.`, - }, - "parent": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the parent this firewall endpoint belongs to. -Format: organizations/{organization_id}.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `A map of key/value label pairs to assign to the resource. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "associated_networks": { - Type: schema.TypeList, - Computed: true, - Description: `List of networks that are associated with this endpoint in the local zone. -This is a projection of the FirewallEndpointAssociations pointing at this -endpoint. A network will only appear in this list after traffic routing is -fully configured. Format: projects/{project}/global/networks/{name}.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the firewall endpoint was created in UTC.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "reconciling": { - Type: schema.TypeBool, - Computed: true, - Description: `Whether reconciling is in progress, recommended per https://google.aip.dev/128.`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - Description: `Server-defined URL of this resource.`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `The current state of the endpoint.`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the firewall endpoint was updated in UTC.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkSecurityFirewallEndpointCreate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - billingProjectIdProp, err := expandNetworkSecurityFirewallEndpointBillingProjectId(d.Get("billing_project_id"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("billing_project_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(billingProjectIdProp)) && (ok || !reflect.DeepEqual(v, billingProjectIdProp)) { - obj["billingProjectId"] = billingProjectIdProp - } - labelsProp, err := expandNetworkSecurityFirewallEndpointEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpoints?firewallEndpointId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new FirewallEndpoint: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating FirewallEndpoint: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/firewallEndpoints/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Creating FirewallEndpoint", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create FirewallEndpoint: %s", err) - } - - log.Printf("[DEBUG] Finished creating FirewallEndpoint %q: %#v", d.Id(), res) - - return resourceNetworkSecurityFirewallEndpointRead(d, meta) -} - -func resourceNetworkSecurityFirewallEndpointRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpoints/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityFirewallEndpoint %q", d.Id())) - } - - if err := d.Set("labels", flattenNetworkSecurityFirewallEndpointLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("self_link", flattenNetworkSecurityFirewallEndpointSelfLink(res["selfLink"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("create_time", flattenNetworkSecurityFirewallEndpointCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("update_time", flattenNetworkSecurityFirewallEndpointUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("reconciling", flattenNetworkSecurityFirewallEndpointReconciling(res["reconciling"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("associated_networks", flattenNetworkSecurityFirewallEndpointAssociatedNetworks(res["associatedNetworks"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("state", flattenNetworkSecurityFirewallEndpointState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("billing_project_id", flattenNetworkSecurityFirewallEndpointBillingProjectId(res["billingProjectId"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkSecurityFirewallEndpointTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkSecurityFirewallEndpointEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpoint: %s", err) - } - - return nil -} - -func resourceNetworkSecurityFirewallEndpointUpdate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - billingProjectIdProp, err := expandNetworkSecurityFirewallEndpointBillingProjectId(d.Get("billing_project_id"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("billing_project_id"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, billingProjectIdProp)) { - obj["billingProjectId"] = billingProjectIdProp - } - labelsProp, err := expandNetworkSecurityFirewallEndpointEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpoints/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating FirewallEndpoint %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("billing_project_id") { - updateMask = append(updateMask, "billingProjectId") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating FirewallEndpoint %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating FirewallEndpoint %q: %#v", d.Id(), res) - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Updating FirewallEndpoint", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkSecurityFirewallEndpointRead(d, meta) -} - -func resourceNetworkSecurityFirewallEndpointDelete(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpoints/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting FirewallEndpoint %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "FirewallEndpoint") - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Deleting FirewallEndpoint", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting FirewallEndpoint %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkSecurityFirewallEndpointImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P.+)/locations/(?P[^/]+)/firewallEndpoints/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/firewallEndpoints/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkSecurityFirewallEndpointLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecurityFirewallEndpointSelfLink(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointReconciling(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociatedNetworks(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointBillingProjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecurityFirewallEndpointEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkSecurityFirewallEndpointBillingProjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityFirewallEndpointEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go deleted file mode 100644 index 22d6e335612..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_association.go +++ /dev/null @@ -1,592 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceNetworkSecurityFirewallEndpointAssociation() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkSecurityFirewallEndpointAssociationCreate, - Read: resourceNetworkSecurityFirewallEndpointAssociationRead, - Update: resourceNetworkSecurityFirewallEndpointAssociationUpdate, - Delete: resourceNetworkSecurityFirewallEndpointAssociationDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkSecurityFirewallEndpointAssociationImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - ), - - Schema: map[string]*schema.Schema{ - "firewall_endpoint": { - Type: schema.TypeString, - Required: true, - Description: `The URL of the firewall endpoint that is being associated.`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The location (zone) of the firewall endpoint association.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the firewall endpoint association resource.`, - }, - "network": { - Type: schema.TypeString, - Required: true, - Description: `The URL of the network that is being associated.`, - }, - "disabled": { - Type: schema.TypeBool, - Optional: true, - Description: `Whether the association is disabled. True indicates that traffic will not be intercepted. - -~> **Note:** The API will reject the request if this value is set to true when creating the resource, -otherwise on an update the association can be disabled.`, - Default: false, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `A map of key/value label pairs to assign to the resource. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "parent": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The name of the parent this firewall endpoint association belongs to. -Format: projects/{project_id}.`, - }, - "tls_inspection_policy": { - Type: schema.TypeString, - Optional: true, - Description: `The URL of the TlsInspectionPolicy that is being associated.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the firewall endpoint was created in UTC.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "reconciling": { - Type: schema.TypeBool, - Computed: true, - Description: `Whether reconciling is in progress, recommended per https://google.aip.dev/128.`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - Description: `Server-defined URL of this resource.`, - }, - "state": { - Type: schema.TypeString, - Computed: true, - Description: `The current state of the endpoint.`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the firewall endpoint was updated in UTC.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkSecurityFirewallEndpointAssociationCreate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - firewallEndpointProp, err := expandNetworkSecurityFirewallEndpointAssociationFirewallEndpoint(d.Get("firewall_endpoint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("firewall_endpoint"); !tpgresource.IsEmptyValue(reflect.ValueOf(firewallEndpointProp)) && (ok || !reflect.DeepEqual(v, firewallEndpointProp)) { - obj["firewallEndpoint"] = firewallEndpointProp - } - networkProp, err := expandNetworkSecurityFirewallEndpointAssociationNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(networkProp)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } - tlsInspectionPolicyProp, err := expandNetworkSecurityFirewallEndpointAssociationTlsInspectionPolicy(d.Get("tls_inspection_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("tls_inspection_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(tlsInspectionPolicyProp)) && (ok || !reflect.DeepEqual(v, tlsInspectionPolicyProp)) { - obj["tlsInspectionPolicy"] = tlsInspectionPolicyProp - } - disabledProp, err := expandNetworkSecurityFirewallEndpointAssociationDisabled(d.Get("disabled"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("disabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(disabledProp)) && (ok || !reflect.DeepEqual(v, disabledProp)) { - obj["disabled"] = disabledProp - } - labelsProp, err := expandNetworkSecurityFirewallEndpointAssociationEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpointAssociations?firewallEndpointAssociationId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new FirewallEndpointAssociation: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating FirewallEndpointAssociation: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/firewallEndpointAssociations/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Creating FirewallEndpointAssociation", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create FirewallEndpointAssociation: %s", err) - } - - log.Printf("[DEBUG] Finished creating FirewallEndpointAssociation %q: %#v", d.Id(), res) - - return resourceNetworkSecurityFirewallEndpointAssociationRead(d, meta) -} - -func resourceNetworkSecurityFirewallEndpointAssociationRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpointAssociations/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityFirewallEndpointAssociation %q", d.Id())) - } - - if err := d.Set("firewall_endpoint", flattenNetworkSecurityFirewallEndpointAssociationFirewallEndpoint(res["firewallEndpoint"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("network", flattenNetworkSecurityFirewallEndpointAssociationNetwork(res["network"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("tls_inspection_policy", flattenNetworkSecurityFirewallEndpointAssociationTlsInspectionPolicy(res["tlsInspectionPolicy"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("labels", flattenNetworkSecurityFirewallEndpointAssociationLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("disabled", flattenNetworkSecurityFirewallEndpointAssociationDisabled(res["disabled"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("self_link", flattenNetworkSecurityFirewallEndpointAssociationSelfLink(res["selfLink"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("create_time", flattenNetworkSecurityFirewallEndpointAssociationCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("update_time", flattenNetworkSecurityFirewallEndpointAssociationUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("reconciling", flattenNetworkSecurityFirewallEndpointAssociationReconciling(res["reconciling"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("state", flattenNetworkSecurityFirewallEndpointAssociationState(res["state"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkSecurityFirewallEndpointAssociationTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkSecurityFirewallEndpointAssociationEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading FirewallEndpointAssociation: %s", err) - } - - return nil -} - -func resourceNetworkSecurityFirewallEndpointAssociationUpdate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - firewallEndpointProp, err := expandNetworkSecurityFirewallEndpointAssociationFirewallEndpoint(d.Get("firewall_endpoint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("firewall_endpoint"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, firewallEndpointProp)) { - obj["firewallEndpoint"] = firewallEndpointProp - } - networkProp, err := expandNetworkSecurityFirewallEndpointAssociationNetwork(d.Get("network"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("network"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, networkProp)) { - obj["network"] = networkProp - } - tlsInspectionPolicyProp, err := expandNetworkSecurityFirewallEndpointAssociationTlsInspectionPolicy(d.Get("tls_inspection_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("tls_inspection_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, tlsInspectionPolicyProp)) { - obj["tlsInspectionPolicy"] = tlsInspectionPolicyProp - } - disabledProp, err := expandNetworkSecurityFirewallEndpointAssociationDisabled(d.Get("disabled"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("disabled"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, disabledProp)) { - obj["disabled"] = disabledProp - } - labelsProp, err := expandNetworkSecurityFirewallEndpointAssociationEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpointAssociations/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating FirewallEndpointAssociation %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("firewall_endpoint") { - updateMask = append(updateMask, "firewallEndpoint") - } - - if d.HasChange("network") { - updateMask = append(updateMask, "network") - } - - if d.HasChange("tls_inspection_policy") { - updateMask = append(updateMask, "tlsInspectionPolicy") - } - - if d.HasChange("disabled") { - updateMask = append(updateMask, "disabled") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating FirewallEndpointAssociation %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating FirewallEndpointAssociation %q: %#v", d.Id(), res) - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Updating FirewallEndpointAssociation", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkSecurityFirewallEndpointAssociationRead(d, meta) -} - -func resourceNetworkSecurityFirewallEndpointAssociationDelete(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/firewallEndpointAssociations/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting FirewallEndpointAssociation %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "FirewallEndpointAssociation") - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Deleting FirewallEndpointAssociation", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting FirewallEndpointAssociation %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkSecurityFirewallEndpointAssociationImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P.+)/locations/(?P[^/]+)/firewallEndpointAssociations/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/firewallEndpointAssociations/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkSecurityFirewallEndpointAssociationFirewallEndpoint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationNetwork(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationTlsInspectionPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecurityFirewallEndpointAssociationDisabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationSelfLink(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationReconciling(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityFirewallEndpointAssociationTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecurityFirewallEndpointAssociationEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkSecurityFirewallEndpointAssociationFirewallEndpoint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityFirewallEndpointAssociationNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityFirewallEndpointAssociationTlsInspectionPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityFirewallEndpointAssociationDisabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityFirewallEndpointAssociationEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_association_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_association_sweeper.go deleted file mode 100644 index 32cbc70c4e3..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_association_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkSecurityFirewallEndpointAssociation", testSweepNetworkSecurityFirewallEndpointAssociation) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkSecurityFirewallEndpointAssociation(region string) error { - resourceName := "NetworkSecurityFirewallEndpointAssociation" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/firewallEndpointAssociations", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["firewallEndpointAssociations"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/firewallEndpointAssociations/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_sweeper.go deleted file mode 100644 index ac2815565b6..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_firewall_endpoint_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkSecurityFirewallEndpoint", testSweepNetworkSecurityFirewallEndpoint) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkSecurityFirewallEndpoint(region string) error { - resourceName := "NetworkSecurityFirewallEndpoint" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/firewallEndpoints", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["firewallEndpoints"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/firewallEndpoints/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy.go index b66a7d42f6c..fd6113c80c7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy.go @@ -20,7 +20,6 @@ package networksecurity import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -136,7 +135,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -145,7 +143,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GatewaySecurityPolicy: %s", err) @@ -198,14 +195,12 @@ func resourceNetworkSecurityGatewaySecurityPolicyRead(d *schema.ResourceData, me billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityGatewaySecurityPolicy %q", d.Id())) @@ -260,7 +255,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating GatewaySecurityPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -288,7 +282,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -336,8 +329,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GatewaySecurityPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -347,7 +338,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GatewaySecurityPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go index 03382869252..0f419cfb3f5 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_gateway_security_policy_rule.go @@ -20,7 +20,6 @@ package networksecurity import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -211,7 +210,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleCreate(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -220,7 +218,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleCreate(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating GatewaySecurityPolicyRule: %s", err) @@ -273,14 +270,12 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleRead(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityGatewaySecurityPolicyRule %q", d.Id())) @@ -389,7 +384,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleUpdate(d *schema.ResourceDa } log.Printf("[DEBUG] Updating GatewaySecurityPolicyRule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enabled") { @@ -441,7 +435,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleUpdate(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -489,8 +482,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleDelete(d *schema.ResourceDa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting GatewaySecurityPolicyRule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -500,7 +491,6 @@ func resourceNetworkSecurityGatewaySecurityPolicyRuleDelete(d *schema.ResourceDa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "GatewaySecurityPolicyRule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile.go deleted file mode 100644 index ccbaf772c91..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile.go +++ /dev/null @@ -1,771 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceNetworkSecuritySecurityProfile() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkSecuritySecurityProfileCreate, - Read: resourceNetworkSecuritySecurityProfileRead, - Update: resourceNetworkSecuritySecurityProfileUpdate, - Delete: resourceNetworkSecuritySecurityProfileDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkSecuritySecurityProfileImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - ), - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the security profile resource.`, - }, - "type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"THREAT_PREVENTION"}), - Description: `The type of security profile. Possible values: ["THREAT_PREVENTION"]`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `An optional description of the security profile. The Max length is 512 characters.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `A map of key/value label pairs to assign to the resource. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location of the security profile. -The default value is 'global'.`, - Default: "global", - }, - "parent": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The name of the parent this security profile belongs to. -Format: organizations/{organization_id}.`, - }, - "threat_prevention_profile": { - Type: schema.TypeList, - Optional: true, - Description: `The threat prevention configuration for the security profile.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "severity_overrides": { - Type: schema.TypeList, - Optional: true, - Description: `The configuration for overriding threats actions by severity match.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"}), - Description: `Threat action override. Possible values: ["ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"]`, - }, - "severity": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"CRITICAL", "HIGH", "INFORMATIONAL", "LOW", "MEDIUM"}), - Description: `Severity level to match. Possible values: ["CRITICAL", "HIGH", "INFORMATIONAL", "LOW", "MEDIUM"]`, - }, - }, - }, - }, - "threat_overrides": { - Type: schema.TypeList, - Optional: true, - Description: `The configuration for overriding threats actions by threat id match. -If a threat is matched both by configuration provided in severity overrides -and threat overrides, the threat overrides action is applied.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "action": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"}), - Description: `Threat action. Possible values: ["ALERT", "ALLOW", "DEFAULT_ACTION", "DENY"]`, - }, - "threat_id": { - Type: schema.TypeString, - Required: true, - Description: `Vendor-specific ID of a threat to override.`, - }, - "type": { - Type: schema.TypeString, - Computed: true, - Description: `Type of threat.`, - }, - }, - }, - }, - }, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the security profile was created in UTC.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - Description: `This checksum is computed by the server based on the value of other fields, -and may be sent on update and delete requests to ensure the client has an up-to-date -value before proceeding.`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - Description: `Server-defined URL of this resource.`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the security profile was updated in UTC.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkSecuritySecurityProfileCreate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkSecuritySecurityProfileDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - threatPreventionProfileProp, err := expandNetworkSecuritySecurityProfileThreatPreventionProfile(d.Get("threat_prevention_profile"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("threat_prevention_profile"); !tpgresource.IsEmptyValue(reflect.ValueOf(threatPreventionProfileProp)) && (ok || !reflect.DeepEqual(v, threatPreventionProfileProp)) { - obj["threatPreventionProfile"] = threatPreventionProfileProp - } - typeProp, err := expandNetworkSecuritySecurityProfileType(d.Get("type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) { - obj["type"] = typeProp - } - labelsProp, err := expandNetworkSecuritySecurityProfileEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfiles?securityProfileId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new SecurityProfile: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating SecurityProfile: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/securityProfiles/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Creating SecurityProfile", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create SecurityProfile: %s", err) - } - - log.Printf("[DEBUG] Finished creating SecurityProfile %q: %#v", d.Id(), res) - - return resourceNetworkSecuritySecurityProfileRead(d, meta) -} - -func resourceNetworkSecuritySecurityProfileRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfiles/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecuritySecurityProfile %q", d.Id())) - } - - if err := d.Set("self_link", flattenNetworkSecuritySecurityProfileSelfLink(res["selfLink"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("create_time", flattenNetworkSecuritySecurityProfileCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("update_time", flattenNetworkSecuritySecurityProfileUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("etag", flattenNetworkSecuritySecurityProfileEtag(res["etag"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("description", flattenNetworkSecuritySecurityProfileDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("labels", flattenNetworkSecuritySecurityProfileLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("threat_prevention_profile", flattenNetworkSecuritySecurityProfileThreatPreventionProfile(res["threatPreventionProfile"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("type", flattenNetworkSecuritySecurityProfileType(res["type"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkSecuritySecurityProfileTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkSecuritySecurityProfileEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfile: %s", err) - } - - return nil -} - -func resourceNetworkSecuritySecurityProfileUpdate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkSecuritySecurityProfileDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - threatPreventionProfileProp, err := expandNetworkSecuritySecurityProfileThreatPreventionProfile(d.Get("threat_prevention_profile"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("threat_prevention_profile"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, threatPreventionProfileProp)) { - obj["threatPreventionProfile"] = threatPreventionProfileProp - } - labelsProp, err := expandNetworkSecuritySecurityProfileEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfiles/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating SecurityProfile %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("threat_prevention_profile") { - updateMask = append(updateMask, "threatPreventionProfile") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating SecurityProfile %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating SecurityProfile %q: %#v", d.Id(), res) - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Updating SecurityProfile", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkSecuritySecurityProfileRead(d, meta) -} - -func resourceNetworkSecuritySecurityProfileDelete(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfiles/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting SecurityProfile %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "SecurityProfile") - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Deleting SecurityProfile", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting SecurityProfile %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkSecuritySecurityProfileImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P.+)/locations/(?P[^/]+)/securityProfiles/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/securityProfiles/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkSecuritySecurityProfileSelfLink(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecuritySecurityProfileThreatPreventionProfile(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["severity_overrides"] = - flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverrides(original["severityOverrides"], d, config) - transformed["threat_overrides"] = - flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides(original["threatOverrides"], d, config) - return []interface{}{transformed} -} -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverrides(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "action": flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesAction(original["action"], d, config), - "severity": flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesSeverity(original["severity"], d, config), - }) - } - return transformed -} -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesAction(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesSeverity(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "action": flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesAction(original["action"], d, config), - "threat_id": flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesThreatId(original["threatId"], d, config), - "type": flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesType(original["type"], d, config), - }) - } - return transformed -} -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesAction(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesThreatId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecuritySecurityProfileEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkSecuritySecurityProfileDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfile(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedSeverityOverrides, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverrides(original["severity_overrides"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeverityOverrides); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["severityOverrides"] = transformedSeverityOverrides - } - - transformedThreatOverrides, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides(original["threat_overrides"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedThreatOverrides); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["threatOverrides"] = transformedThreatOverrides - } - - return transformed, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverrides(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAction, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesAction(original["action"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAction); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["action"] = transformedAction - } - - transformedSeverity, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesSeverity(original["severity"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeverity); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["severity"] = transformedSeverity - } - - req = append(req, transformed) - } - return req, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileSeverityOverridesSeverity(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverrides(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAction, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesAction(original["action"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAction); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["action"] = transformedAction - } - - transformedThreatId, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesThreatId(original["threat_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedThreatId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["threatId"] = transformedThreatId - } - - transformedType, err := expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - req = append(req, transformed) - } - return req, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesAction(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesThreatId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileThreatPreventionProfileThreatOverridesType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_group.go deleted file mode 100644 index 2df369da9d7..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_group.go +++ /dev/null @@ -1,504 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceNetworkSecuritySecurityProfileGroup() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkSecuritySecurityProfileGroupCreate, - Read: resourceNetworkSecuritySecurityProfileGroupRead, - Update: resourceNetworkSecuritySecurityProfileGroupUpdate, - Delete: resourceNetworkSecuritySecurityProfileGroupDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkSecuritySecurityProfileGroupImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - ), - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the security profile group resource.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `An optional description of the profile. The Max length is 512 characters.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `A map of key/value label pairs to assign to the resource. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location of the security profile group. -The default value is 'global'.`, - Default: "global", - }, - "parent": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The name of the parent this security profile group belongs to. -Format: organizations/{organization_id}.`, - }, - "threat_prevention_profile": { - Type: schema.TypeString, - Optional: true, - Description: `Reference to a SecurityProfile with the threat prevention configuration for the SecurityProfileGroup.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the security profile group was created in UTC.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - Description: `This checksum is computed by the server based on the value of other fields, -and may be sent on update and delete requests to ensure the client has an up-to-date -value before proceeding.`, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the security profile group was updated in UTC.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkSecuritySecurityProfileGroupCreate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkSecuritySecurityProfileGroupDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - threatPreventionProfileProp, err := expandNetworkSecuritySecurityProfileGroupThreatPreventionProfile(d.Get("threat_prevention_profile"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("threat_prevention_profile"); !tpgresource.IsEmptyValue(reflect.ValueOf(threatPreventionProfileProp)) && (ok || !reflect.DeepEqual(v, threatPreventionProfileProp)) { - obj["threatPreventionProfile"] = threatPreventionProfileProp - } - labelsProp, err := expandNetworkSecuritySecurityProfileGroupEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfileGroups?securityProfileGroupId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new SecurityProfileGroup: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating SecurityProfileGroup: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/securityProfileGroups/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Creating SecurityProfileGroup", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create SecurityProfileGroup: %s", err) - } - - log.Printf("[DEBUG] Finished creating SecurityProfileGroup %q: %#v", d.Id(), res) - - return resourceNetworkSecuritySecurityProfileGroupRead(d, meta) -} - -func resourceNetworkSecuritySecurityProfileGroupRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfileGroups/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecuritySecurityProfileGroup %q", d.Id())) - } - - if err := d.Set("create_time", flattenNetworkSecuritySecurityProfileGroupCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("update_time", flattenNetworkSecuritySecurityProfileGroupUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("etag", flattenNetworkSecuritySecurityProfileGroupEtag(res["etag"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("description", flattenNetworkSecuritySecurityProfileGroupDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("labels", flattenNetworkSecuritySecurityProfileGroupLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("threat_prevention_profile", flattenNetworkSecuritySecurityProfileGroupThreatPreventionProfile(res["threatPreventionProfile"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkSecuritySecurityProfileGroupTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkSecuritySecurityProfileGroupEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading SecurityProfileGroup: %s", err) - } - - return nil -} - -func resourceNetworkSecuritySecurityProfileGroupUpdate(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkSecuritySecurityProfileGroupDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - threatPreventionProfileProp, err := expandNetworkSecuritySecurityProfileGroupThreatPreventionProfile(d.Get("threat_prevention_profile"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("threat_prevention_profile"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, threatPreventionProfileProp)) { - obj["threatPreventionProfile"] = threatPreventionProfileProp - } - labelsProp, err := expandNetworkSecuritySecurityProfileGroupEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfileGroups/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating SecurityProfileGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("threat_prevention_profile") { - updateMask = append(updateMask, "threatPreventionProfile") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating SecurityProfileGroup %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating SecurityProfileGroup %q: %#v", d.Id(), res) - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Updating SecurityProfileGroup", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkSecuritySecurityProfileGroupRead(d, meta) -} - -func resourceNetworkSecuritySecurityProfileGroupDelete(d *schema.ResourceData, meta interface{}) error { - var project string - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}{{parent}}/locations/{{location}}/securityProfileGroups/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting SecurityProfileGroup %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "SecurityProfileGroup") - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Deleting SecurityProfileGroup", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting SecurityProfileGroup %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkSecuritySecurityProfileGroupImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P.+)/locations/(?P[^/]+)/securityProfileGroups/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/locations/{{location}}/securityProfileGroups/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkSecuritySecurityProfileGroupCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileGroupUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileGroupEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileGroupDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileGroupLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecuritySecurityProfileGroupThreatPreventionProfile(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecuritySecurityProfileGroupTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkSecuritySecurityProfileGroupEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkSecuritySecurityProfileGroupDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileGroupThreatPreventionProfile(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecuritySecurityProfileGroupEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_group_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_group_sweeper.go deleted file mode 100644 index bce207dd1a5..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_group_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkSecuritySecurityProfileGroup", testSweepNetworkSecuritySecurityProfileGroup) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkSecuritySecurityProfileGroup(region string) error { - resourceName := "NetworkSecuritySecurityProfileGroup" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}securityProfileGroups", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["securityProfileGroups"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/securityProfileGroups/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_sweeper.go deleted file mode 100644 index b338ec9dee5..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_security_profile_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkSecuritySecurityProfile", testSweepNetworkSecuritySecurityProfile) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkSecuritySecurityProfile(region string) error { - resourceName := "NetworkSecuritySecurityProfile" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/securityProfiles", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["securityProfiles"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networksecurity.googleapis.com/v1/{{parent}}/locations/{{location}}/securityProfiles/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_tls_inspection_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_tls_inspection_policy.go deleted file mode 100644 index d5dde964479..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_tls_inspection_policy.go +++ /dev/null @@ -1,586 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceNetworkSecurityTlsInspectionPolicy() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkSecurityTlsInspectionPolicyCreate, - Read: resourceNetworkSecurityTlsInspectionPolicyRead, - Update: resourceNetworkSecurityTlsInspectionPolicyUpdate, - Delete: resourceNetworkSecurityTlsInspectionPolicyDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkSecurityTlsInspectionPolicyImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(30 * time.Minute), - Update: schema.DefaultTimeout(30 * time.Minute), - Delete: schema.DefaultTimeout(30 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "ca_pool": { - Type: schema.TypeString, - Required: true, - Description: `A CA pool resource used to issue interception certificates.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: `Short name of the TlsInspectionPolicy resource to be created.`, - }, - "custom_tls_features": { - Type: schema.TypeList, - Optional: true, - Description: `List of custom TLS cipher suites selected. This field is valid only if the selected tls_feature_profile is CUSTOM. The compute.SslPoliciesService.ListAvailableFeatures method returns the set of features that can be specified in this list. Note that Secure Web Proxy does not yet honor this field.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Free-text description of the resource.`, - }, - "exclude_public_ca_set": { - Type: schema.TypeBool, - Optional: true, - Description: `If FALSE (the default), use our default set of public CAs in addition to any CAs specified in trustConfig. These public CAs are currently based on the Mozilla Root Program and are subject to change over time. If TRUE, do not accept our default set of public CAs. Only CAs specified in trustConfig will be accepted.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `The location of the tls inspection policy.`, - }, - "min_tls_version": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"TLS_VERSION_UNSPECIFIED", "TLS_1_0", "TLS_1_1", "TLS_1_2", "TLS_1_3", ""}), - Description: `Minimum TLS version that the firewall should use when negotiating connections with both clients and servers. If this is not set, then the default value is to allow the broadest set of clients and servers (TLS 1.0 or higher). Setting this to more restrictive values may improve security, but may also prevent the firewall from connecting to some clients or servers. Note that Secure Web Proxy does not yet honor this field. Possible values: ["TLS_VERSION_UNSPECIFIED", "TLS_1_0", "TLS_1_1", "TLS_1_2", "TLS_1_3"]`, - }, - "tls_feature_profile": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"PROFILE_UNSPECIFIED", "PROFILE_COMPATIBLE", "PROFILE_MODERN", "PROFILE_RESTRICTED", "PROFILE_CUSTOM", ""}), - Description: `The selected Profile. If this is not set, then the default value is to allow the broadest set of clients and servers (\"PROFILE_COMPATIBLE\"). Setting this to more restrictive values may improve security, but may also prevent the TLS inspection proxy from connecting to some clients or servers. Note that Secure Web Proxy does not yet honor this field. Possible values: ["PROFILE_UNSPECIFIED", "PROFILE_COMPATIBLE", "PROFILE_MODERN", "PROFILE_RESTRICTED", "PROFILE_CUSTOM"]`, - }, - "trust_config": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `A TrustConfig resource used when making a connection to the TLS server. This is a relative resource path following the form \"projects/{project}/locations/{location}/trustConfigs/{trust_config}\". This is necessary to intercept TLS connections to servers with certificates signed by a private CA or self-signed certificates. Trust config and the TLS inspection policy must be in the same region. Note that Secure Web Proxy does not yet honor this field.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp when the resource was created.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp when the resource was updated.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkSecurityTlsInspectionPolicyCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkSecurityTlsInspectionPolicyDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - caPoolProp, err := expandNetworkSecurityTlsInspectionPolicyCaPool(d.Get("ca_pool"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ca_pool"); !tpgresource.IsEmptyValue(reflect.ValueOf(caPoolProp)) && (ok || !reflect.DeepEqual(v, caPoolProp)) { - obj["caPool"] = caPoolProp - } - trustConfigProp, err := expandNetworkSecurityTlsInspectionPolicyTrustConfig(d.Get("trust_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("trust_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(trustConfigProp)) && (ok || !reflect.DeepEqual(v, trustConfigProp)) { - obj["trustConfig"] = trustConfigProp - } - minTlsVersionProp, err := expandNetworkSecurityTlsInspectionPolicyMinTlsVersion(d.Get("min_tls_version"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("min_tls_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(minTlsVersionProp)) && (ok || !reflect.DeepEqual(v, minTlsVersionProp)) { - obj["minTlsVersion"] = minTlsVersionProp - } - tlsFeatureProfileProp, err := expandNetworkSecurityTlsInspectionPolicyTlsFeatureProfile(d.Get("tls_feature_profile"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("tls_feature_profile"); !tpgresource.IsEmptyValue(reflect.ValueOf(tlsFeatureProfileProp)) && (ok || !reflect.DeepEqual(v, tlsFeatureProfileProp)) { - obj["tlsFeatureProfile"] = tlsFeatureProfileProp - } - customTlsFeaturesProp, err := expandNetworkSecurityTlsInspectionPolicyCustomTlsFeatures(d.Get("custom_tls_features"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_tls_features"); !tpgresource.IsEmptyValue(reflect.ValueOf(customTlsFeaturesProp)) && (ok || !reflect.DeepEqual(v, customTlsFeaturesProp)) { - obj["customTlsFeatures"] = customTlsFeaturesProp - } - excludePublicCaSetProp, err := expandNetworkSecurityTlsInspectionPolicyExcludePublicCaSet(d.Get("exclude_public_ca_set"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("exclude_public_ca_set"); !tpgresource.IsEmptyValue(reflect.ValueOf(excludePublicCaSetProp)) && (ok || !reflect.DeepEqual(v, excludePublicCaSetProp)) { - obj["excludePublicCaSet"] = excludePublicCaSetProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}projects/{{project}}/locations/{{location}}/tlsInspectionPolicies?tlsInspectionPolicyId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new TlsInspectionPolicy: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for TlsInspectionPolicy: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating TlsInspectionPolicy: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/tlsInspectionPolicies/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Creating TlsInspectionPolicy", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create TlsInspectionPolicy: %s", err) - } - - log.Printf("[DEBUG] Finished creating TlsInspectionPolicy %q: %#v", d.Id(), res) - - return resourceNetworkSecurityTlsInspectionPolicyRead(d, meta) -} - -func resourceNetworkSecurityTlsInspectionPolicyRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}projects/{{project}}/locations/{{location}}/tlsInspectionPolicies/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for TlsInspectionPolicy: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityTlsInspectionPolicy %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - - if err := d.Set("create_time", flattenNetworkSecurityTlsInspectionPolicyCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("update_time", flattenNetworkSecurityTlsInspectionPolicyUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("description", flattenNetworkSecurityTlsInspectionPolicyDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("ca_pool", flattenNetworkSecurityTlsInspectionPolicyCaPool(res["caPool"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("trust_config", flattenNetworkSecurityTlsInspectionPolicyTrustConfig(res["trustConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("min_tls_version", flattenNetworkSecurityTlsInspectionPolicyMinTlsVersion(res["minTlsVersion"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("tls_feature_profile", flattenNetworkSecurityTlsInspectionPolicyTlsFeatureProfile(res["tlsFeatureProfile"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("custom_tls_features", flattenNetworkSecurityTlsInspectionPolicyCustomTlsFeatures(res["customTlsFeatures"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - if err := d.Set("exclude_public_ca_set", flattenNetworkSecurityTlsInspectionPolicyExcludePublicCaSet(res["excludePublicCaSet"], d, config)); err != nil { - return fmt.Errorf("Error reading TlsInspectionPolicy: %s", err) - } - - return nil -} - -func resourceNetworkSecurityTlsInspectionPolicyUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for TlsInspectionPolicy: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkSecurityTlsInspectionPolicyDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - caPoolProp, err := expandNetworkSecurityTlsInspectionPolicyCaPool(d.Get("ca_pool"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ca_pool"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, caPoolProp)) { - obj["caPool"] = caPoolProp - } - trustConfigProp, err := expandNetworkSecurityTlsInspectionPolicyTrustConfig(d.Get("trust_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("trust_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, trustConfigProp)) { - obj["trustConfig"] = trustConfigProp - } - minTlsVersionProp, err := expandNetworkSecurityTlsInspectionPolicyMinTlsVersion(d.Get("min_tls_version"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("min_tls_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, minTlsVersionProp)) { - obj["minTlsVersion"] = minTlsVersionProp - } - tlsFeatureProfileProp, err := expandNetworkSecurityTlsInspectionPolicyTlsFeatureProfile(d.Get("tls_feature_profile"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("tls_feature_profile"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, tlsFeatureProfileProp)) { - obj["tlsFeatureProfile"] = tlsFeatureProfileProp - } - customTlsFeaturesProp, err := expandNetworkSecurityTlsInspectionPolicyCustomTlsFeatures(d.Get("custom_tls_features"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_tls_features"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customTlsFeaturesProp)) { - obj["customTlsFeatures"] = customTlsFeaturesProp - } - excludePublicCaSetProp, err := expandNetworkSecurityTlsInspectionPolicyExcludePublicCaSet(d.Get("exclude_public_ca_set"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("exclude_public_ca_set"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, excludePublicCaSetProp)) { - obj["excludePublicCaSet"] = excludePublicCaSetProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}projects/{{project}}/locations/{{location}}/tlsInspectionPolicies/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating TlsInspectionPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("ca_pool") { - updateMask = append(updateMask, "caPool") - } - - if d.HasChange("trust_config") { - updateMask = append(updateMask, "trustConfig") - } - - if d.HasChange("min_tls_version") { - updateMask = append(updateMask, "minTlsVersion") - } - - if d.HasChange("tls_feature_profile") { - updateMask = append(updateMask, "tlsFeatureProfile") - } - - if d.HasChange("custom_tls_features") { - updateMask = append(updateMask, "customTlsFeatures") - } - - if d.HasChange("exclude_public_ca_set") { - updateMask = append(updateMask, "excludePublicCaSet") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating TlsInspectionPolicy %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating TlsInspectionPolicy %q: %#v", d.Id(), res) - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Updating TlsInspectionPolicy", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkSecurityTlsInspectionPolicyRead(d, meta) -} - -func resourceNetworkSecurityTlsInspectionPolicyDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for TlsInspectionPolicy: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkSecurityBasePath}}projects/{{project}}/locations/{{location}}/tlsInspectionPolicies/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting TlsInspectionPolicy %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "TlsInspectionPolicy") - } - - err = NetworkSecurityOperationWaitTime( - config, res, project, "Deleting TlsInspectionPolicy", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting TlsInspectionPolicy %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkSecurityTlsInspectionPolicyImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/tlsInspectionPolicies/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/tlsInspectionPolicies/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkSecurityTlsInspectionPolicyCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyCaPool(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyTrustConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyMinTlsVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyTlsFeatureProfile(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyCustomTlsFeatures(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkSecurityTlsInspectionPolicyExcludePublicCaSet(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkSecurityTlsInspectionPolicyDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityTlsInspectionPolicyCaPool(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityTlsInspectionPolicyTrustConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityTlsInspectionPolicyMinTlsVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityTlsInspectionPolicyTlsFeatureProfile(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityTlsInspectionPolicyCustomTlsFeatures(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkSecurityTlsInspectionPolicyExcludePublicCaSet(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_tls_inspection_policy_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_tls_inspection_policy_sweeper.go deleted file mode 100644 index b40bbf51085..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_tls_inspection_policy_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networksecurity - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkSecurityTlsInspectionPolicy", testSweepNetworkSecurityTlsInspectionPolicy) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkSecurityTlsInspectionPolicy(region string) error { - resourceName := "NetworkSecurityTlsInspectionPolicy" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networksecurity.googleapis.com/v1/projects/{{project}}/locations/{{location}}/tlsInspectionPolicies", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["tlsInspectionPolicies"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networksecurity.googleapis.com/v1/projects/{{project}}/locations/{{location}}/tlsInspectionPolicies/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_url_lists.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_url_lists.go index ddd6dd48179..ee1d603e5ca 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_url_lists.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networksecurity/resource_network_security_url_lists.go @@ -20,7 +20,6 @@ package networksecurity import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -143,7 +142,6 @@ func resourceNetworkSecurityUrlListsCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -152,7 +150,6 @@ func resourceNetworkSecurityUrlListsCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating UrlLists: %s", err) @@ -205,14 +202,12 @@ func resourceNetworkSecurityUrlListsRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkSecurityUrlLists %q", d.Id())) @@ -273,7 +268,6 @@ func resourceNetworkSecurityUrlListsUpdate(d *schema.ResourceData, meta interfac } log.Printf("[DEBUG] Updating UrlLists %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -305,7 +299,6 @@ func resourceNetworkSecurityUrlListsUpdate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -353,8 +346,6 @@ func resourceNetworkSecurityUrlListsDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting UrlLists %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -364,7 +355,6 @@ func resourceNetworkSecurityUrlListsDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "UrlLists") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_keyset.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_keyset.go index ddd99274c00..664cab6b575 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_keyset.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_keyset.go @@ -20,7 +20,6 @@ package networkservices import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -216,7 +215,6 @@ func resourceNetworkServicesEdgeCacheKeysetCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -225,7 +223,6 @@ func resourceNetworkServicesEdgeCacheKeysetCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -279,14 +276,12 @@ func resourceNetworkServicesEdgeCacheKeysetRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -366,7 +361,6 @@ func resourceNetworkServicesEdgeCacheKeysetUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating EdgeCacheKeyset %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -406,7 +400,6 @@ func resourceNetworkServicesEdgeCacheKeysetUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -455,8 +448,6 @@ func resourceNetworkServicesEdgeCacheKeysetDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EdgeCacheKeyset %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -466,7 +457,6 @@ func resourceNetworkServicesEdgeCacheKeysetDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_origin.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_origin.go index 63b960a0999..9ebda365460 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_origin.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_origin.go @@ -20,7 +20,6 @@ package networkservices import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -465,7 +464,6 @@ func resourceNetworkServicesEdgeCacheOriginCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -474,7 +472,6 @@ func resourceNetworkServicesEdgeCacheOriginCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EdgeCacheOrigin: %s", err) @@ -527,14 +524,12 @@ func resourceNetworkServicesEdgeCacheOriginRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkServicesEdgeCacheOrigin %q", d.Id())) @@ -685,7 +680,6 @@ func resourceNetworkServicesEdgeCacheOriginUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating EdgeCacheOrigin %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -757,7 +751,6 @@ func resourceNetworkServicesEdgeCacheOriginUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -805,8 +798,6 @@ func resourceNetworkServicesEdgeCacheOriginDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EdgeCacheOrigin %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -816,7 +807,6 @@ func resourceNetworkServicesEdgeCacheOriginDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EdgeCacheOrigin") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_service.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_service.go index d8d70ecd381..a48e45f0209 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_service.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_edge_cache_service.go @@ -20,7 +20,6 @@ package networkservices import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -1112,7 +1111,6 @@ func resourceNetworkServicesEdgeCacheServiceCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1121,7 +1119,6 @@ func resourceNetworkServicesEdgeCacheServiceCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EdgeCacheService: %s", err) @@ -1174,14 +1171,12 @@ func resourceNetworkServicesEdgeCacheServiceRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkServicesEdgeCacheService %q", d.Id())) @@ -1320,7 +1315,6 @@ func resourceNetworkServicesEdgeCacheServiceUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating EdgeCacheService %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -1384,7 +1378,6 @@ func resourceNetworkServicesEdgeCacheServiceUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1432,8 +1425,6 @@ func resourceNetworkServicesEdgeCacheServiceDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EdgeCacheService %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1443,7 +1434,6 @@ func resourceNetworkServicesEdgeCacheServiceDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EdgeCacheService") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_gateway.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_gateway.go index e23a6380fe6..27ec03dad4c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_gateway.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_gateway.go @@ -20,7 +20,6 @@ package networkservices import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -209,6 +208,7 @@ Gateways of type 'OPEN_MESH' listen on 0.0.0.0.`, "certificate_urls": { Type: schema.TypeList, Optional: true, + ForceNew: true, Description: `A fully-qualified Certificates URL reference. The proxy presents a Certificate (selected based on SNI) when establishing a TLS connection. This feature only applies to gateways of type 'SECURE_WEB_GATEWAY'.`, Elem: &schema.Schema{ @@ -223,6 +223,7 @@ This feature only applies to gateways of type 'SECURE_WEB_GATEWAY'.`, "gateway_security_policy": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: `A fully-qualified GatewaySecurityPolicy URL reference. Defines how a server should apply security policy to inbound (VM to Proxy) initiated connections. For example: 'projects/*/locations/*/gatewaySecurityPolicies/swg-policy'. This policy is specific to gateways of type 'SECURE_WEB_GATEWAY'.`, @@ -414,7 +415,6 @@ func resourceNetworkServicesGatewayCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -423,7 +423,6 @@ func resourceNetworkServicesGatewayCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Gateway: %s", err) @@ -476,14 +475,12 @@ func resourceNetworkServicesGatewayRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkServicesGateway %q", d.Id())) @@ -579,18 +576,6 @@ func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface } else if v, ok := d.GetOkExists("server_tls_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, serverTlsPolicyProp)) { obj["serverTlsPolicy"] = serverTlsPolicyProp } - gatewaySecurityPolicyProp, err := expandNetworkServicesGatewayGatewaySecurityPolicy(d.Get("gateway_security_policy"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("gateway_security_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, gatewaySecurityPolicyProp)) { - obj["gatewaySecurityPolicy"] = gatewaySecurityPolicyProp - } - certificateUrlsProp, err := expandNetworkServicesGatewayCertificateUrls(d.Get("certificate_urls"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("certificate_urls"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, certificateUrlsProp)) { - obj["certificateUrls"] = certificateUrlsProp - } labelsProp, err := expandNetworkServicesGatewayEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -604,7 +589,6 @@ func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating Gateway %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -615,14 +599,6 @@ func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface updateMask = append(updateMask, "serverTlsPolicy") } - if d.HasChange("gateway_security_policy") { - updateMask = append(updateMask, "gatewaySecurityPolicy") - } - - if d.HasChange("certificate_urls") { - updateMask = append(updateMask, "certificateUrls") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -632,10 +608,6 @@ func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface if err != nil { return err } - if d.Get("type") == "SECURE_WEB_GATEWAY" { - obj["name"] = d.Get("name") - obj["type"] = d.Get("type") - } // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -652,7 +624,6 @@ func resourceNetworkServicesGatewayUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -700,8 +671,6 @@ func resourceNetworkServicesGatewayDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Gateway %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -711,7 +680,6 @@ func resourceNetworkServicesGatewayDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Gateway") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_route_extension.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_route_extension.go deleted file mode 100644 index 244932d466a..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_route_extension.go +++ /dev/null @@ -1,864 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkservices - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceNetworkServicesLbRouteExtension() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkServicesLbRouteExtensionCreate, - Read: resourceNetworkServicesLbRouteExtensionRead, - Update: resourceNetworkServicesLbRouteExtensionUpdate, - Delete: resourceNetworkServicesLbRouteExtensionDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkServicesLbRouteExtensionImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "extension_chains": { - Type: schema.TypeList, - Required: true, - Description: `A set of ordered extension chains that contain the match conditions and extensions to execute. -Match conditions for each extension chain are evaluated in sequence for a given request. -The first extension chain that has a condition that matches the request is executed. -Any subsequent extension chains do not execute. Limited to 5 extension chains per resource.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "extensions": { - Type: schema.TypeList, - Required: true, - Description: `A set of extensions to execute for the matching request. -At least one extension is required. Up to 3 extensions can be defined for each extension chain for -LbTrafficExtension resource. LbRouteExtension chains are limited to 1 extension per extension chain.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: `The name for this extension. The name is logged as part of the HTTP request logs. -The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, -and can have a maximum length of 63 characters. Additionally, the first character must be a letter -and the last a letter or a number.`, - }, - "service": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `The reference to the service that runs the extension. Must be a reference to a backend service`, - }, - "authority": { - Type: schema.TypeString, - Optional: true, - Description: `The :authority header in the gRPC request sent from Envoy to the extension service.`, - }, - "fail_open": { - Type: schema.TypeBool, - Optional: true, - Description: `Determines how the proxy behaves if the call to the extension fails or times out. -When set to TRUE, request or response processing continues without error. -Any subsequent extensions in the extension chain are also executed. -When set to FALSE: * If response headers have not been delivered to the downstream client, -a generic 500 error is returned to the client. The error response can be tailored by -configuring a custom error response in the load balancer.`, - }, - "forward_headers": { - Type: schema.TypeList, - Optional: true, - Description: `List of the HTTP headers to forward to the extension (from the client or backend). -If omitted, all headers are sent. Each element is a string indicating the header name.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timeout": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: tpgresource.DurationDiffSuppress, - Description: `Specifies the timeout for each individual message on the stream. The timeout must be between 10-1000 milliseconds. -A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, - }, - }, - }, - }, - "match_condition": { - Type: schema.TypeList, - Required: true, - Description: `Conditions under which this chain is invoked for a request.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cel_expression": { - Type: schema.TypeString, - Required: true, - Description: `A Common Expression Language (CEL) expression that is used to match requests for which the extension chain is executed.`, - }, - }, - }, - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: `The name for this extension chain. The name is logged as part of the HTTP request logs. -The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, -and can have a maximum length of 63 characters. Additionally, the first character must be a letter -and the last character must be a letter or a number.`, - }, - }, - }, - }, - "forwarding_rules": { - Type: schema.TypeList, - Required: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `A list of references to the forwarding rules to which this service extension is attached to. -At least one forwarding rule is required. There can be only one LbRouteExtension resource per forwarding rule.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "load_balancing_scheme": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"INTERNAL_MANAGED", "EXTERNAL_MANAGED"}), - Description: `All backend services and forwarding rules referenced by this extension must share the same load balancing scheme. -For more information, refer to [Choosing a load balancer](https://cloud.google.com/load-balancing/docs/backend-service) and -[Supported application load balancers](https://cloud.google.com/service-extensions/docs/callouts-overview#supported-lbs). Possible values: ["INTERNAL_MANAGED", "EXTERNAL_MANAGED"]`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The location of the route extension`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Name of the LbRouteExtension resource in the following format: projects/{project}/locations/{location}/lbRouteExtensions/{lbRouteExtension}`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `A human-readable description of the resource.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `Set of labels associated with the LbRouteExtension resource. - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkServicesLbRouteExtensionCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkServicesLbRouteExtensionDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - forwardingRulesProp, err := expandNetworkServicesLbRouteExtensionForwardingRules(d.Get("forwarding_rules"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("forwarding_rules"); !tpgresource.IsEmptyValue(reflect.ValueOf(forwardingRulesProp)) && (ok || !reflect.DeepEqual(v, forwardingRulesProp)) { - obj["forwardingRules"] = forwardingRulesProp - } - extensionChainsProp, err := expandNetworkServicesLbRouteExtensionExtensionChains(d.Get("extension_chains"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("extension_chains"); !tpgresource.IsEmptyValue(reflect.ValueOf(extensionChainsProp)) && (ok || !reflect.DeepEqual(v, extensionChainsProp)) { - obj["extensionChains"] = extensionChainsProp - } - loadBalancingSchemeProp, err := expandNetworkServicesLbRouteExtensionLoadBalancingScheme(d.Get("load_balancing_scheme"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("load_balancing_scheme"); !tpgresource.IsEmptyValue(reflect.ValueOf(loadBalancingSchemeProp)) && (ok || !reflect.DeepEqual(v, loadBalancingSchemeProp)) { - obj["loadBalancingScheme"] = loadBalancingSchemeProp - } - labelsProp, err := expandNetworkServicesLbRouteExtensionEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbRouteExtensions?lbRouteExtensionId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new LbRouteExtension: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbRouteExtension: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating LbRouteExtension: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/lbRouteExtensions/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkServicesOperationWaitTime( - config, res, project, "Creating LbRouteExtension", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create LbRouteExtension: %s", err) - } - - log.Printf("[DEBUG] Finished creating LbRouteExtension %q: %#v", d.Id(), res) - - return resourceNetworkServicesLbRouteExtensionRead(d, meta) -} - -func resourceNetworkServicesLbRouteExtensionRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbRouteExtensions/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbRouteExtension: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkServicesLbRouteExtension %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - - if err := d.Set("description", flattenNetworkServicesLbRouteExtensionDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - if err := d.Set("labels", flattenNetworkServicesLbRouteExtensionLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - if err := d.Set("forwarding_rules", flattenNetworkServicesLbRouteExtensionForwardingRules(res["forwardingRules"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - if err := d.Set("extension_chains", flattenNetworkServicesLbRouteExtensionExtensionChains(res["extensionChains"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - if err := d.Set("load_balancing_scheme", flattenNetworkServicesLbRouteExtensionLoadBalancingScheme(res["loadBalancingScheme"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkServicesLbRouteExtensionTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkServicesLbRouteExtensionEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading LbRouteExtension: %s", err) - } - - return nil -} - -func resourceNetworkServicesLbRouteExtensionUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbRouteExtension: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkServicesLbRouteExtensionDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - forwardingRulesProp, err := expandNetworkServicesLbRouteExtensionForwardingRules(d.Get("forwarding_rules"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("forwarding_rules"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, forwardingRulesProp)) { - obj["forwardingRules"] = forwardingRulesProp - } - extensionChainsProp, err := expandNetworkServicesLbRouteExtensionExtensionChains(d.Get("extension_chains"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("extension_chains"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, extensionChainsProp)) { - obj["extensionChains"] = extensionChainsProp - } - labelsProp, err := expandNetworkServicesLbRouteExtensionEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbRouteExtensions/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating LbRouteExtension %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("forwarding_rules") { - updateMask = append(updateMask, "forwardingRules") - } - - if d.HasChange("extension_chains") { - updateMask = append(updateMask, "extensionChains") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating LbRouteExtension %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating LbRouteExtension %q: %#v", d.Id(), res) - } - - err = NetworkServicesOperationWaitTime( - config, res, project, "Updating LbRouteExtension", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkServicesLbRouteExtensionRead(d, meta) -} - -func resourceNetworkServicesLbRouteExtensionDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbRouteExtension: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbRouteExtensions/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting LbRouteExtension %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "LbRouteExtension") - } - - err = NetworkServicesOperationWaitTime( - config, res, project, "Deleting LbRouteExtension", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting LbRouteExtension %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkServicesLbRouteExtensionImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/lbRouteExtensions/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/lbRouteExtensions/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkServicesLbRouteExtensionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkServicesLbRouteExtensionForwardingRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChains(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenNetworkServicesLbRouteExtensionExtensionChainsName(original["name"], d, config), - "match_condition": flattenNetworkServicesLbRouteExtensionExtensionChainsMatchCondition(original["matchCondition"], d, config), - "extensions": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensions(original["extensions"], d, config), - }) - } - return transformed -} -func flattenNetworkServicesLbRouteExtensionExtensionChainsName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsMatchCondition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["cel_expression"] = - flattenNetworkServicesLbRouteExtensionExtensionChainsMatchConditionCelExpression(original["celExpression"], d, config) - return []interface{}{transformed} -} -func flattenNetworkServicesLbRouteExtensionExtensionChainsMatchConditionCelExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsName(original["name"], d, config), - "authority": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsAuthority(original["authority"], d, config), - "service": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsService(original["service"], d, config), - "timeout": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsTimeout(original["timeout"], d, config), - "fail_open": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsFailOpen(original["failOpen"], d, config), - "forward_headers": flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsForwardHeaders(original["forwardHeaders"], d, config), - }) - } - return transformed -} -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsAuthority(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsTimeout(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsFailOpen(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionExtensionChainsExtensionsForwardHeaders(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionLoadBalancingScheme(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbRouteExtensionTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkServicesLbRouteExtensionEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkServicesLbRouteExtensionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionForwardingRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChains(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandNetworkServicesLbRouteExtensionExtensionChainsName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedMatchCondition, err := expandNetworkServicesLbRouteExtensionExtensionChainsMatchCondition(original["match_condition"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMatchCondition); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["matchCondition"] = transformedMatchCondition - } - - transformedExtensions, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensions(original["extensions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExtensions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["extensions"] = transformedExtensions - } - - req = append(req, transformed) - } - return req, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsMatchCondition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCelExpression, err := expandNetworkServicesLbRouteExtensionExtensionChainsMatchConditionCelExpression(original["cel_expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCelExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["celExpression"] = transformedCelExpression - } - - return transformed, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsMatchConditionCelExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedAuthority, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsAuthority(original["authority"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthority); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authority"] = transformedAuthority - } - - transformedService, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsService(original["service"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedService); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["service"] = transformedService - } - - transformedTimeout, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsTimeout(original["timeout"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTimeout); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["timeout"] = transformedTimeout - } - - transformedFailOpen, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsFailOpen(original["fail_open"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFailOpen); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["failOpen"] = transformedFailOpen - } - - transformedForwardHeaders, err := expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsForwardHeaders(original["forward_headers"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedForwardHeaders); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["forwardHeaders"] = transformedForwardHeaders - } - - req = append(req, transformed) - } - return req, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsAuthority(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsTimeout(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsFailOpen(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionExtensionChainsExtensionsForwardHeaders(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionLoadBalancingScheme(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbRouteExtensionEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_route_extension_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_route_extension_sweeper.go deleted file mode 100644 index 75dccf25255..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_route_extension_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkservices - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkServicesLbRouteExtension", testSweepNetworkServicesLbRouteExtension) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkServicesLbRouteExtension(region string) error { - resourceName := "NetworkServicesLbRouteExtension" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networkservices.googleapis.com/v1/projects/{{project}}/locations/{{location}}/lbRouteExtensions", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["lbRouteExtensions"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networkservices.googleapis.com/v1/projects/{{project}}/locations/{{location}}/lbRouteExtensions/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_traffic_extension.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_traffic_extension.go deleted file mode 100644 index bb5d7dc9b14..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_traffic_extension.go +++ /dev/null @@ -1,892 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkservices - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceNetworkServicesLbTrafficExtension() *schema.Resource { - return &schema.Resource{ - Create: resourceNetworkServicesLbTrafficExtensionCreate, - Read: resourceNetworkServicesLbTrafficExtensionRead, - Update: resourceNetworkServicesLbTrafficExtensionUpdate, - Delete: resourceNetworkServicesLbTrafficExtensionDelete, - - Importer: &schema.ResourceImporter{ - State: resourceNetworkServicesLbTrafficExtensionImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "extension_chains": { - Type: schema.TypeList, - Required: true, - Description: `A set of ordered extension chains that contain the match conditions and extensions to execute. -Match conditions for each extension chain are evaluated in sequence for a given request. -The first extension chain that has a condition that matches the request is executed. -Any subsequent extension chains do not execute. Limited to 5 extension chains per resource.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "extensions": { - Type: schema.TypeList, - Required: true, - Description: `A set of extensions to execute for the matching request. -At least one extension is required. Up to 3 extensions can be defined for each extension chain for -LbTrafficExtension resource. LbRouteExtension chains are limited to 1 extension per extension chain.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - Description: `The name for this extension. The name is logged as part of the HTTP request logs. -The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, -and can have a maximum length of 63 characters. Additionally, the first character must be a letter -and the last a letter or a number.`, - }, - "service": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `The reference to the service that runs the extension. Must be a reference to a backend service`, - }, - "authority": { - Type: schema.TypeString, - Optional: true, - Description: `The :authority header in the gRPC request sent from Envoy to the extension service.`, - }, - "fail_open": { - Type: schema.TypeBool, - Optional: true, - Description: `Determines how the proxy behaves if the call to the extension fails or times out. -When set to TRUE, request or response processing continues without error. -Any subsequent extensions in the extension chain are also executed. -When set to FALSE: * If response headers have not been delivered to the downstream client, -a generic 500 error is returned to the client. The error response can be tailored by -configuring a custom error response in the load balancer.`, - }, - "forward_headers": { - Type: schema.TypeList, - Optional: true, - Description: `List of the HTTP headers to forward to the extension (from the client or backend). -If omitted, all headers are sent. Each element is a string indicating the header name.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "supported_events": { - Type: schema.TypeList, - Optional: true, - Description: `A set of events during request or response processing for which this extension is called. -This field is required for the LbTrafficExtension resource. It's not relevant for the LbRouteExtension -resource. Possible values:'EVENT_TYPE_UNSPECIFIED', 'REQUEST_HEADERS', 'REQUEST_BODY', 'RESPONSE_HEADERS', -'RESPONSE_BODY', 'RESPONSE_BODY' and 'RESPONSE_BODY'.`, - MinItems: 1, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "timeout": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: tpgresource.DurationDiffSuppress, - Description: `Specifies the timeout for each individual message on the stream. The timeout must be between 10-1000 milliseconds. -A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, - }, - }, - }, - }, - "match_condition": { - Type: schema.TypeList, - Required: true, - Description: `Conditions under which this chain is invoked for a request.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cel_expression": { - Type: schema.TypeString, - Required: true, - Description: `A Common Expression Language (CEL) expression that is used to match requests for which the extension chain is executed.`, - }, - }, - }, - }, - "name": { - Type: schema.TypeString, - Required: true, - Description: `The name for this extension chain. The name is logged as part of the HTTP request logs. -The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, -and can have a maximum length of 63 characters. Additionally, the first character must be a letter -and the last a letter or a number.`, - }, - }, - }, - }, - "forwarding_rules": { - Type: schema.TypeList, - Required: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `A list of references to the forwarding rules to which this service extension is attached to. -At least one forwarding rule is required. There can be only one LBTrafficExtension resource per forwarding rule.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The location of the traffic extension`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Name of the LbTrafficExtension resource in the following format: projects/{project}/locations/{location}/lbTrafficExtensions/{lbTrafficExtension}.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `A human-readable description of the resource.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `Set of labels associated with the LbTrafficExtension resource. - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "load_balancing_scheme": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"INTERNAL_MANAGED", "EXTERNAL_MANAGED", ""}), - Description: `All backend services and forwarding rules referenced by this extension must share the same load balancing scheme. -For more information, refer to [Choosing a load balancer](https://cloud.google.com/load-balancing/docs/backend-service) and -[Supported application load balancers](https://cloud.google.com/service-extensions/docs/callouts-overview#supported-lbs). Possible values: ["INTERNAL_MANAGED", "EXTERNAL_MANAGED"]`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceNetworkServicesLbTrafficExtensionCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkServicesLbTrafficExtensionDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - forwardingRulesProp, err := expandNetworkServicesLbTrafficExtensionForwardingRules(d.Get("forwarding_rules"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("forwarding_rules"); !tpgresource.IsEmptyValue(reflect.ValueOf(forwardingRulesProp)) && (ok || !reflect.DeepEqual(v, forwardingRulesProp)) { - obj["forwardingRules"] = forwardingRulesProp - } - extensionChainsProp, err := expandNetworkServicesLbTrafficExtensionExtensionChains(d.Get("extension_chains"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("extension_chains"); !tpgresource.IsEmptyValue(reflect.ValueOf(extensionChainsProp)) && (ok || !reflect.DeepEqual(v, extensionChainsProp)) { - obj["extensionChains"] = extensionChainsProp - } - loadBalancingSchemeProp, err := expandNetworkServicesLbTrafficExtensionLoadBalancingScheme(d.Get("load_balancing_scheme"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("load_balancing_scheme"); !tpgresource.IsEmptyValue(reflect.ValueOf(loadBalancingSchemeProp)) && (ok || !reflect.DeepEqual(v, loadBalancingSchemeProp)) { - obj["loadBalancingScheme"] = loadBalancingSchemeProp - } - labelsProp, err := expandNetworkServicesLbTrafficExtensionEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbTrafficExtensions?lbTrafficExtensionId={{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new LbTrafficExtension: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbTrafficExtension: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating LbTrafficExtension: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/lbTrafficExtensions/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = NetworkServicesOperationWaitTime( - config, res, project, "Creating LbTrafficExtension", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create LbTrafficExtension: %s", err) - } - - log.Printf("[DEBUG] Finished creating LbTrafficExtension %q: %#v", d.Id(), res) - - return resourceNetworkServicesLbTrafficExtensionRead(d, meta) -} - -func resourceNetworkServicesLbTrafficExtensionRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbTrafficExtensions/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbTrafficExtension: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NetworkServicesLbTrafficExtension %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - - if err := d.Set("description", flattenNetworkServicesLbTrafficExtensionDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - if err := d.Set("labels", flattenNetworkServicesLbTrafficExtensionLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - if err := d.Set("forwarding_rules", flattenNetworkServicesLbTrafficExtensionForwardingRules(res["forwardingRules"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - if err := d.Set("extension_chains", flattenNetworkServicesLbTrafficExtensionExtensionChains(res["extensionChains"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - if err := d.Set("load_balancing_scheme", flattenNetworkServicesLbTrafficExtensionLoadBalancingScheme(res["loadBalancingScheme"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - if err := d.Set("terraform_labels", flattenNetworkServicesLbTrafficExtensionTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - if err := d.Set("effective_labels", flattenNetworkServicesLbTrafficExtensionEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading LbTrafficExtension: %s", err) - } - - return nil -} - -func resourceNetworkServicesLbTrafficExtensionUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbTrafficExtension: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - descriptionProp, err := expandNetworkServicesLbTrafficExtensionDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - forwardingRulesProp, err := expandNetworkServicesLbTrafficExtensionForwardingRules(d.Get("forwarding_rules"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("forwarding_rules"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, forwardingRulesProp)) { - obj["forwardingRules"] = forwardingRulesProp - } - extensionChainsProp, err := expandNetworkServicesLbTrafficExtensionExtensionChains(d.Get("extension_chains"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("extension_chains"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, extensionChainsProp)) { - obj["extensionChains"] = extensionChainsProp - } - labelsProp, err := expandNetworkServicesLbTrafficExtensionEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbTrafficExtensions/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating LbTrafficExtension %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("forwarding_rules") { - updateMask = append(updateMask, "forwardingRules") - } - - if d.HasChange("extension_chains") { - updateMask = append(updateMask, "extensionChains") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating LbTrafficExtension %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating LbTrafficExtension %q: %#v", d.Id(), res) - } - - err = NetworkServicesOperationWaitTime( - config, res, project, "Updating LbTrafficExtension", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceNetworkServicesLbTrafficExtensionRead(d, meta) -} - -func resourceNetworkServicesLbTrafficExtensionDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for LbTrafficExtension: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{NetworkServicesBasePath}}projects/{{project}}/locations/{{location}}/lbTrafficExtensions/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting LbTrafficExtension %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "LbTrafficExtension") - } - - err = NetworkServicesOperationWaitTime( - config, res, project, "Deleting LbTrafficExtension", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting LbTrafficExtension %q: %#v", d.Id(), res) - return nil -} - -func resourceNetworkServicesLbTrafficExtensionImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/lbTrafficExtensions/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/lbTrafficExtensions/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenNetworkServicesLbTrafficExtensionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkServicesLbTrafficExtensionForwardingRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChains(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenNetworkServicesLbTrafficExtensionExtensionChainsName(original["name"], d, config), - "match_condition": flattenNetworkServicesLbTrafficExtensionExtensionChainsMatchCondition(original["matchCondition"], d, config), - "extensions": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensions(original["extensions"], d, config), - }) - } - return transformed -} -func flattenNetworkServicesLbTrafficExtensionExtensionChainsName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsMatchCondition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["cel_expression"] = - flattenNetworkServicesLbTrafficExtensionExtensionChainsMatchConditionCelExpression(original["celExpression"], d, config) - return []interface{}{transformed} -} -func flattenNetworkServicesLbTrafficExtensionExtensionChainsMatchConditionCelExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsName(original["name"], d, config), - "authority": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsAuthority(original["authority"], d, config), - "service": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsService(original["service"], d, config), - "timeout": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsTimeout(original["timeout"], d, config), - "fail_open": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsFailOpen(original["failOpen"], d, config), - "forward_headers": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsForwardHeaders(original["forwardHeaders"], d, config), - "supported_events": flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsSupportedEvents(original["supportedEvents"], d, config), - }) - } - return transformed -} -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsAuthority(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsTimeout(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsFailOpen(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsForwardHeaders(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionExtensionChainsExtensionsSupportedEvents(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionLoadBalancingScheme(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenNetworkServicesLbTrafficExtensionTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenNetworkServicesLbTrafficExtensionEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandNetworkServicesLbTrafficExtensionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionForwardingRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChains(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandNetworkServicesLbTrafficExtensionExtensionChainsName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedMatchCondition, err := expandNetworkServicesLbTrafficExtensionExtensionChainsMatchCondition(original["match_condition"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMatchCondition); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["matchCondition"] = transformedMatchCondition - } - - transformedExtensions, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensions(original["extensions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExtensions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["extensions"] = transformedExtensions - } - - req = append(req, transformed) - } - return req, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsMatchCondition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedCelExpression, err := expandNetworkServicesLbTrafficExtensionExtensionChainsMatchConditionCelExpression(original["cel_expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCelExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["celExpression"] = transformedCelExpression - } - - return transformed, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsMatchConditionCelExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedAuthority, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsAuthority(original["authority"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAuthority); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["authority"] = transformedAuthority - } - - transformedService, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsService(original["service"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedService); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["service"] = transformedService - } - - transformedTimeout, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsTimeout(original["timeout"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTimeout); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["timeout"] = transformedTimeout - } - - transformedFailOpen, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsFailOpen(original["fail_open"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFailOpen); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["failOpen"] = transformedFailOpen - } - - transformedForwardHeaders, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsForwardHeaders(original["forward_headers"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedForwardHeaders); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["forwardHeaders"] = transformedForwardHeaders - } - - transformedSupportedEvents, err := expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsSupportedEvents(original["supported_events"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSupportedEvents); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["supportedEvents"] = transformedSupportedEvents - } - - req = append(req, transformed) - } - return req, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsAuthority(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsService(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsTimeout(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsFailOpen(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsForwardHeaders(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionExtensionChainsExtensionsSupportedEvents(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionLoadBalancingScheme(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandNetworkServicesLbTrafficExtensionEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_traffic_extension_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_traffic_extension_sweeper.go deleted file mode 100644 index 735c6893f93..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/networkservices/resource_network_services_lb_traffic_extension_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package networkservices - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("NetworkServicesLbTrafficExtension", testSweepNetworkServicesLbTrafficExtension) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepNetworkServicesLbTrafficExtension(region string) error { - resourceName := "NetworkServicesLbTrafficExtension" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://networkservices.googleapis.com/v1/projects/{{project}}/locations/{{location}}/lbTrafficExtensions", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["lbTrafficExtensions"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://networkservices.googleapis.com/v1/projects/{{project}}/locations/{{location}}/lbTrafficExtensions/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_environment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_environment.go index 105e035e43d..838c9e1b7bb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_environment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_environment.go @@ -20,7 +20,6 @@ package notebooks import ( "fmt" "log" - "net/http" "reflect" "time" @@ -205,7 +204,6 @@ func resourceNotebooksEnvironmentCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -214,7 +212,6 @@ func resourceNotebooksEnvironmentCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Environment: %s", err) @@ -277,14 +274,12 @@ func resourceNotebooksEnvironmentRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NotebooksEnvironment %q", d.Id())) @@ -369,7 +364,6 @@ func resourceNotebooksEnvironmentUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Environment %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -384,7 +378,6 @@ func resourceNotebooksEnvironmentUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -431,8 +424,6 @@ func resourceNotebooksEnvironmentDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Environment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -442,7 +433,6 @@ func resourceNotebooksEnvironmentDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Environment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_instance.go index b373a557215..0a1af96df97 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_instance.go @@ -21,14 +21,13 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "sort" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -88,9 +87,9 @@ func NotebooksInstanceKmsDiffSuppress(_, old, new string, _ *schema.ResourceData // waitForNotebooksInstanceActive waits for an Notebook instance to become "ACTIVE" func waitForNotebooksInstanceActive(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceNotebooksInstanceRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) @@ -99,7 +98,7 @@ func waitForNotebooksInstanceActive(d *schema.ResourceData, config *transport_tp log.Printf("[DEBUG] Notebook Instance %q has state %q.", name, state) return nil } else { - return retry.RetryableError(fmt.Errorf("Notebook Instance %q has state %q. Waiting for ACTIVE state", name, state)) + return resource.RetryableError(fmt.Errorf("Notebook Instance %q has state %q. Waiting for ACTIVE state", name, state)) } }) @@ -770,7 +769,6 @@ func resourceNotebooksInstanceCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -779,7 +777,6 @@ func resourceNotebooksInstanceCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -856,14 +853,12 @@ func resourceNotebooksInstanceRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NotebooksInstance %q", d.Id())) @@ -992,8 +987,6 @@ func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1007,7 +1000,6 @@ func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) @@ -1042,8 +1034,6 @@ func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) e return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1057,7 +1047,6 @@ func resourceNotebooksInstanceUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) @@ -1126,8 +1115,6 @@ func resourceNotebooksInstanceDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1137,7 +1124,6 @@ func resourceNotebooksInstanceDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_location.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_location.go index dadee9eb87e..3196ee652c0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_location.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_location.go @@ -20,7 +20,6 @@ package notebooks import ( "fmt" "log" - "net/http" "reflect" "time" @@ -107,7 +106,6 @@ func resourceNotebooksLocationCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -116,7 +114,6 @@ func resourceNotebooksLocationCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Location: %s", err) @@ -183,14 +180,12 @@ func resourceNotebooksLocationRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NotebooksLocation %q", d.Id())) @@ -239,7 +234,6 @@ func resourceNotebooksLocationUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Location %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -254,7 +248,6 @@ func resourceNotebooksLocationUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -301,8 +294,6 @@ func resourceNotebooksLocationDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Location %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -312,7 +303,6 @@ func resourceNotebooksLocationDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Location") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_runtime.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_runtime.go index d035a35d899..d0fe61720b4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_runtime.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/notebooks/resource_notebooks_runtime.go @@ -20,7 +20,6 @@ package notebooks import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -716,7 +715,6 @@ func resourceNotebooksRuntimeCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -725,7 +723,6 @@ func resourceNotebooksRuntimeCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Runtime: %s", err) @@ -788,14 +785,12 @@ func resourceNotebooksRuntimeRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("NotebooksRuntime %q", d.Id())) @@ -883,7 +878,6 @@ func resourceNotebooksRuntimeUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Runtime %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("virtual_machine") { @@ -992,7 +986,6 @@ func resourceNotebooksRuntimeUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1040,8 +1033,6 @@ func resourceNotebooksRuntimeDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Runtime %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1051,7 +1042,6 @@ func resourceNotebooksRuntimeDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Runtime") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_custom_constraint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_custom_constraint.go index ee1fa9e2074..43ffa445aa9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_custom_constraint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_custom_constraint.go @@ -20,7 +20,6 @@ package orgpolicy import ( "fmt" "log" - "net/http" "reflect" "time" @@ -175,7 +174,6 @@ func resourceOrgPolicyCustomConstraintCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -184,7 +182,6 @@ func resourceOrgPolicyCustomConstraintCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CustomConstraint: %s", err) @@ -221,14 +218,12 @@ func resourceOrgPolicyCustomConstraintRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("OrgPolicyCustomConstraint %q", d.Id())) @@ -314,7 +309,6 @@ func resourceOrgPolicyCustomConstraintUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating CustomConstraint %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -329,7 +323,6 @@ func resourceOrgPolicyCustomConstraintUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -362,8 +355,6 @@ func resourceOrgPolicyCustomConstraintDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CustomConstraint %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -373,7 +364,6 @@ func resourceOrgPolicyCustomConstraintDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CustomConstraint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy.go index 5d940dbf577..8dfff02f838 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy.go @@ -3,41 +3,37 @@ // ---------------------------------------------------------------------------- // -// *** AUTO GENERATED CODE *** Type: MMv1 *** +// *** AUTO GENERATED CODE *** Type: DCL *** // // ---------------------------------------------------------------------------- // -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. +// This file is managed by Magic Modules (https://github.com/GoogleCloudPlatform/magic-modules) +// and is based on the DCL (https://github.com/GoogleCloudPlatform/declarative-resource-client-library). +// Changes will need to be made to the DCL or Magic Modules instead of here. // -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. +// We are not currently able to accept contributions to this file. If changes +// are required, please file an issue at https://github.com/hashicorp/terraform-provider-google/issues/new/choose // // ---------------------------------------------------------------------------- package orgpolicy import ( + "context" "fmt" "log" - "net/http" - "reflect" - "strconv" - "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy" + + "github.com/hashicorp/terraform-provider-google/google/tpgdclresource" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" ) -func resourceOrgpolicyPolicyRulesConditionExpressionDiffSuppress(_, old, new string, d *schema.ResourceData) bool { - oldReplaced := strings.ReplaceAll(strings.ReplaceAll(old, "Labels", "TagId"), "label", "tag") - newReplaced := strings.ReplaceAll(strings.ReplaceAll(new, "Labels", "TagId"), "label", "tag") - return oldReplaced == newReplaced -} - func ResourceOrgPolicyPolicy() *schema.Resource { return &schema.Resource{ Create: resourceOrgPolicyPolicyCreate, @@ -57,318 +53,340 @@ func ResourceOrgPolicyPolicy() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareResourceNames, - Description: `Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * 'projects/{project_number}/policies/{constraint_name}' * 'folders/{folder_id}/policies/{constraint_name}' * 'organizations/{organization_id}/policies/{constraint_name}' For example, "projects/123/policies/compute.disableSerialPortAccess". Note: 'projects/{project_id}/policies/{constraint_name}' is also an acceptable name for API requests, but responses will return the name using the equivalent project number.`, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Immutable. The resource name of the Policy. Must be one of the following forms, where constraint_name is the name of the constraint which this Policy configures: * `projects/{project_number}/policies/{constraint_name}` * `folders/{folder_id}/policies/{constraint_name}` * `organizations/{organization_id}/policies/{constraint_name}` For example, \"projects/123/policies/compute.disableSerialPortAccess\". Note: `projects/{project_id}/policies/{constraint_name}` is also an acceptable name for API requests, but responses will return the name using the equivalent project number.", }, + "parent": { Type: schema.TypeString, Required: true, ForceNew: true, DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The parent of the resource.`, + Description: "The parent of the resource.", }, + "dry_run_spec": { Type: schema.TypeList, Optional: true, - Description: `Dry-run policy. Audit-only policy, can be used to monitor how the policy would have impacted the existing and future resources if it's enforced.`, + Description: "Dry-run policy. Audit-only policy, can be used to monitor how the policy would have impacted the existing and future resources if it's enforced.", MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "inherit_from_parent": { - Type: schema.TypeBool, - Optional: true, - Description: `Determines the inheritance behavior for this policy. If 'inherit_from_parent' is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies which configure list constraints.`, - }, - "reset": { - Type: schema.TypeBool, - Optional: true, - Description: `Ignores policies set above this resource and restores the 'constraint_default' enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, 'rules' must be empty and 'inherit_from_parent' must be set to false.`, - }, - "rules": { - Type: schema.TypeList, - Optional: true, - Description: `In policies for boolean constraints, the following requirements apply: - There must be one and only one policy rule where condition is unset. - Boolean policy rules with conditions must set 'enforced' to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow_all": { - Type: schema.TypeString, - Optional: true, - Description: `Setting this to '"TRUE"' means that all values are allowed. This field can be set only in Policies for list constraints.`, - }, - "condition": { - Type: schema.TypeList, - Optional: true, - Description: `A condition which determines whether this rule is used in the evaluation of the policy. When set, the 'expression' field in the 'Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.`, - }, - "expression": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: resourceOrgpolicyPolicyRulesConditionExpressionDiffSuppress, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - "deny_all": { - Type: schema.TypeString, - Optional: true, - Description: `Setting this to '"TRUE"' means that all values are denied. This field can be set only in Policies for list constraints.`, - }, - "enforce": { - Type: schema.TypeString, - Optional: true, - Description: `If '"TRUE"', then the 'Policy' is enforced. If '"FALSE"', then any configuration is acceptable. This field can be set only in Policies for boolean constraints.`, - }, - "values": { - Type: schema.TypeList, - Optional: true, - Description: `List of values to be used for this policy rule. This field can be set only in policies for list constraints.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allowed_values": { - Type: schema.TypeList, - Optional: true, - Description: `List of values allowed at this resource.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "denied_values": { - Type: schema.TypeList, - Optional: true, - Description: `List of values denied at this resource.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - Description: `An opaque tag indicating the current version of the policy, used for concurrency control. This field is ignored if used in a 'CreatePolicy' request. When the policy' is returned from either a 'GetPolicy' or a 'ListPolicies' request, this 'etag' indicates the version of the current policy to use when executing a read-modify-write loop. When the policy is returned from a 'GetEffectivePolicy' request, the 'etag' will be unset.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The time stamp this was previously updated. This represents the last time a call to 'CreatePolicy' or 'UpdatePolicy' was made for that policy.`, - }, - }, - }, + Elem: OrgPolicyPolicyDryRunSpecSchema(), }, + "spec": { Type: schema.TypeList, Optional: true, - Description: `Basic information about the Organization Policy.`, + Description: "Basic information about the Organization Policy.", MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "inherit_from_parent": { - Type: schema.TypeBool, - Optional: true, - Description: `Determines the inheritance behavior for this 'Policy'. If 'inherit_from_parent' is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.`, - }, - "reset": { - Type: schema.TypeBool, - Optional: true, - Description: `Ignores policies set above this resource and restores the 'constraint_default' enforcement behavior of the specific 'Constraint' at this resource. This field can be set in policies for either list or boolean constraints. If set, 'rules' must be empty and 'inherit_from_parent' must be set to false.`, - }, - "rules": { - Type: schema.TypeList, - Optional: true, - Description: `Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set 'enforced' to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow_all": { - Type: schema.TypeString, - Optional: true, - Description: `Setting this to '"TRUE"' means that all values are allowed. This field can be set only in Policies for list constraints.`, - }, - "condition": { - Type: schema.TypeList, - Optional: true, - Description: `A condition which determines whether this rule is used in the evaluation of the policy. When set, the 'expression' field in the 'Expr' must include from 1 to 10 subexpressions, joined by the "||" or "&&" operators. Each subexpression must be of the form "resource.matchTag('/tag_key_short_name, 'tag_value_short_name')". or "resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: "resource.matchTag('123456789/environment, 'prod')". or "resource.matchTagId('tagKeys/123', 'tagValues/456')".`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.`, - }, - "expression": { - Type: schema.TypeString, - Optional: true, - DiffSuppressFunc: resourceOrgpolicyPolicyRulesConditionExpressionDiffSuppress, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - "deny_all": { - Type: schema.TypeString, - Optional: true, - Description: `Setting this to '"TRUE"' means that all values are denied. This field can be set only in Policies for list constraints.`, - }, - "enforce": { - Type: schema.TypeString, - Optional: true, - Description: `If '"TRUE"', then the 'Policy' is enforced. If '"FALSE"', then any configuration is acceptable. This field can be set only in Policies for boolean constraints.`, - }, - "values": { - Type: schema.TypeList, - Optional: true, - Description: `List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allowed_values": { - Type: schema.TypeList, - Optional: true, - Description: `List of values allowed at this resource.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "denied_values": { - Type: schema.TypeList, - Optional: true, - Description: `List of values denied at this resource.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - }, - }, - }, - "etag": { - Type: schema.TypeString, - Computed: true, - Description: `An opaque tag indicating the current version of the 'Policy', used for concurrency control. This field is ignored if used in a 'CreatePolicy' request. When the 'Policy' is returned from either a 'GetPolicy' or a 'ListPolicies' request, this 'etag' indicates the version of the current 'Policy' to use when executing a read-modify-write loop. When the 'Policy' is returned from a 'GetEffectivePolicy' request, the 'etag' will be unset.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. The time stamp this was previously updated. This represents the last time a call to 'CreatePolicy' or 'UpdatePolicy' was made for that 'Policy'.`, - }, - }, - }, + Elem: OrgPolicyPolicySpecSchema(), }, + "etag": { Type: schema.TypeString, Computed: true, - Description: `Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.`, + Description: "Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This 'etag' is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.", }, }, - UseJSONNumber: true, } } -func resourceOrgPolicyPolicyCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err +func OrgPolicyPolicyDryRunSpecSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "inherit_from_parent": { + Type: schema.TypeBool, + Optional: true, + Description: "Determines the inheritance behavior for this policy. If `inherit_from_parent` is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies which configure list constraints.", + }, + + "reset": { + Type: schema.TypeBool, + Optional: true, + Description: "Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.", + }, + + "rules": { + Type: schema.TypeList, + Optional: true, + Description: "In policies for boolean constraints, the following requirements apply: - There must be one and only one policy rule where condition is unset. - Boolean policy rules with conditions must set `enforced` to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.", + Elem: OrgPolicyPolicyDryRunSpecRulesSchema(), + }, + + "etag": { + Type: schema.TypeString, + Computed: true, + Description: "An opaque tag indicating the current version of the policy, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the policy` is returned from either a `GetPolicy` or a `ListPolicies` request, this `etag` indicates the version of the current policy to use when executing a read-modify-write loop. When the policy is returned from a `GetEffectivePolicy` request, the `etag` will be unset.", + }, + + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: "Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that policy.", + }, + }, } +} - obj := make(map[string]interface{}) - nameProp, err := expandOrgPolicyPolicyName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp +func OrgPolicyPolicyDryRunSpecRulesSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow_all": { + Type: schema.TypeString, + Optional: true, + Description: "Setting this to `\"TRUE\"` means that all values are allowed. This field can be set only in policies for list constraints.", + }, + + "condition": { + Type: schema.TypeList, + Optional: true, + Description: "A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr' must include from 1 to 10 subexpressions, joined by the \"||\" or \"&&\" operators. Each subexpression must be of the form \"resource.matchTag('/tag_key_short_name, 'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')\". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: \"resource.matchTag('123456789/environment, 'prod')\". or \"resource.matchTagId('tagKeys/123', 'tagValues/456')\".", + MaxItems: 1, + Elem: OrgPolicyPolicyDryRunSpecRulesConditionSchema(), + }, + + "deny_all": { + Type: schema.TypeString, + Optional: true, + Description: "Setting this to `\"TRUE\"` means that all values are denied. This field can be set only in policies for list constraints.", + }, + + "enforce": { + Type: schema.TypeString, + Optional: true, + Description: "If `\"TRUE\"`, then the policy is enforced. If `\"FALSE\"`, then any configuration is acceptable. This field can be set only in policies for boolean constraints.", + }, + + "values": { + Type: schema.TypeList, + Optional: true, + Description: "List of values to be used for this policy rule. This field can be set only in policies for list constraints.", + MaxItems: 1, + Elem: OrgPolicyPolicyDryRunSpecRulesValuesSchema(), + }, + }, } - specProp, err := expandOrgPolicyPolicySpec(d.Get("spec"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(specProp)) && (ok || !reflect.DeepEqual(v, specProp)) { - obj["spec"] = specProp +} + +func OrgPolicyPolicyDryRunSpecRulesConditionSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, + + "expression": { + Type: schema.TypeString, + Optional: true, + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, + + "location": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, + + "title": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, } - dryRunSpecProp, err := expandOrgPolicyPolicyDryRunSpec(d.Get("dry_run_spec"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dry_run_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(dryRunSpecProp)) && (ok || !reflect.DeepEqual(v, dryRunSpecProp)) { - obj["dryRunSpec"] = dryRunSpecProp +} + +func OrgPolicyPolicyDryRunSpecRulesValuesSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allowed_values": { + Type: schema.TypeList, + Optional: true, + Description: "List of values allowed at this resource.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "denied_values": { + Type: schema.TypeList, + Optional: true, + Description: "List of values denied at this resource.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, } +} - obj, err = resourceOrgPolicyPolicyEncoder(d, meta, obj) - if err != nil { - return err +func OrgPolicyPolicySpecSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "inherit_from_parent": { + Type: schema.TypeBool, + Optional: true, + Description: "Determines the inheritance behavior for this `Policy`. If `inherit_from_parent` is true, PolicyRules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this Policy becomes the new root for evaluation. This field can be set only for Policies which configure list constraints.", + }, + + "reset": { + Type: schema.TypeBool, + Optional: true, + Description: "Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific `Constraint` at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.", + }, + + "rules": { + Type: schema.TypeList, + Optional: true, + Description: "Up to 10 PolicyRules are allowed. In Policies for boolean constraints, the following requirements apply: - There must be one and only one PolicyRule where condition is unset. - BooleanPolicyRules with conditions must set `enforced` to the opposite of the PolicyRule without a condition. - During policy evaluation, PolicyRules with conditions that are true for a target resource take precedence.", + Elem: OrgPolicyPolicySpecRulesSchema(), + }, + + "etag": { + Type: schema.TypeString, + Computed: true, + Description: "An opaque tag indicating the current version of the `Policy`, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the `Policy` is returned from either a `GetPolicy` or a `ListPolicies` request, this `etag` indicates the version of the current `Policy` to use when executing a read-modify-write loop. When the `Policy` is returned from a `GetEffectivePolicy` request, the `etag` will be unset.", + }, + + "update_time": { + Type: schema.TypeString, + Computed: true, + Description: "Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that `Policy`.", + }, + }, + } +} + +func OrgPolicyPolicySpecRulesSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow_all": { + Type: schema.TypeString, + Optional: true, + Description: "Setting this to `\"TRUE\"` means that all values are allowed. This field can be set only in Policies for list constraints.", + }, + + "condition": { + Type: schema.TypeList, + Optional: true, + Description: "A condition which determines whether this rule is used in the evaluation of the policy. When set, the `expression` field in the `Expr' must include from 1 to 10 subexpressions, joined by the \"||\" or \"&&\" operators. Each subexpression must be of the form \"resource.matchTag('/tag_key_short_name, 'tag_value_short_name')\". or \"resource.matchTagId('tagKeys/key_id', 'tagValues/value_id')\". where key_name and value_name are the resource names for Label Keys and Values. These names are available from the Tag Manager Service. An example expression is: \"resource.matchTag('123456789/environment, 'prod')\". or \"resource.matchTagId('tagKeys/123', 'tagValues/456')\".", + MaxItems: 1, + Elem: OrgPolicyPolicySpecRulesConditionSchema(), + }, + + "deny_all": { + Type: schema.TypeString, + Optional: true, + Description: "Setting this to `\"TRUE\"` means that all values are denied. This field can be set only in Policies for list constraints.", + }, + + "enforce": { + Type: schema.TypeString, + Optional: true, + Description: "If `\"TRUE\"`, then the `Policy` is enforced. If `\"FALSE\"`, then any configuration is acceptable. This field can be set only in Policies for boolean constraints.", + }, + + "values": { + Type: schema.TypeList, + Optional: true, + Description: "List of values to be used for this PolicyRule. This field can be set only in Policies for list constraints.", + MaxItems: 1, + Elem: OrgPolicyPolicySpecRulesValuesSchema(), + }, + }, + } +} + +func OrgPolicyPolicySpecRulesConditionSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, + + "expression": { + Type: schema.TypeString, + Optional: true, + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, + + "location": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, + + "title": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, + } +} + +func OrgPolicyPolicySpecRulesValuesSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allowed_values": { + Type: schema.TypeList, + Optional: true, + Description: "List of values allowed at this resource.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + + "denied_values": { + Type: schema.TypeList, + Optional: true, + Description: "List of values denied at this resource.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, } +} - url, err := tpgresource.ReplaceVars(d, config, "{{OrgPolicyBasePath}}{{parent}}/policies") +func resourceOrgPolicyPolicyCreate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + + obj := &orgpolicy.Policy{ + Name: dcl.String(d.Get("name").(string)), + Parent: dcl.String(d.Get("parent").(string)), + DryRunSpec: expandOrgPolicyPolicyDryRunSpec(d.Get("dry_run_spec")), + Spec: expandOrgPolicyPolicySpec(d.Get("spec")), + } + + id, err := obj.ID() + if err != nil { + return fmt.Errorf("error constructing id: %s", err) + } + d.SetId(id) + directive := tpgdclresource.CreateDirective + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err } - - log.Printf("[DEBUG] Creating new Policy: %#v", obj) billingProject := "" - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsOrgpolicyRetryableError}, - }) - if err != nil { - return fmt.Errorf("Error creating Policy: %s", err) + client := transport_tpg.NewDCLOrgPolicyClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutCreate)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } + res, err := client.ApplyPolicy(context.Background(), obj, directive...) - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/policies/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) + if _, ok := err.(dcl.DiffAfterApplyError); ok { + log.Printf("[DEBUG] Diff after apply returned from the DCL: %s", err) + } else if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error creating Policy: %s", err) } - d.SetId(id) log.Printf("[DEBUG] Finished creating Policy %q: %#v", d.Id(), res) @@ -377,960 +395,447 @@ func resourceOrgPolicyPolicyCreate(d *schema.ResourceData, meta interface{}) err func resourceOrgPolicyPolicyRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err + + obj := &orgpolicy.Policy{ + Name: dcl.String(d.Get("name").(string)), + Parent: dcl.String(d.Get("parent").(string)), + DryRunSpec: expandOrgPolicyPolicyDryRunSpec(d.Get("dry_run_spec")), + Spec: expandOrgPolicyPolicySpec(d.Get("spec")), } - url, err := tpgresource.ReplaceVars(d, config, "{{OrgPolicyBasePath}}{{parent}}/policies/{{name}}") + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err } - billingProject := "" - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - // Call the encoder to shorten name even if the resource is created by another provider version. - resourceOrgPolicyPolicyEncoder(d, nil, nil) - // Re-create the url. - url, err = tpgresource.ReplaceVars(d, config, "{{OrgPolicyBasePath}}{{parent}}/policies/{{name}}") - if err != nil { - return err + client := transport_tpg.NewDCLOrgPolicyClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutRead)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsOrgpolicyRetryableError}, - }) + res, err := client.GetPolicy(context.Background(), obj) if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("OrgPolicyPolicy %q", d.Id())) + resourceName := fmt.Sprintf("OrgPolicyPolicy %q", d.Id()) + return tpgdclresource.HandleNotFoundDCLError(err, d, resourceName) } - if err := d.Set("spec", flattenOrgPolicyPolicySpec(res["spec"], d, config)); err != nil { - return fmt.Errorf("Error reading Policy: %s", err) + if err = d.Set("name", res.Name); err != nil { + return fmt.Errorf("error setting name in state: %s", err) + } + if err = d.Set("parent", res.Parent); err != nil { + return fmt.Errorf("error setting parent in state: %s", err) } - if err := d.Set("dry_run_spec", flattenOrgPolicyPolicyDryRunSpec(res["dryRunSpec"], d, config)); err != nil { - return fmt.Errorf("Error reading Policy: %s", err) + if err = d.Set("dry_run_spec", flattenOrgPolicyPolicyDryRunSpec(res.DryRunSpec)); err != nil { + return fmt.Errorf("error setting dry_run_spec in state: %s", err) } - if err := d.Set("etag", flattenOrgPolicyPolicyEtag(res["etag"], d, config)); err != nil { - return fmt.Errorf("Error reading Policy: %s", err) + if err = d.Set("spec", flattenOrgPolicyPolicySpec(res.Spec)); err != nil { + return fmt.Errorf("error setting spec in state: %s", err) + } + if err = d.Set("etag", res.Etag); err != nil { + return fmt.Errorf("error setting etag in state: %s", err) } return nil } - func resourceOrgPolicyPolicyUpdate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - specProp, err := expandOrgPolicyPolicySpec(d.Get("spec"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, specProp)) { - obj["spec"] = specProp - } - dryRunSpecProp, err := expandOrgPolicyPolicyDryRunSpec(d.Get("dry_run_spec"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dry_run_spec"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dryRunSpecProp)) { - obj["dryRunSpec"] = dryRunSpecProp - } - - obj, err = resourceOrgPolicyPolicyEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{OrgPolicyBasePath}}{{parent}}/policies/{{name}}") - if err != nil { - return err - } - log.Printf("[DEBUG] Updating Policy %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("spec") { - updateMask = append(updateMask, "policy.spec") + obj := &orgpolicy.Policy{ + Name: dcl.String(d.Get("name").(string)), + Parent: dcl.String(d.Get("parent").(string)), + DryRunSpec: expandOrgPolicyPolicyDryRunSpec(d.Get("dry_run_spec")), + Spec: expandOrgPolicyPolicySpec(d.Get("spec")), } - - if d.HasChange("dry_run_spec") { - updateMask = append(updateMask, "policy.dryRunSpec") - } - - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + directive := tpgdclresource.UpdateDirective + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err } + billingProject := "" // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsOrgpolicyRetryableError}, - }) - - if err != nil { - return fmt.Errorf("Error updating Policy %q: %s", d.Id(), err) + client := transport_tpg.NewDCLOrgPolicyClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutUpdate)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) } else { - log.Printf("[DEBUG] Finished updating Policy %q: %#v", d.Id(), res) + client.Config.BasePath = bp } + res, err := client.ApplyPolicy(context.Background(), obj, directive...) + + if _, ok := err.(dcl.DiffAfterApplyError); ok { + log.Printf("[DEBUG] Diff after apply returned from the DCL: %s", err) + } else if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error updating Policy: %s", err) + } + + log.Printf("[DEBUG] Finished creating Policy %q: %#v", d.Id(), res) return resourceOrgPolicyPolicyRead(d, meta) } func resourceOrgPolicyPolicyDelete(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - billingProject := "" + obj := &orgpolicy.Policy{ + Name: dcl.String(d.Get("name").(string)), + Parent: dcl.String(d.Get("parent").(string)), + DryRunSpec: expandOrgPolicyPolicyDryRunSpec(d.Get("dry_run_spec")), + Spec: expandOrgPolicyPolicySpec(d.Get("spec")), + } - url, err := tpgresource.ReplaceVars(d, config, "{{OrgPolicyBasePath}}{{parent}}/policies/{{name}}") + log.Printf("[DEBUG] Deleting Policy %q", d.Id()) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err } - - var obj map[string]interface{} - + billingProject := "" // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting Policy %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.IsOrgpolicyRetryableError}, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "Policy") + client := transport_tpg.NewDCLOrgPolicyClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutDelete)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp + } + if err := client.DeletePolicy(context.Background(), obj); err != nil { + return fmt.Errorf("Error deleting Policy: %s", err) } - log.Printf("[DEBUG] Finished deleting Policy %q: %#v", d.Id(), res) + log.Printf("[DEBUG] Finished deleting Policy %q", d.Id()) return nil } func resourceOrgPolicyPolicyImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P.+)/policies/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{parent}}/policies/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) + if err := tpgdclresource.ResourceOrgPolicyPolicyCustomImport(d, config); err != nil { + return nil, fmt.Errorf("error encountered in import: %v", err) } - d.SetId(id) return []*schema.ResourceData{d}, nil } -func flattenOrgPolicyPolicySpec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil +func expandOrgPolicyPolicyDryRunSpec(o interface{}) *orgpolicy.PolicyDryRunSpec { + if o == nil { + return orgpolicy.EmptyPolicyDryRunSpec } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return orgpolicy.EmptyPolicyDryRunSpec } - transformed := make(map[string]interface{}) - transformed["etag"] = - flattenOrgPolicyPolicySpecEtag(original["etag"], d, config) - transformed["update_time"] = - flattenOrgPolicyPolicySpecUpdateTime(original["updateTime"], d, config) - transformed["rules"] = - flattenOrgPolicyPolicySpecRules(original["rules"], d, config) - transformed["inherit_from_parent"] = - flattenOrgPolicyPolicySpecInheritFromParent(original["inheritFromParent"], d, config) - transformed["reset"] = - flattenOrgPolicyPolicySpecReset(original["reset"], d, config) - return []interface{}{transformed} -} -func flattenOrgPolicyPolicySpecEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicySpecUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicySpecRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "values": flattenOrgPolicyPolicySpecRulesValues(original["values"], d, config), - "allow_all": flattenOrgPolicyPolicySpecRulesAllowAll(original["allowAll"], d, config), - "deny_all": flattenOrgPolicyPolicySpecRulesDenyAll(original["denyAll"], d, config), - "enforce": flattenOrgPolicyPolicySpecRulesEnforce(original["enforce"], d, config), - "condition": flattenOrgPolicyPolicySpecRulesCondition(original["condition"], d, config), - }) + obj := objArr[0].(map[string]interface{}) + return &orgpolicy.PolicyDryRunSpec{ + InheritFromParent: dcl.Bool(obj["inherit_from_parent"].(bool)), + Reset: dcl.Bool(obj["reset"].(bool)), + Rules: expandOrgPolicyPolicyDryRunSpecRulesArray(obj["rules"]), } - return transformed } -func flattenOrgPolicyPolicySpecRulesValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { + +func flattenOrgPolicyPolicyDryRunSpec(obj *orgpolicy.PolicyDryRunSpec) interface{} { + if obj == nil || obj.Empty() { return nil } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + transformed := map[string]interface{}{ + "inherit_from_parent": obj.InheritFromParent, + "reset": obj.Reset, + "rules": flattenOrgPolicyPolicyDryRunSpecRulesArray(obj.Rules), + "etag": obj.Etag, + "update_time": obj.UpdateTime, } - transformed := make(map[string]interface{}) - transformed["allowed_values"] = - flattenOrgPolicyPolicySpecRulesValuesAllowedValues(original["allowedValues"], d, config) - transformed["denied_values"] = - flattenOrgPolicyPolicySpecRulesValuesDeniedValues(original["deniedValues"], d, config) + return []interface{}{transformed} -} -func flattenOrgPolicyPolicySpecRulesValuesAllowedValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenOrgPolicyPolicySpecRulesValuesDeniedValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v } - -func flattenOrgPolicyPolicySpecRulesAllowAll(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return "" +func expandOrgPolicyPolicyDryRunSpecRulesArray(o interface{}) []orgpolicy.PolicyDryRunSpecRules { + if o == nil { + return make([]orgpolicy.PolicyDryRunSpecRules, 0) } - return strings.ToUpper(strconv.FormatBool(v.(bool))) -} -func flattenOrgPolicyPolicySpecRulesDenyAll(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return "" + objs := o.([]interface{}) + if len(objs) == 0 || objs[0] == nil { + return make([]orgpolicy.PolicyDryRunSpecRules, 0) } - return strings.ToUpper(strconv.FormatBool(v.(bool))) -} -func flattenOrgPolicyPolicySpecRulesEnforce(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return "" + items := make([]orgpolicy.PolicyDryRunSpecRules, 0, len(objs)) + for _, item := range objs { + i := expandOrgPolicyPolicyDryRunSpecRules(item) + items = append(items, *i) } - return strings.ToUpper(strconv.FormatBool(v.(bool))) -} -func flattenOrgPolicyPolicySpecRulesCondition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenOrgPolicyPolicySpecRulesConditionExpression(original["expression"], d, config) - transformed["title"] = - flattenOrgPolicyPolicySpecRulesConditionTitle(original["title"], d, config) - transformed["description"] = - flattenOrgPolicyPolicySpecRulesConditionDescription(original["description"], d, config) - transformed["location"] = - flattenOrgPolicyPolicySpecRulesConditionLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenOrgPolicyPolicySpecRulesConditionExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicySpecRulesConditionTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicySpecRulesConditionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + return items } -func flattenOrgPolicyPolicySpecRulesConditionLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicySpecInheritFromParent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} +func expandOrgPolicyPolicyDryRunSpecRules(o interface{}) *orgpolicy.PolicyDryRunSpecRules { + if o == nil { + return orgpolicy.EmptyPolicyDryRunSpecRules + } -func flattenOrgPolicyPolicySpecReset(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + obj := o.(map[string]interface{}) + return &orgpolicy.PolicyDryRunSpecRules{ + AllowAll: tpgdclresource.ExpandEnumBool(obj["allow_all"].(string)), + Condition: expandOrgPolicyPolicyDryRunSpecRulesCondition(obj["condition"]), + DenyAll: tpgdclresource.ExpandEnumBool(obj["deny_all"].(string)), + Enforce: tpgdclresource.ExpandEnumBool(obj["enforce"].(string)), + Values: expandOrgPolicyPolicyDryRunSpecRulesValues(obj["values"]), + } } -func flattenOrgPolicyPolicyDryRunSpec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { +func flattenOrgPolicyPolicyDryRunSpecRulesArray(objs []orgpolicy.PolicyDryRunSpecRules) []interface{} { + if objs == nil { return nil } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + + items := []interface{}{} + for _, item := range objs { + i := flattenOrgPolicyPolicyDryRunSpecRules(&item) + items = append(items, i) } - transformed := make(map[string]interface{}) - transformed["etag"] = - flattenOrgPolicyPolicyDryRunSpecEtag(original["etag"], d, config) - transformed["update_time"] = - flattenOrgPolicyPolicyDryRunSpecUpdateTime(original["updateTime"], d, config) - transformed["rules"] = - flattenOrgPolicyPolicyDryRunSpecRules(original["rules"], d, config) - transformed["inherit_from_parent"] = - flattenOrgPolicyPolicyDryRunSpecInheritFromParent(original["inheritFromParent"], d, config) - transformed["reset"] = - flattenOrgPolicyPolicyDryRunSpecReset(original["reset"], d, config) - return []interface{}{transformed} -} -func flattenOrgPolicyPolicyDryRunSpecEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenOrgPolicyPolicyDryRunSpecUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + return items } -func flattenOrgPolicyPolicyDryRunSpecRules(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "values": flattenOrgPolicyPolicyDryRunSpecRulesValues(original["values"], d, config), - "allow_all": flattenOrgPolicyPolicyDryRunSpecRulesAllowAll(original["allowAll"], d, config), - "deny_all": flattenOrgPolicyPolicyDryRunSpecRulesDenyAll(original["denyAll"], d, config), - "enforce": flattenOrgPolicyPolicyDryRunSpecRulesEnforce(original["enforce"], d, config), - "condition": flattenOrgPolicyPolicyDryRunSpecRulesCondition(original["condition"], d, config), - }) - } - return transformed -} -func flattenOrgPolicyPolicyDryRunSpecRulesValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { +func flattenOrgPolicyPolicyDryRunSpecRules(obj *orgpolicy.PolicyDryRunSpecRules) interface{} { + if obj == nil || obj.Empty() { return nil } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + transformed := map[string]interface{}{ + "allow_all": tpgdclresource.FlattenEnumBool(obj.AllowAll), + "condition": flattenOrgPolicyPolicyDryRunSpecRulesCondition(obj.Condition), + "deny_all": tpgdclresource.FlattenEnumBool(obj.DenyAll), + "enforce": tpgdclresource.FlattenEnumBool(obj.Enforce), + "values": flattenOrgPolicyPolicyDryRunSpecRulesValues(obj.Values), } - transformed := make(map[string]interface{}) - transformed["allowed_values"] = - flattenOrgPolicyPolicyDryRunSpecRulesValuesAllowedValues(original["allowedValues"], d, config) - transformed["denied_values"] = - flattenOrgPolicyPolicyDryRunSpecRulesValuesDeniedValues(original["deniedValues"], d, config) - return []interface{}{transformed} -} -func flattenOrgPolicyPolicyDryRunSpecRulesValuesAllowedValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenOrgPolicyPolicyDryRunSpecRulesValuesDeniedValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + return transformed -func flattenOrgPolicyPolicyDryRunSpecRulesAllowAll(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return "" - } - return strings.ToUpper(strconv.FormatBool(v.(bool))) } -func flattenOrgPolicyPolicyDryRunSpecRulesDenyAll(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return "" +func expandOrgPolicyPolicyDryRunSpecRulesCondition(o interface{}) *orgpolicy.PolicyDryRunSpecRulesCondition { + if o == nil { + return orgpolicy.EmptyPolicyDryRunSpecRulesCondition } - return strings.ToUpper(strconv.FormatBool(v.(bool))) -} - -func flattenOrgPolicyPolicyDryRunSpecRulesEnforce(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return "" + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return orgpolicy.EmptyPolicyDryRunSpecRulesCondition + } + obj := objArr[0].(map[string]interface{}) + return &orgpolicy.PolicyDryRunSpecRulesCondition{ + Description: dcl.String(obj["description"].(string)), + Expression: dcl.String(obj["expression"].(string)), + Location: dcl.String(obj["location"].(string)), + Title: dcl.String(obj["title"].(string)), } - return strings.ToUpper(strconv.FormatBool(v.(bool))) } -func flattenOrgPolicyPolicyDryRunSpecRulesCondition(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { +func flattenOrgPolicyPolicyDryRunSpecRulesCondition(obj *orgpolicy.PolicyDryRunSpecRulesCondition) interface{} { + if obj == nil || obj.Empty() { return nil } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + transformed := map[string]interface{}{ + "description": obj.Description, + "expression": obj.Expression, + "location": obj.Location, + "title": obj.Title, } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenOrgPolicyPolicyDryRunSpecRulesConditionExpression(original["expression"], d, config) - transformed["title"] = - flattenOrgPolicyPolicyDryRunSpecRulesConditionTitle(original["title"], d, config) - transformed["description"] = - flattenOrgPolicyPolicyDryRunSpecRulesConditionDescription(original["description"], d, config) - transformed["location"] = - flattenOrgPolicyPolicyDryRunSpecRulesConditionLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenOrgPolicyPolicyDryRunSpecRulesConditionExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicyDryRunSpecRulesConditionTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenOrgPolicyPolicyDryRunSpecRulesConditionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicyDryRunSpecRulesConditionLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicyDryRunSpecInheritFromParent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicyDryRunSpecReset(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenOrgPolicyPolicyEtag(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + return []interface{}{transformed} -func expandOrgPolicyPolicyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandOrgPolicyPolicySpec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEtag, err := expandOrgPolicyPolicySpecEtag(original["etag"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEtag); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["etag"] = transformedEtag - } - - transformedUpdateTime, err := expandOrgPolicyPolicySpecUpdateTime(original["update_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUpdateTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["updateTime"] = transformedUpdateTime +func expandOrgPolicyPolicyDryRunSpecRulesValues(o interface{}) *orgpolicy.PolicyDryRunSpecRulesValues { + if o == nil { + return orgpolicy.EmptyPolicyDryRunSpecRulesValues } - - transformedRules, err := expandOrgPolicyPolicySpecRules(original["rules"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRules); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["rules"] = transformedRules + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return orgpolicy.EmptyPolicyDryRunSpecRulesValues } - - transformedInheritFromParent, err := expandOrgPolicyPolicySpecInheritFromParent(original["inherit_from_parent"], d, config) - if err != nil { - return nil, err - } else { - transformed["inheritFromParent"] = transformedInheritFromParent + obj := objArr[0].(map[string]interface{}) + return &orgpolicy.PolicyDryRunSpecRulesValues{ + AllowedValues: tpgdclresource.ExpandStringArray(obj["allowed_values"]), + DeniedValues: tpgdclresource.ExpandStringArray(obj["denied_values"]), } - - transformedReset, err := expandOrgPolicyPolicySpecReset(original["reset"], d, config) - if err != nil { - return nil, err - } else { - transformed["reset"] = transformedReset - } - - return transformed, nil -} - -func expandOrgPolicyPolicySpecEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandOrgPolicyPolicySpecUpdateTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicySpecRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedValues, err := expandOrgPolicyPolicySpecRulesValues(original["values"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValues); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["values"] = transformedValues - } - - transformedAllowAll, err := expandOrgPolicyPolicySpecRulesAllowAll(original["allow_all"], d, config) - if err != nil { - return nil, err - } else { - transformed["allowAll"] = transformedAllowAll - } - - transformedDenyAll, err := expandOrgPolicyPolicySpecRulesDenyAll(original["deny_all"], d, config) - if err != nil { - return nil, err - } else { - transformed["denyAll"] = transformedDenyAll - } - - transformedEnforce, err := expandOrgPolicyPolicySpecRulesEnforce(original["enforce"], d, config) - if err != nil { - return nil, err - } else { - transformed["enforce"] = transformedEnforce - } - - transformedCondition, err := expandOrgPolicyPolicySpecRulesCondition(original["condition"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCondition); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["condition"] = transformedCondition - } - - req = append(req, transformed) - } - return req, nil -} - -func expandOrgPolicyPolicySpecRulesValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func flattenOrgPolicyPolicyDryRunSpecRulesValues(obj *orgpolicy.PolicyDryRunSpecRulesValues) interface{} { + if obj == nil || obj.Empty() { + return nil } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAllowedValues, err := expandOrgPolicyPolicySpecRulesValuesAllowedValues(original["allowed_values"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAllowedValues); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["allowedValues"] = transformedAllowedValues + transformed := map[string]interface{}{ + "allowed_values": obj.AllowedValues, + "denied_values": obj.DeniedValues, } - transformedDeniedValues, err := expandOrgPolicyPolicySpecRulesValuesDeniedValues(original["denied_values"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDeniedValues); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["deniedValues"] = transformedDeniedValues - } - - return transformed, nil -} - -func expandOrgPolicyPolicySpecRulesValuesAllowedValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return []interface{}{transformed} -func expandOrgPolicyPolicySpecRulesValuesDeniedValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandOrgPolicyPolicySpecRulesAllowAll(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - - b, err := strconv.ParseBool(v.(string)) - if err != nil { - return nil, nil +func expandOrgPolicyPolicySpec(o interface{}) *orgpolicy.PolicySpec { + if o == nil { + return orgpolicy.EmptyPolicySpec } - return b, nil -} - -func expandOrgPolicyPolicySpecRulesDenyAll(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return orgpolicy.EmptyPolicySpec } - - b, err := strconv.ParseBool(v.(string)) - if err != nil { - return nil, nil + obj := objArr[0].(map[string]interface{}) + return &orgpolicy.PolicySpec{ + InheritFromParent: dcl.Bool(obj["inherit_from_parent"].(bool)), + Reset: dcl.Bool(obj["reset"].(bool)), + Rules: expandOrgPolicyPolicySpecRulesArray(obj["rules"]), } - return b, nil } -func expandOrgPolicyPolicySpecRulesEnforce(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } - - b, err := strconv.ParseBool(v.(string)) - if err != nil { - return nil, nil +func flattenOrgPolicyPolicySpec(obj *orgpolicy.PolicySpec) interface{} { + if obj == nil || obj.Empty() { + return nil } - return b, nil -} - -func expandOrgPolicyPolicySpecRulesCondition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil + transformed := map[string]interface{}{ + "inherit_from_parent": obj.InheritFromParent, + "reset": obj.Reset, + "rules": flattenOrgPolicyPolicySpecRulesArray(obj.Rules), + "etag": obj.Etag, + "update_time": obj.UpdateTime, } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - transformedExpression, err := expandOrgPolicyPolicySpecRulesConditionExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } + return []interface{}{transformed} - transformedTitle, err := expandOrgPolicyPolicySpecRulesConditionTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle +} +func expandOrgPolicyPolicySpecRulesArray(o interface{}) []orgpolicy.PolicySpecRules { + if o == nil { + return make([]orgpolicy.PolicySpecRules, 0) } - transformedDescription, err := expandOrgPolicyPolicySpecRulesConditionDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription + objs := o.([]interface{}) + if len(objs) == 0 || objs[0] == nil { + return make([]orgpolicy.PolicySpecRules, 0) } - transformedLocation, err := expandOrgPolicyPolicySpecRulesConditionLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation + items := make([]orgpolicy.PolicySpecRules, 0, len(objs)) + for _, item := range objs { + i := expandOrgPolicyPolicySpecRules(item) + items = append(items, *i) } - return transformed, nil + return items } -func expandOrgPolicyPolicySpecRulesConditionExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicySpecRulesConditionTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicySpecRulesConditionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicySpecRulesConditionLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicySpecInheritFromParent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicySpecReset(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEtag, err := expandOrgPolicyPolicyDryRunSpecEtag(original["etag"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEtag); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["etag"] = transformedEtag - } - - transformedUpdateTime, err := expandOrgPolicyPolicyDryRunSpecUpdateTime(original["update_time"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUpdateTime); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["updateTime"] = transformedUpdateTime +func expandOrgPolicyPolicySpecRules(o interface{}) *orgpolicy.PolicySpecRules { + if o == nil { + return orgpolicy.EmptyPolicySpecRules } - transformedRules, err := expandOrgPolicyPolicyDryRunSpecRules(original["rules"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRules); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["rules"] = transformedRules + obj := o.(map[string]interface{}) + return &orgpolicy.PolicySpecRules{ + AllowAll: tpgdclresource.ExpandEnumBool(obj["allow_all"].(string)), + Condition: expandOrgPolicyPolicySpecRulesCondition(obj["condition"]), + DenyAll: tpgdclresource.ExpandEnumBool(obj["deny_all"].(string)), + Enforce: tpgdclresource.ExpandEnumBool(obj["enforce"].(string)), + Values: expandOrgPolicyPolicySpecRulesValues(obj["values"]), } +} - transformedInheritFromParent, err := expandOrgPolicyPolicyDryRunSpecInheritFromParent(original["inherit_from_parent"], d, config) - if err != nil { - return nil, err - } else { - transformed["inheritFromParent"] = transformedInheritFromParent +func flattenOrgPolicyPolicySpecRulesArray(objs []orgpolicy.PolicySpecRules) []interface{} { + if objs == nil { + return nil } - transformedReset, err := expandOrgPolicyPolicyDryRunSpecReset(original["reset"], d, config) - if err != nil { - return nil, err - } else { - transformed["reset"] = transformedReset + items := []interface{}{} + for _, item := range objs { + i := flattenOrgPolicyPolicySpecRules(&item) + items = append(items, i) } - return transformed, nil + return items } -func expandOrgPolicyPolicyDryRunSpecEtag(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecUpdateTime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecRules(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedValues, err := expandOrgPolicyPolicyDryRunSpecRulesValues(original["values"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValues); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["values"] = transformedValues - } - - transformedAllowAll, err := expandOrgPolicyPolicyDryRunSpecRulesAllowAll(original["allow_all"], d, config) - if err != nil { - return nil, err - } else { - transformed["allowAll"] = transformedAllowAll - } - - transformedDenyAll, err := expandOrgPolicyPolicyDryRunSpecRulesDenyAll(original["deny_all"], d, config) - if err != nil { - return nil, err - } else { - transformed["denyAll"] = transformedDenyAll - } - - transformedEnforce, err := expandOrgPolicyPolicyDryRunSpecRulesEnforce(original["enforce"], d, config) - if err != nil { - return nil, err - } else { - transformed["enforce"] = transformedEnforce - } - - transformedCondition, err := expandOrgPolicyPolicyDryRunSpecRulesCondition(original["condition"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCondition); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["condition"] = transformedCondition - } - - req = append(req, transformed) - } - return req, nil -} - -func expandOrgPolicyPolicyDryRunSpecRulesValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAllowedValues, err := expandOrgPolicyPolicyDryRunSpecRulesValuesAllowedValues(original["allowed_values"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAllowedValues); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["allowedValues"] = transformedAllowedValues +func flattenOrgPolicyPolicySpecRules(obj *orgpolicy.PolicySpecRules) interface{} { + if obj == nil || obj.Empty() { + return nil } - - transformedDeniedValues, err := expandOrgPolicyPolicyDryRunSpecRulesValuesDeniedValues(original["denied_values"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDeniedValues); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["deniedValues"] = transformedDeniedValues + transformed := map[string]interface{}{ + "allow_all": tpgdclresource.FlattenEnumBool(obj.AllowAll), + "condition": flattenOrgPolicyPolicySpecRulesCondition(obj.Condition), + "deny_all": tpgdclresource.FlattenEnumBool(obj.DenyAll), + "enforce": tpgdclresource.FlattenEnumBool(obj.Enforce), + "values": flattenOrgPolicyPolicySpecRulesValues(obj.Values), } - return transformed, nil -} - -func expandOrgPolicyPolicyDryRunSpecRulesValuesAllowedValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return transformed -func expandOrgPolicyPolicyDryRunSpecRulesValuesDeniedValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandOrgPolicyPolicyDryRunSpecRulesAllowAll(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil +func expandOrgPolicyPolicySpecRulesCondition(o interface{}) *orgpolicy.PolicySpecRulesCondition { + if o == nil { + return orgpolicy.EmptyPolicySpecRulesCondition } - - b, err := strconv.ParseBool(v.(string)) - if err != nil { - return nil, nil + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return orgpolicy.EmptyPolicySpecRulesCondition + } + obj := objArr[0].(map[string]interface{}) + return &orgpolicy.PolicySpecRulesCondition{ + Description: dcl.String(obj["description"].(string)), + Expression: dcl.String(obj["expression"].(string)), + Location: dcl.String(obj["location"].(string)), + Title: dcl.String(obj["title"].(string)), } - return b, nil } -func expandOrgPolicyPolicyDryRunSpecRulesDenyAll(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil +func flattenOrgPolicyPolicySpecRulesCondition(obj *orgpolicy.PolicySpecRulesCondition) interface{} { + if obj == nil || obj.Empty() { + return nil } - - b, err := strconv.ParseBool(v.(string)) - if err != nil { - return nil, nil + transformed := map[string]interface{}{ + "description": obj.Description, + "expression": obj.Expression, + "location": obj.Location, + "title": obj.Title, } - return b, nil -} -func expandOrgPolicyPolicyDryRunSpecRulesEnforce(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - if v == nil { - return nil, nil - } + return []interface{}{transformed} - b, err := strconv.ParseBool(v.(string)) - if err != nil { - return nil, nil - } - return b, nil } -func expandOrgPolicyPolicyDryRunSpecRulesCondition(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func expandOrgPolicyPolicySpecRulesValues(o interface{}) *orgpolicy.PolicySpecRulesValues { + if o == nil { + return orgpolicy.EmptyPolicySpecRulesValues } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandOrgPolicyPolicyDryRunSpecRulesConditionExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return orgpolicy.EmptyPolicySpecRulesValues } - - transformedTitle, err := expandOrgPolicyPolicyDryRunSpecRulesConditionTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle + obj := objArr[0].(map[string]interface{}) + return &orgpolicy.PolicySpecRulesValues{ + AllowedValues: tpgdclresource.ExpandStringArray(obj["allowed_values"]), + DeniedValues: tpgdclresource.ExpandStringArray(obj["denied_values"]), } +} - transformedDescription, err := expandOrgPolicyPolicyDryRunSpecRulesConditionDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription +func flattenOrgPolicyPolicySpecRulesValues(obj *orgpolicy.PolicySpecRulesValues) interface{} { + if obj == nil || obj.Empty() { + return nil } - - transformedLocation, err := expandOrgPolicyPolicyDryRunSpecRulesConditionLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation + transformed := map[string]interface{}{ + "allowed_values": obj.AllowedValues, + "denied_values": obj.DeniedValues, } - return transformed, nil -} - -func expandOrgPolicyPolicyDryRunSpecRulesConditionExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecRulesConditionTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecRulesConditionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecRulesConditionLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecInheritFromParent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandOrgPolicyPolicyDryRunSpecReset(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return []interface{}{transformed} -func resourceOrgPolicyPolicyEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - name := d.Get("name").(string) - d.Set("name", tpgresource.GetResourceNameFromSelfLink(name)) - return obj, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy_sweeper.go deleted file mode 100644 index 82768ab68a5..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/orgpolicy/resource_org_policy_policy_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package orgpolicy - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("OrgPolicyPolicy", testSweepOrgPolicyPolicy) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepOrgPolicyPolicy(region string) error { - resourceName := "OrgPolicyPolicy" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://orgpolicy.googleapis.com/v2/{{parent}}/policies", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["policies"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://orgpolicy.googleapis.com/v2/{{parent}}/policies/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/osconfig/resource_os_config_patch_deployment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/osconfig/resource_os_config_patch_deployment.go index 6bb919afe21..ccc75575410 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/osconfig/resource_os_config_patch_deployment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/osconfig/resource_os_config_patch_deployment.go @@ -20,7 +20,6 @@ package osconfig import ( "fmt" "log" - "net/http" "reflect" "time" @@ -1038,7 +1037,6 @@ func resourceOSConfigPatchDeploymentCreate(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -1047,7 +1045,6 @@ func resourceOSConfigPatchDeploymentCreate(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PatchDeployment: %s", err) @@ -1111,14 +1108,12 @@ func resourceOSConfigPatchDeploymentRead(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("OSConfigPatchDeployment %q", d.Id())) @@ -1204,8 +1199,6 @@ func resourceOSConfigPatchDeploymentDelete(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PatchDeployment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1215,7 +1208,6 @@ func resourceOSConfigPatchDeploymentDelete(d *schema.ResourceData, meta interfac UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PatchDeployment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/oslogin/resource_os_login_ssh_public_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/oslogin/resource_os_login_ssh_public_key.go index 07477dabd62..f2ca1e02cc7 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/oslogin/resource_os_login_ssh_public_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/oslogin/resource_os_login_ssh_public_key.go @@ -20,7 +20,6 @@ package oslogin import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -116,7 +115,6 @@ func resourceOSLoginSSHPublicKeyCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) // Don't use `GetProject()` because we only want to set the project in the URL // if the user set it explicitly on the resource. if p, ok := d.GetOk("project"); ok { @@ -133,7 +131,6 @@ func resourceOSLoginSSHPublicKeyCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SSHPublicKey: %s", err) @@ -193,14 +190,12 @@ func resourceOSLoginSSHPublicKeyRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("OSLoginSSHPublicKey %q", d.Id())) @@ -242,7 +237,6 @@ func resourceOSLoginSSHPublicKeyUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating SSHPublicKey %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("expiration_time_usec") { @@ -270,7 +264,6 @@ func resourceOSLoginSSHPublicKeyUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -305,8 +298,6 @@ func resourceOSLoginSSHPublicKeyDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting SSHPublicKey %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -316,7 +307,6 @@ func resourceOSLoginSSHPublicKeyDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SSHPublicKey") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/privateca_ca_utils.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/privateca_ca_utils.go index 4c031c081c3..2c15662b6a8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/privateca_ca_utils.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/privateca_ca_utils.go @@ -230,14 +230,12 @@ func activateSubCAWithFirstPartyIssuer(config *transport_tpg.Config, d *schema.R return fmt.Errorf("Error creating Certificate: %s", err) } signedCACert := res["pemCertificate"] - signerCertChain := res["pemCertificateChain"] // 4. activate sub CA with the signed CA cert. activateObj := make(map[string]interface{}) activateObj["pemCaCertificate"] = signedCACert activateObj["subordinateConfig"] = make(map[string]interface{}) - activateObj["subordinateConfig"].(map[string]interface{})["pemIssuerChain"] = make(map[string]interface{}) - activateObj["subordinateConfig"].(map[string]interface{})["pemIssuerChain"].(map[string]interface{})["pemCertificates"] = signerCertChain + activateObj["subordinateConfig"].(map[string]interface{})["certificateAuthority"] = issuer activateUrl, err := tpgresource.ReplaceVars(d, config, "{{PrivatecaBasePath}}projects/{{project}}/locations/{{location}}/caPools/{{pool}}/certificateAuthorities/{{certificate_authority_id}}:activate") if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_ca_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_ca_pool.go index 71676c4cad9..4411dd0da1c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_ca_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_ca_pool.go @@ -20,7 +20,6 @@ package privateca import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -674,7 +673,6 @@ func resourcePrivatecaCaPoolCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -683,7 +681,6 @@ func resourcePrivatecaCaPoolCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CaPool: %s", err) @@ -746,14 +743,12 @@ func resourcePrivatecaCaPoolRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PrivatecaCaPool %q", d.Id())) @@ -826,7 +821,6 @@ func resourcePrivatecaCaPoolUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating CaPool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("issuance_policy") { @@ -862,7 +856,6 @@ func resourcePrivatecaCaPoolUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -910,8 +903,6 @@ func resourcePrivatecaCaPoolDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting CaPool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -921,7 +912,6 @@ func resourcePrivatecaCaPoolDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CaPool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate.go index e34f20d1626..e29b24fa430 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate.go @@ -20,7 +20,6 @@ package privateca import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -625,23 +624,6 @@ leading period (like '.example.com')`, }, }, }, - "subject_key_id": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `When specified this provides a custom SKI to be used in the certificate. This should only be used to maintain a SKI of an existing CA originally created outside CA service, which was not generated using method (1) described in RFC 5280 section 4.2.1.2..`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The value of the KeyId in lowercase hexidecimal.`, - }, - }, - }, - }, }, }, ExactlyOneOf: []string{"pem_csr", "config"}, @@ -1358,7 +1340,6 @@ func resourcePrivatecaCertificateCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) // Only include linked certificate authority if the user specified it if p, ok := d.GetOk("certificate_authority"); ok { url, err = transport_tpg.AddQueryParams(url, map[string]string{"issuingCertificateAuthorityId": p.(string)}) @@ -1374,7 +1355,6 @@ func resourcePrivatecaCertificateCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Certificate: %s", err) @@ -1417,14 +1397,12 @@ func resourcePrivatecaCertificateRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PrivatecaCertificate %q", d.Id())) @@ -1509,7 +1487,6 @@ func resourcePrivatecaCertificateUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Certificate %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("effective_labels") { @@ -1537,7 +1514,6 @@ func resourcePrivatecaCertificateUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1578,8 +1554,6 @@ func resourcePrivatecaCertificateDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Certificate %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1589,7 +1563,6 @@ func resourcePrivatecaCertificateDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Certificate") @@ -2337,8 +2310,6 @@ func flattenPrivatecaCertificateConfig(v interface{}, d *schema.ResourceData, co flattenPrivatecaCertificateConfigX509Config(original["x509Config"], d, config) transformed["subject_config"] = flattenPrivatecaCertificateConfigSubjectConfig(original["subjectConfig"], d, config) - transformed["subject_key_id"] = - flattenPrivatecaCertificateConfigSubjectKeyId(original["subjectKeyId"], d, config) transformed["public_key"] = flattenPrivatecaCertificateConfigPublicKey(original["publicKey"], d, config) return []interface{}{transformed} @@ -2473,23 +2444,6 @@ func flattenPrivatecaCertificateConfigSubjectConfigSubjectAltNameIpAddresses(v i return v } -func flattenPrivatecaCertificateConfigSubjectKeyId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["key_id"] = - flattenPrivatecaCertificateConfigSubjectKeyIdKeyId(original["keyId"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateConfigSubjectKeyIdKeyId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenPrivatecaCertificateConfigPublicKey(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -2567,13 +2521,6 @@ func expandPrivatecaCertificateConfig(v interface{}, d tpgresource.TerraformReso transformed["subjectConfig"] = transformedSubjectConfig } - transformedSubjectKeyId, err := expandPrivatecaCertificateConfigSubjectKeyId(original["subject_key_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSubjectKeyId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["subjectKeyId"] = transformedSubjectKeyId - } - transformedPublicKey, err := expandPrivatecaCertificateConfigPublicKey(original["public_key"], d, config) if err != nil { return nil, err @@ -2819,29 +2766,6 @@ func expandPrivatecaCertificateConfigSubjectConfigSubjectAltNameIpAddresses(v in return v, nil } -func expandPrivatecaCertificateConfigSubjectKeyId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKeyId, err := expandPrivatecaCertificateConfigSubjectKeyIdKeyId(original["key_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKeyId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["keyId"] = transformedKeyId - } - - return transformed, nil -} - -func expandPrivatecaCertificateConfigSubjectKeyIdKeyId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandPrivatecaCertificateConfigPublicKey(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_authority.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_authority.go index d91db1e0aff..00f4b52d83f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_authority.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_authority.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -591,23 +590,6 @@ leading period (like '.example.com')`, }, }, }, - "subject_key_id": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `When specified this provides a custom SKI to be used in the certificate. This should only be used to maintain a SKI of an existing CA originally created outside CA service, which was not generated using method (1) described in RFC 5280 section 4.2.1.2..`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The value of the KeyId in lowercase hexidecimal.`, - }, - }, - }, - }, }, }, }, @@ -727,7 +709,6 @@ and usability purposes only. The resource name is in the format }, "pem_issuer_chain": { Type: schema.TypeList, - Computed: true, Optional: true, Description: `Contains the PEM certificate chain for the issuers of this CertificateAuthority, but not pem certificate for this CA itself.`, @@ -839,10 +820,8 @@ fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045 Type: schema.TypeBool, Optional: true, Default: true, - Description: `Whether Terraform will be prevented from destroying the CertificateAuthority. -When the field is set to true or unset in Terraform state, a 'terraform apply' -or 'terraform destroy' that would delete the CertificateAuthority will fail. -When the field is set to false, deleting the CertificateAuthority is allowed.`, + Description: `Whether or not to allow Terraform to destroy the CertificateAuthority. Unless this field is set to false +in Terraform state, a 'terraform destroy' or 'terraform apply' that would delete the instance will fail.`, }, "desired_state": { Type: schema.TypeString, @@ -930,7 +909,6 @@ func resourcePrivatecaCertificateAuthorityCreate(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) // Drop `subordinateConfig` as it can not be set during CA creation. // It can be used to activate CA during post_create or pre_update. delete(obj, "subordinateConfig") @@ -942,7 +920,6 @@ func resourcePrivatecaCertificateAuthorityCreate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating CertificateAuthority: %s", err) @@ -1041,14 +1018,12 @@ func resourcePrivatecaCertificateAuthorityRead(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PrivatecaCertificateAuthority %q", d.Id())) @@ -1160,7 +1135,6 @@ func resourcePrivatecaCertificateAuthorityUpdate(d *schema.ResourceData, meta in } log.Printf("[DEBUG] Updating CertificateAuthority %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("subordinate_config") { @@ -1235,7 +1209,6 @@ func resourcePrivatecaCertificateAuthorityUpdate(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1283,7 +1256,6 @@ func resourcePrivatecaCertificateAuthorityDelete(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) if d.Get("deletion_protection").(bool) { return fmt.Errorf("cannot destroy CertificateAuthority without setting deletion_protection=false and running `terraform apply`") } @@ -1325,7 +1297,6 @@ func resourcePrivatecaCertificateAuthorityDelete(d *schema.ResourceData, meta in UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "CertificateAuthority") @@ -1388,30 +1359,12 @@ func flattenPrivatecaCertificateAuthorityConfig(v interface{}, d *schema.Resourc return nil } transformed := make(map[string]interface{}) - transformed["subject_key_id"] = - flattenPrivatecaCertificateAuthorityConfigSubjectKeyId(original["subjectKeyId"], d, config) transformed["x509_config"] = flattenPrivatecaCertificateAuthorityConfigX509Config(original["x509Config"], d, config) transformed["subject_config"] = flattenPrivatecaCertificateAuthorityConfigSubjectConfig(original["subjectConfig"], d, config) return []interface{}{transformed} } -func flattenPrivatecaCertificateAuthorityConfigSubjectKeyId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["key_id"] = - flattenPrivatecaCertificateAuthorityConfigSubjectKeyIdKeyId(original["keyId"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateAuthorityConfigSubjectKeyIdKeyId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} func flattenPrivatecaCertificateAuthorityConfigX509Config(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { @@ -1585,7 +1538,7 @@ func flattenPrivatecaCertificateAuthoritySubordinateConfig(v interface{}, d *sch return []interface{}{transformed} } func flattenPrivatecaCertificateAuthoritySubordinateConfigCertificateAuthority(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return d.Get("subordinate_config.0.certificate_authority") + return v } func flattenPrivatecaCertificateAuthoritySubordinateConfigPemIssuerChain(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1695,13 +1648,6 @@ func expandPrivatecaCertificateAuthorityConfig(v interface{}, d tpgresource.Terr original := raw.(map[string]interface{}) transformed := make(map[string]interface{}) - transformedSubjectKeyId, err := expandPrivatecaCertificateAuthorityConfigSubjectKeyId(original["subject_key_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSubjectKeyId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["subjectKeyId"] = transformedSubjectKeyId - } - transformedX509Config, err := expandPrivatecaCertificateAuthorityConfigX509Config(original["x509_config"], d, config) if err != nil { return nil, err @@ -1719,29 +1665,6 @@ func expandPrivatecaCertificateAuthorityConfig(v interface{}, d tpgresource.Terr return transformed, nil } -func expandPrivatecaCertificateAuthorityConfigSubjectKeyId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKeyId, err := expandPrivatecaCertificateAuthorityConfigSubjectKeyIdKeyId(original["key_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKeyId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["keyId"] = transformedKeyId - } - - return transformed, nil -} - -func expandPrivatecaCertificateAuthorityConfigSubjectKeyIdKeyId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandPrivatecaCertificateAuthorityConfigX509Config(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { if v == nil { return v, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template.go index 2a2f57c7029..da61139f9b9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template.go @@ -3,31 +3,34 @@ // ---------------------------------------------------------------------------- // -// *** AUTO GENERATED CODE *** Type: MMv1 *** +// *** AUTO GENERATED CODE *** Type: DCL *** // // ---------------------------------------------------------------------------- // -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. +// This file is managed by Magic Modules (https://github.com/GoogleCloudPlatform/magic-modules) +// and is based on the DCL (https://github.com/GoogleCloudPlatform/declarative-resource-client-library). +// Changes will need to be made to the DCL or Magic Modules instead of here. // -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. +// We are not currently able to accept contributions to this file. If changes +// are required, please file an issue at https://github.com/hashicorp/terraform-provider-google/issues/new/choose // // ---------------------------------------------------------------------------- package privateca import ( + "context" "fmt" "log" - "net/http" - "reflect" - "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + dcl "github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl" + privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca" + + "github.com/hashicorp/terraform-provider-google/google/tpgdclresource" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" ) @@ -48,10 +51,9 @@ func ResourcePrivatecaCertificateTemplate() *schema.Resource { Update: schema.DefaultTimeout(20 * time.Minute), Delete: schema.DefaultTimeout(20 * time.Minute), }, - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, tpgresource.DefaultProviderProject, + tpgresource.SetLabelsDiff, ), Schema: map[string]*schema.Schema{ @@ -59,1798 +61,1239 @@ func ResourcePrivatecaCertificateTemplate() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: `The location for the resource`, + Description: "The location for the resource", }, + "name": { Type: schema.TypeString, Required: true, ForceNew: true, - Description: `The resource name for this CertificateTemplate in the format 'projects/*/locations/*/certificateTemplates/*'.`, + Description: "The resource name for this CertificateTemplate in the format `projects/*/locations/*/certificateTemplates/*`.", }, + "description": { Type: schema.TypeString, Optional: true, - Description: `Optional. A human-readable description of scenarios this template is intended for.`, + Description: "Optional. A human-readable description of scenarios this template is intended for.", + }, + + "effective_labels": { + Type: schema.TypeMap, + Computed: true, + Description: "All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.", }, + "identity_constraints": { Type: schema.TypeList, Optional: true, - Description: `Optional. Describes constraints on identities that may be appear in Certificates issued using this template. If this is omitted, then this template will not add restrictions on a certificate's identity.`, + Description: "Optional. Describes constraints on identities that may be appear in Certificates issued using this template. If this is omitted, then this template will not add restrictions on a certificate's identity.", MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "allow_subject_alt_names_passthrough": { - Type: schema.TypeBool, - Required: true, - Description: `Required. If this is true, the SubjectAltNames extension may be copied from a certificate request into the signed certificate. Otherwise, the requested SubjectAltNames will be discarded.`, - }, - "allow_subject_passthrough": { - Type: schema.TypeBool, - Required: true, - Description: `Required. If this is true, the Subject field may be copied from a certificate request into the signed certificate. Otherwise, the requested Subject will be discarded.`, - }, - "cel_expression": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. A CEL expression that may be used to validate the resolved X.509 Subject and/or Subject Alternative Name before a certificate is signed. To see the full allowed syntax and some examples, see https://cloud.google.com/certificate-authority-service/docs/using-cel`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.`, - }, - "expression": { - Type: schema.TypeString, - Optional: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - }, - }, + Elem: PrivatecaCertificateTemplateIdentityConstraintsSchema(), }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `Optional. Labels with user-defined metadata. -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "maximum_lifetime": { - Type: schema.TypeString, - Optional: true, - Description: `Optional. The maximum lifetime allowed for all issued certificates that use this template. If the issuing CaPool's IssuancePolicy specifies a maximum lifetime the minimum of the two durations will be the maximum lifetime for issued. Note that if the issuing CertificateAuthority expires before a Certificate's requested maximum_lifetime, the effective lifetime will be explicitly truncated to match it.`, - }, "passthrough_extensions": { Type: schema.TypeList, Optional: true, - Description: `Optional. Describes the set of X.509 extensions that may appear in a Certificate issued using this CertificateTemplate. If a certificate request sets extensions that don't appear in the passthrough_extensions, those extensions will be dropped. If the issuing CaPool's IssuancePolicy defines baseline_values that don't appear here, the certificate issuance request will fail. If this is omitted, then this template will not add restrictions on a certificate's X.509 extensions. These constraints do not apply to X.509 extensions set in this CertificateTemplate's predefined_values.`, + Description: "Optional. Describes the set of X.509 extensions that may appear in a Certificate issued using this CertificateTemplate. If a certificate request sets extensions that don't appear in the passthrough_extensions, those extensions will be dropped. If the issuing CaPool's IssuancePolicy defines baseline_values that don't appear here, the certificate issuance request will fail. If this is omitted, then this template will not add restrictions on a certificate's X.509 extensions. These constraints do not apply to X.509 extensions set in this CertificateTemplate's predefined_values.", MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "additional_extensions": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. A set of ObjectIds identifying custom X.509 extensions. Will be combined with known_extensions to determine the full set of X.509 extensions.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "object_id_path": { - Type: schema.TypeList, - Required: true, - Description: `Required. The parts of an OID path. The most significant parts of the path come first.`, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, - }, - }, - }, - "known_extensions": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. A set of named X.509 extensions. Will be combined with additional_extensions to determine the full set of X.509 extensions.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, + Elem: PrivatecaCertificateTemplatePassthroughExtensionsSchema(), }, + "predefined_values": { Type: schema.TypeList, Optional: true, - Description: `Optional. A set of X.509 values that will be applied to all issued certificates that use this template. If the certificate request includes conflicting values for the same properties, they will be overwritten by the values defined here. If the issuing CaPool's IssuancePolicy defines conflicting baseline_values for the same properties, the certificate issuance request will fail.`, + Description: "Optional. A set of X.509 values that will be applied to all issued certificates that use this template. If the certificate request includes conflicting values for the same properties, they will be overwritten by the values defined here. If the issuing CaPool's IssuancePolicy defines conflicting baseline_values for the same properties, the certificate issuance request will fail.", MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "additional_extensions": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Describes custom X.509 extensions.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "object_id": { - Type: schema.TypeList, - Required: true, - Description: `Required. The OID for this X.509 extension.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "object_id_path": { - Type: schema.TypeList, - Required: true, - Description: `Required. The parts of an OID path. The most significant parts of the path come first.`, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, - }, - }, - }, - "value": { - Type: schema.TypeString, - Required: true, - Description: `Required. The value of this X.509 extension.`, - }, - "critical": { - Type: schema.TypeBool, - Optional: true, - Description: `Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).`, - }, - }, - }, - }, - "aia_ocsp_servers": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the "Authority Information Access" extension in the certificate.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "ca_options": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Describes options in this X509Parameters that are relevant in a CA certificate.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "is_ca": { - Type: schema.TypeBool, - Optional: true, - Description: `Optional. Refers to the "CA" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.`, - }, - "max_issuer_path_length": { - Type: schema.TypeInt, - Optional: true, - Description: `Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.`, - }, - }, - }, - }, - "key_usage": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Indicates the intended use for keys that correspond to a certificate.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "base_key_usage": { - Type: schema.TypeList, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrUnsetBlockDiffSuppress, - Description: `Describes high-level ways in which a key may be used.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cert_sign": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used to sign certificates.`, - }, - "content_commitment": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used for cryptographic commitments. Note that this may also be referred to as "non-repudiation".`, - }, - "crl_sign": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used sign certificate revocation lists.`, - }, - "data_encipherment": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used to encipher data.`, - }, - "decipher_only": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used to decipher only.`, - }, - "digital_signature": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used for digital signatures.`, - }, - "encipher_only": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used to encipher only.`, - }, - "key_agreement": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used in a key agreement protocol.`, - }, - "key_encipherment": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `The key may be used to encipher other keys.`, - }, - }, - }, - }, - "extended_key_usage": { - Type: schema.TypeList, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrUnsetBlockDiffSuppress, - Description: `Detailed scenarios in which a key may be used.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "client_auth": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as "TLS WWW client authentication", though regularly used for non-WWW TLS.`, - }, - "code_signing": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as "Signing of downloadable executable code client authentication".`, - }, - "email_protection": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as "Email protection".`, - }, - "ocsp_signing": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as "Signing OCSP responses".`, - }, - "server_auth": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as "TLS WWW server authentication", though regularly used for non-WWW TLS.`, - }, - "time_stamping": { - Type: schema.TypeBool, - Optional: true, - DiffSuppressFunc: tpgresource.EmptyOrFalseSuppressBoolean, - Description: `Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as "Binding the hash of an object to a time".`, - }, - }, - }, - }, - "unknown_extended_key_usages": { - Type: schema.TypeList, - Optional: true, - Description: `Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "object_id_path": { - Type: schema.TypeList, - Required: true, - Description: `Required. The parts of an OID path. The most significant parts of the path come first.`, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, - }, - }, - }, - }, - }, - }, - "policy_ids": { - Type: schema.TypeList, - Optional: true, - Description: `Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "object_id_path": { - Type: schema.TypeList, - Required: true, - Description: `Required. The parts of an OID path. The most significant parts of the path come first.`, - Elem: &schema.Schema{ - Type: schema.TypeInt, - }, - }, - }, - }, - }, - }, - }, + Elem: PrivatecaCertificateTemplatePredefinedValuesSchema(), + }, + + "project": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, + Description: "The project for the resource", }, + "create_time": { Type: schema.TypeString, Computed: true, - Description: `Output only. The time at which this CertificateTemplate was created.`, + Description: "Output only. The time at which this CertificateTemplate was created.", }, - "effective_labels": { + + "labels": { Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, + Optional: true, + Description: "Optional. Labels with user-defined metadata.\n\n**Note**: This field is non-authoritative, and will only manage the labels present in your configuration.\nPlease refer to the field `effective_labels` for all of the labels present on the resource.", Elem: &schema.Schema{Type: schema.TypeString}, }, + "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, + Type: schema.TypeMap, + Computed: true, + Description: "The combination of labels configured directly on the resource and default labels configured on the provider.", }, + "update_time": { Type: schema.TypeString, Computed: true, - Description: `Output only. The time at which this CertificateTemplate was updated.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, + Description: "Output only. The time at which this CertificateTemplate was updated.", }, }, - UseJSONNumber: true, } } -func resourcePrivatecaCertificateTemplateCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } +func PrivatecaCertificateTemplateIdentityConstraintsSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "allow_subject_alt_names_passthrough": { + Type: schema.TypeBool, + Required: true, + Description: "Required. If this is true, the SubjectAltNames extension may be copied from a certificate request into the signed certificate. Otherwise, the requested SubjectAltNames will be discarded.", + }, - obj := make(map[string]interface{}) - predefinedValuesProp, err := expandPrivatecaCertificateTemplatePredefinedValues(d.Get("predefined_values"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("predefined_values"); !tpgresource.IsEmptyValue(reflect.ValueOf(predefinedValuesProp)) && (ok || !reflect.DeepEqual(v, predefinedValuesProp)) { - obj["predefinedValues"] = predefinedValuesProp - } - identityConstraintsProp, err := expandPrivatecaCertificateTemplateIdentityConstraints(d.Get("identity_constraints"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("identity_constraints"); !tpgresource.IsEmptyValue(reflect.ValueOf(identityConstraintsProp)) && (ok || !reflect.DeepEqual(v, identityConstraintsProp)) { - obj["identityConstraints"] = identityConstraintsProp - } - passthroughExtensionsProp, err := expandPrivatecaCertificateTemplatePassthroughExtensions(d.Get("passthrough_extensions"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("passthrough_extensions"); !tpgresource.IsEmptyValue(reflect.ValueOf(passthroughExtensionsProp)) && (ok || !reflect.DeepEqual(v, passthroughExtensionsProp)) { - obj["passthroughExtensions"] = passthroughExtensionsProp - } - maximumLifetimeProp, err := expandPrivatecaCertificateTemplateMaximumLifetime(d.Get("maximum_lifetime"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("maximum_lifetime"); !tpgresource.IsEmptyValue(reflect.ValueOf(maximumLifetimeProp)) && (ok || !reflect.DeepEqual(v, maximumLifetimeProp)) { - obj["maximumLifetime"] = maximumLifetimeProp - } - descriptionProp, err := expandPrivatecaCertificateTemplateDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - labelsProp, err := expandPrivatecaCertificateTemplateEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } + "allow_subject_passthrough": { + Type: schema.TypeBool, + Required: true, + Description: "Required. If this is true, the Subject field may be copied from a certificate request into the signed certificate. Otherwise, the requested Subject will be discarded.", + }, - url, err := tpgresource.ReplaceVarsForId(d, config, "{{PrivatecaBasePath}}projects/{{project}}/locations/{{location}}/certificateTemplates?certificateTemplateId={{name}}") - if err != nil { - return err + "cel_expression": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. A CEL expression that may be used to validate the resolved X.509 Subject and/or Subject Alternative Name before a certificate is signed. To see the full allowed syntax and some examples, see https://cloud.google.com/certificate-authority-service/docs/using-cel", + MaxItems: 1, + Elem: PrivatecaCertificateTemplateIdentityConstraintsCelExpressionSchema(), + }, + }, } +} - log.Printf("[DEBUG] Creating new CertificateTemplate: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for CertificateTemplate: %s", err) - } - billingProject = strings.TrimPrefix(project, "projects/") +func PrivatecaCertificateTemplateIdentityConstraintsCelExpressionSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "description": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.", + }, - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } + "expression": { + Type: schema.TypeString, + Optional: true, + Description: "Textual representation of an expression in Common Expression Language syntax.", + }, - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating CertificateTemplate: %s", err) - } + "location": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.", + }, - // Store the ID now - id, err := tpgresource.ReplaceVarsForId(d, config, "projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) + "title": { + Type: schema.TypeString, + Optional: true, + Description: "Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.", + }, + }, } - d.SetId(id) +} - // Use the resource in the operation response to populate - // identity fields and d.Id() before read - var opRes map[string]interface{} - err = PrivatecaOperationWaitTimeWithResponse( - config, res, &opRes, tpgresource.GetResourceNameFromSelfLink(project), "Creating CertificateTemplate", userAgent, - d.Timeout(schema.TimeoutCreate)) - if err != nil { - // The resource didn't actually create - d.SetId("") +func PrivatecaCertificateTemplatePassthroughExtensionsSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "additional_extensions": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. A set of ObjectIds identifying custom X.509 extensions. Will be combined with known_extensions to determine the full set of X.509 extensions.", + Elem: PrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsSchema(), + }, - return fmt.Errorf("Error waiting to create CertificateTemplate: %s", err) + "known_extensions": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. A set of named X.509 extensions. Will be combined with additional_extensions to determine the full set of X.509 extensions.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + }, } +} - // This may have caused the ID to update - update it if so. - id, err = tpgresource.ReplaceVarsForId(d, config, "projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) +func PrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "object_id_path": { + Type: schema.TypeList, + Required: true, + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating CertificateTemplate %q: %#v", d.Id(), res) - - return resourcePrivatecaCertificateTemplateRead(d, meta) } -func resourcePrivatecaCertificateTemplateRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } +func PrivatecaCertificateTemplatePredefinedValuesSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "additional_extensions": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. Describes custom X.509 extensions.", + Elem: PrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsSchema(), + }, - url, err := tpgresource.ReplaceVarsForId(d, config, "{{PrivatecaBasePath}}projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") - if err != nil { - return err - } + "aia_ocsp_servers": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. Describes Online Certificate Status Protocol (OCSP) endpoint addresses that appear in the \"Authority Information Access\" extension in the certificate.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, - billingProject := "" + "ca_options": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. Describes options in this X509Parameters that are relevant in a CA certificate.", + MaxItems: 1, + Elem: PrivatecaCertificateTemplatePredefinedValuesCaOptionsSchema(), + }, - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for CertificateTemplate: %s", err) - } - billingProject = strings.TrimPrefix(project, "projects/") + "key_usage": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. Indicates the intended use for keys that correspond to a certificate.", + MaxItems: 1, + Elem: PrivatecaCertificateTemplatePredefinedValuesKeyUsageSchema(), + }, - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp + "policy_ids": { + Type: schema.TypeList, + Optional: true, + Description: "Optional. Describes the X.509 certificate policy object identifiers, per https://tools.ietf.org/html/rfc5280#section-4.2.1.4.", + Elem: PrivatecaCertificateTemplatePredefinedValuesPolicyIdsSchema(), + }, + }, } +} - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PrivatecaCertificateTemplate %q", d.Id())) - } +func PrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "object_id": { + Type: schema.TypeList, + Required: true, + Description: "Required. The OID for this X.509 extension.", + MaxItems: 1, + Elem: PrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSchema(), + }, - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } + "value": { + Type: schema.TypeString, + Required: true, + Description: "Required. The value of this X.509 extension.", + }, - if err := d.Set("predefined_values", flattenPrivatecaCertificateTemplatePredefinedValues(res["predefinedValues"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("identity_constraints", flattenPrivatecaCertificateTemplateIdentityConstraints(res["identityConstraints"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("passthrough_extensions", flattenPrivatecaCertificateTemplatePassthroughExtensions(res["passthroughExtensions"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("maximum_lifetime", flattenPrivatecaCertificateTemplateMaximumLifetime(res["maximumLifetime"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("description", flattenPrivatecaCertificateTemplateDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("create_time", flattenPrivatecaCertificateTemplateCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("update_time", flattenPrivatecaCertificateTemplateUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("labels", flattenPrivatecaCertificateTemplateLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("terraform_labels", flattenPrivatecaCertificateTemplateTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) - } - if err := d.Set("effective_labels", flattenPrivatecaCertificateTemplateEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading CertificateTemplate: %s", err) + "critical": { + Type: schema.TypeBool, + Optional: true, + Description: "Optional. Indicates whether or not this extension is critical (i.e., if the client does not know how to handle this extension, the client should consider this to be an error).", + }, + }, } - - return nil } -func resourcePrivatecaCertificateTemplateUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for CertificateTemplate: %s", err) +func PrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "object_id_path": { + Type: schema.TypeList, + Required: true, + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, } - billingProject = strings.TrimPrefix(project, "projects/") +} - obj := make(map[string]interface{}) - predefinedValuesProp, err := expandPrivatecaCertificateTemplatePredefinedValues(d.Get("predefined_values"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("predefined_values"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, predefinedValuesProp)) { - obj["predefinedValues"] = predefinedValuesProp - } - identityConstraintsProp, err := expandPrivatecaCertificateTemplateIdentityConstraints(d.Get("identity_constraints"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("identity_constraints"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, identityConstraintsProp)) { - obj["identityConstraints"] = identityConstraintsProp - } - passthroughExtensionsProp, err := expandPrivatecaCertificateTemplatePassthroughExtensions(d.Get("passthrough_extensions"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("passthrough_extensions"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, passthroughExtensionsProp)) { - obj["passthroughExtensions"] = passthroughExtensionsProp - } - maximumLifetimeProp, err := expandPrivatecaCertificateTemplateMaximumLifetime(d.Get("maximum_lifetime"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("maximum_lifetime"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, maximumLifetimeProp)) { - obj["maximumLifetime"] = maximumLifetimeProp - } - descriptionProp, err := expandPrivatecaCertificateTemplateDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - labelsProp, err := expandPrivatecaCertificateTemplateEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } +func PrivatecaCertificateTemplatePredefinedValuesCaOptionsSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "is_ca": { + Type: schema.TypeBool, + Optional: true, + Description: "Optional. Refers to the \"CA\" X.509 extension, which is a boolean value. When this value is missing, the extension will be omitted from the CA certificate.", + }, - url, err := tpgresource.ReplaceVarsForId(d, config, "{{PrivatecaBasePath}}projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") - if err != nil { - return err + "max_issuer_path_length": { + Type: schema.TypeInt, + Optional: true, + Description: "Optional. Refers to the path length restriction X.509 extension. For a CA certificate, this value describes the depth of subordinate CA certificates that are allowed. If this value is less than 0, the request will fail. If this value is missing, the max path length will be omitted from the CA certificate.", + }, + }, } +} - log.Printf("[DEBUG] Updating CertificateTemplate %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} +func PrivatecaCertificateTemplatePredefinedValuesKeyUsageSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "base_key_usage": { + Type: schema.TypeList, + Optional: true, + Description: "Describes high-level ways in which a key may be used.", + MaxItems: 1, + Elem: PrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSchema(), + }, - if d.HasChange("predefined_values") { - updateMask = append(updateMask, "predefinedValues") - } + "extended_key_usage": { + Type: schema.TypeList, + Optional: true, + Description: "Detailed scenarios in which a key may be used.", + MaxItems: 1, + Elem: PrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSchema(), + }, - if d.HasChange("identity_constraints") { - updateMask = append(updateMask, "identityConstraints") + "unknown_extended_key_usages": { + Type: schema.TypeList, + Optional: true, + Description: "Used to describe extended key usages that are not listed in the KeyUsage.ExtendedKeyUsageOptions message.", + Elem: PrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSchema(), + }, + }, } +} - if d.HasChange("passthrough_extensions") { - updateMask = append(updateMask, "passthroughExtensions") - } +func PrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cert_sign": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used to sign certificates.", + }, - if d.HasChange("maximum_lifetime") { - updateMask = append(updateMask, "maximumLifetime") - } + "content_commitment": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used for cryptographic commitments. Note that this may also be referred to as \"non-repudiation\".", + }, - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } + "crl_sign": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used sign certificate revocation lists.", + }, - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } + "data_encipherment": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used to encipher data.", + }, - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp + "decipher_only": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used to decipher only.", + }, + + "digital_signature": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used for digital signatures.", + }, + + "encipher_only": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used to encipher only.", + }, + + "key_agreement": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used in a key agreement protocol.", + }, + + "key_encipherment": { + Type: schema.TypeBool, + Optional: true, + Description: "The key may be used to encipher other keys.", + }, + }, } +} - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating CertificateTemplate %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating CertificateTemplate %q: %#v", d.Id(), res) - } +func PrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "client_auth": { + Type: schema.TypeBool, + Optional: true, + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.2. Officially described as \"TLS WWW client authentication\", though regularly used for non-WWW TLS.", + }, - err = PrivatecaOperationWaitTime( - config, res, tpgresource.GetResourceNameFromSelfLink(project), "Updating CertificateTemplate", userAgent, - d.Timeout(schema.TimeoutUpdate)) + "code_signing": { + Type: schema.TypeBool, + Optional: true, + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.3. Officially described as \"Signing of downloadable executable code client authentication\".", + }, - if err != nil { - return err - } + "email_protection": { + Type: schema.TypeBool, + Optional: true, + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.4. Officially described as \"Email protection\".", + }, + + "ocsp_signing": { + Type: schema.TypeBool, + Optional: true, + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.9. Officially described as \"Signing OCSP responses\".", + }, + + "server_auth": { + Type: schema.TypeBool, + Optional: true, + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.1. Officially described as \"TLS WWW server authentication\", though regularly used for non-WWW TLS.", + }, + + "time_stamping": { + Type: schema.TypeBool, + Optional: true, + Description: "Corresponds to OID 1.3.6.1.5.5.7.3.8. Officially described as \"Binding the hash of an object to a time\".", + }, + }, } +} - return resourcePrivatecaCertificateTemplateRead(d, meta) +func PrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "object_id_path": { + Type: schema.TypeList, + Required: true, + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, + } } -func resourcePrivatecaCertificateTemplateDelete(d *schema.ResourceData, meta interface{}) error { +func PrivatecaCertificateTemplatePredefinedValuesPolicyIdsSchema() *schema.Resource { + return &schema.Resource{ + Schema: map[string]*schema.Schema{ + "object_id_path": { + Type: schema.TypeList, + Required: true, + Description: "Required. The parts of an OID path. The most significant parts of the path come first.", + Elem: &schema.Schema{Type: schema.TypeInt}, + }, + }, + } +} + +func resourcePrivatecaCertificateTemplateCreate(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + project, err := tpgresource.GetProject(d, config) if err != nil { return err } - billingProject := "" + obj := &privateca.CertificateTemplate{ + Location: dcl.String(d.Get("location").(string)), + Name: dcl.String(d.Get("name").(string)), + Description: dcl.String(d.Get("description").(string)), + Labels: tpgresource.CheckStringMap(d.Get("effective_labels")), + IdentityConstraints: expandPrivatecaCertificateTemplateIdentityConstraints(d.Get("identity_constraints")), + PassthroughExtensions: expandPrivatecaCertificateTemplatePassthroughExtensions(d.Get("passthrough_extensions")), + PredefinedValues: expandPrivatecaCertificateTemplatePredefinedValues(d.Get("predefined_values")), + Project: dcl.String(project), + } - project, err := tpgresource.GetProject(d, config) + id, err := obj.ID() if err != nil { - return fmt.Errorf("Error fetching project for CertificateTemplate: %s", err) + return fmt.Errorf("error constructing id: %s", err) } - billingProject = strings.TrimPrefix(project, "projects/") - - url, err := tpgresource.ReplaceVarsForId(d, config, "{{PrivatecaBasePath}}projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") + d.SetId(id) + directive := tpgdclresource.CreateDirective + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) if err != nil { return err } - - var obj map[string]interface{} - + billingProject := project // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting CertificateTemplate %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "CertificateTemplate") + client := transport_tpg.NewDCLPrivatecaClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutCreate)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } + res, err := client.ApplyCertificateTemplate(context.Background(), obj, directive...) - err = PrivatecaOperationWaitTime( - config, res, tpgresource.GetResourceNameFromSelfLink(project), "Deleting CertificateTemplate", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err + if _, ok := err.(dcl.DiffAfterApplyError); ok { + log.Printf("[DEBUG] Diff after apply returned from the DCL: %s", err) + } else if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error creating CertificateTemplate: %s", err) } - log.Printf("[DEBUG] Finished deleting CertificateTemplate %q: %#v", d.Id(), res) - return nil + log.Printf("[DEBUG] Finished creating CertificateTemplate %q: %#v", d.Id(), res) + + return resourcePrivatecaCertificateTemplateRead(d, meta) } -func resourcePrivatecaCertificateTemplateImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { +func resourcePrivatecaCertificateTemplateRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/certificateTemplates/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVarsForId(d, config, "projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") + project, err := tpgresource.GetProject(d, config) if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) + return err } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} -func flattenPrivatecaCertificateTemplatePredefinedValues(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + obj := &privateca.CertificateTemplate{ + Location: dcl.String(d.Get("location").(string)), + Name: dcl.String(d.Get("name").(string)), + Description: dcl.String(d.Get("description").(string)), + Labels: tpgresource.CheckStringMap(d.Get("effective_labels")), + IdentityConstraints: expandPrivatecaCertificateTemplateIdentityConstraints(d.Get("identity_constraints")), + PassthroughExtensions: expandPrivatecaCertificateTemplatePassthroughExtensions(d.Get("passthrough_extensions")), + PredefinedValues: expandPrivatecaCertificateTemplatePredefinedValues(d.Get("predefined_values")), + Project: dcl.String(project), } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["key_usage"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsage(original["keyUsage"], d, config) - transformed["ca_options"] = - flattenPrivatecaCertificateTemplatePredefinedValuesCaOptions(original["caOptions"], d, config) - transformed["policy_ids"] = - flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIds(original["policyIds"], d, config) - transformed["aia_ocsp_servers"] = - flattenPrivatecaCertificateTemplatePredefinedValuesAiaOcspServers(original["aiaOcspServers"], d, config) - transformed["additional_extensions"] = - flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(original["additionalExtensions"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + billingProject := project + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp } - transformed := make(map[string]interface{}) - transformed["base_key_usage"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(original["baseKeyUsage"], d, config) - transformed["extended_key_usage"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(original["extendedKeyUsage"], d, config) - transformed["unknown_extended_key_usages"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(original["unknownExtendedKeyUsages"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + client := transport_tpg.NewDCLPrivatecaClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutRead)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + res, err := client.GetCertificateTemplate(context.Background(), obj) + if err != nil { + resourceName := fmt.Sprintf("PrivatecaCertificateTemplate %q", d.Id()) + return tpgdclresource.HandleNotFoundDCLError(err, d, resourceName) } - transformed := make(map[string]interface{}) - transformed["digital_signature"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDigitalSignature(original["digitalSignature"], d, config) - transformed["content_commitment"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageContentCommitment(original["contentCommitment"], d, config) - transformed["key_encipherment"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyEncipherment(original["keyEncipherment"], d, config) - transformed["data_encipherment"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDataEncipherment(original["dataEncipherment"], d, config) - transformed["key_agreement"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyAgreement(original["keyAgreement"], d, config) - transformed["cert_sign"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCertSign(original["certSign"], d, config) - transformed["crl_sign"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCrlSign(original["crlSign"], d, config) - transformed["encipher_only"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageEncipherOnly(original["encipherOnly"], d, config) - transformed["decipher_only"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDecipherOnly(original["decipherOnly"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDigitalSignature(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageContentCommitment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyEncipherment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDataEncipherment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyAgreement(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCertSign(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCrlSign(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageEncipherOnly(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDecipherOnly(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + if err = d.Set("location", res.Location); err != nil { + return fmt.Errorf("error setting location in state: %s", err) } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + if err = d.Set("name", res.Name); err != nil { + return fmt.Errorf("error setting name in state: %s", err) } - transformed := make(map[string]interface{}) - transformed["server_auth"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageServerAuth(original["serverAuth"], d, config) - transformed["client_auth"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageClientAuth(original["clientAuth"], d, config) - transformed["code_signing"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageCodeSigning(original["codeSigning"], d, config) - transformed["email_protection"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageEmailProtection(original["emailProtection"], d, config) - transformed["time_stamping"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageTimeStamping(original["timeStamping"], d, config) - transformed["ocsp_signing"] = - flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageOcspSigning(original["ocspSigning"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageServerAuth(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageClientAuth(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageCodeSigning(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageEmailProtection(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageTimeStamping(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageOcspSigning(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "object_id_path": flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesObjectIdPath(original["objectIdPath"], d, config), - }) + if err = d.Set("description", res.Description); err != nil { + return fmt.Errorf("error setting description in state: %s", err) } - return transformed -} -func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesObjectIdPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesCaOptions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + if err = d.Set("effective_labels", res.Labels); err != nil { + return fmt.Errorf("error setting effective_labels in state: %s", err) } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + if err = d.Set("identity_constraints", flattenPrivatecaCertificateTemplateIdentityConstraints(res.IdentityConstraints)); err != nil { + return fmt.Errorf("error setting identity_constraints in state: %s", err) } - transformed := make(map[string]interface{}) - transformed["is_ca"] = - flattenPrivatecaCertificateTemplatePredefinedValuesCaOptionsIsCa(original["isCa"], d, config) - transformed["max_issuer_path_length"] = - flattenPrivatecaCertificateTemplatePredefinedValuesCaOptionsMaxIssuerPathLength(original["maxIssuerPathLength"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePredefinedValuesCaOptionsIsCa(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesCaOptionsMaxIssuerPathLength(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } + if err = d.Set("passthrough_extensions", flattenPrivatecaCertificateTemplatePassthroughExtensions(res.PassthroughExtensions)); err != nil { + return fmt.Errorf("error setting passthrough_extensions in state: %s", err) } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal + if err = d.Set("predefined_values", flattenPrivatecaCertificateTemplatePredefinedValues(res.PredefinedValues)); err != nil { + return fmt.Errorf("error setting predefined_values in state: %s", err) } - - return v // let terraform core handle it otherwise -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIds(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "object_id_path": flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIdsObjectIdPath(original["objectIdPath"], d, config), - }) + if err = d.Set("project", res.Project); err != nil { + return fmt.Errorf("error setting project in state: %s", err) } - return transformed -} -func flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIdsObjectIdPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesAiaOcspServers(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "object_id": flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(original["objectId"], d, config), - "critical": flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsCritical(original["critical"], d, config), - "value": flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsValue(original["value"], d, config), - }) + if err = d.Set("create_time", res.CreateTime); err != nil { + return fmt.Errorf("error setting create_time in state: %s", err) } - return transformed -} -func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + if err = d.Set("labels", flattenPrivatecaCertificateTemplateLabels(res.Labels, d)); err != nil { + return fmt.Errorf("error setting labels in state: %s", err) } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + if err = d.Set("terraform_labels", flattenPrivatecaCertificateTemplateTerraformLabels(res.Labels, d)); err != nil { + return fmt.Errorf("error setting terraform_labels in state: %s", err) + } + if err = d.Set("update_time", res.UpdateTime); err != nil { + return fmt.Errorf("error setting update_time in state: %s", err) } - transformed := make(map[string]interface{}) - transformed["object_id_path"] = - flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdObjectIdPath(original["objectIdPath"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdObjectIdPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsCritical(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsValue(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + return nil } +func resourcePrivatecaCertificateTemplateUpdate(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + project, err := tpgresource.GetProject(d, config) + if err != nil { + return err + } -func flattenPrivatecaCertificateTemplateIdentityConstraints(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + obj := &privateca.CertificateTemplate{ + Location: dcl.String(d.Get("location").(string)), + Name: dcl.String(d.Get("name").(string)), + Description: dcl.String(d.Get("description").(string)), + Labels: tpgresource.CheckStringMap(d.Get("effective_labels")), + IdentityConstraints: expandPrivatecaCertificateTemplateIdentityConstraints(d.Get("identity_constraints")), + PassthroughExtensions: expandPrivatecaCertificateTemplatePassthroughExtensions(d.Get("passthrough_extensions")), + PredefinedValues: expandPrivatecaCertificateTemplatePredefinedValues(d.Get("predefined_values")), + Project: dcl.String(project), } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + directive := tpgdclresource.UpdateDirective + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err } - transformed := make(map[string]interface{}) - transformed["cel_expression"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpression(original["celExpression"], d, config) - transformed["allow_subject_passthrough"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectPassthrough(original["allowSubjectPassthrough"], d, config) - transformed["allow_subject_alt_names_passthrough"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectAltNamesPassthrough(original["allowSubjectAltNamesPassthrough"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + + billingProject := "" + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + client := transport_tpg.NewDCLPrivatecaClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutUpdate)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionExpression(original["expression"], d, config) - transformed["title"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionTitle(original["title"], d, config) - transformed["description"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionDescription(original["description"], d, config) - transformed["location"] = - flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + res, err := client.ApplyCertificateTemplate(context.Background(), obj, directive...) -func flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + if _, ok := err.(dcl.DiffAfterApplyError); ok { + log.Printf("[DEBUG] Diff after apply returned from the DCL: %s", err) + } else if err != nil { + // The resource didn't actually create + d.SetId("") + return fmt.Errorf("Error updating CertificateTemplate: %s", err) + } -func flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + log.Printf("[DEBUG] Finished creating CertificateTemplate %q: %#v", d.Id(), res) -func flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpressionLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + return resourcePrivatecaCertificateTemplateRead(d, meta) } -func flattenPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectPassthrough(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} +func resourcePrivatecaCertificateTemplateDelete(d *schema.ResourceData, meta interface{}) error { + config := meta.(*transport_tpg.Config) + project, err := tpgresource.GetProject(d, config) + if err != nil { + return err + } -func flattenPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectAltNamesPassthrough(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} + obj := &privateca.CertificateTemplate{ + Location: dcl.String(d.Get("location").(string)), + Name: dcl.String(d.Get("name").(string)), + Description: dcl.String(d.Get("description").(string)), + Labels: tpgresource.CheckStringMap(d.Get("effective_labels")), + IdentityConstraints: expandPrivatecaCertificateTemplateIdentityConstraints(d.Get("identity_constraints")), + PassthroughExtensions: expandPrivatecaCertificateTemplatePassthroughExtensions(d.Get("passthrough_extensions")), + PredefinedValues: expandPrivatecaCertificateTemplatePredefinedValues(d.Get("predefined_values")), + Project: dcl.String(project), + } -func flattenPrivatecaCertificateTemplatePassthroughExtensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil + log.Printf("[DEBUG] Deleting CertificateTemplate %q", d.Id()) + userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) + if err != nil { + return err } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil + billingProject := project + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp } - transformed := make(map[string]interface{}) - transformed["known_extensions"] = - flattenPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensions(original["knownExtensions"], d, config) - transformed["additional_extensions"] = - flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(original["additionalExtensions"], d, config) - return []interface{}{transformed} -} -func flattenPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "object_id_path": flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsObjectIdPath(original["objectIdPath"], d, config), - }) + client := transport_tpg.NewDCLPrivatecaClient(config, userAgent, billingProject, d.Timeout(schema.TimeoutDelete)) + if bp, err := tpgresource.ReplaceVars(d, config, client.Config.BasePath); err != nil { + d.SetId("") + return fmt.Errorf("Could not format %q: %w", client.Config.BasePath, err) + } else { + client.Config.BasePath = bp + } + if err := client.DeleteCertificateTemplate(context.Background(), obj); err != nil { + return fmt.Errorf("Error deleting CertificateTemplate: %s", err) } - return transformed -} -func flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsObjectIdPath(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplateMaximumLifetime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPrivatecaCertificateTemplateDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} -func flattenPrivatecaCertificateTemplateCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v + log.Printf("[DEBUG] Finished deleting CertificateTemplate %q", d.Id()) + return nil } -func flattenPrivatecaCertificateTemplateUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} +func resourcePrivatecaCertificateTemplateImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { + config := meta.(*transport_tpg.Config) -func flattenPrivatecaCertificateTemplateLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v + if err := tpgresource.ParseImportId([]string{ + "projects/(?P[^/]+)/locations/(?P[^/]+)/certificateTemplates/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", + "(?P[^/]+)/(?P[^/]+)", + }, d, config); err != nil { + return nil, err } - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } + // Replace import id for the resource id + id, err := tpgresource.ReplaceVarsForId(d, config, "projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}") + if err != nil { + return nil, fmt.Errorf("Error constructing id: %s", err) } + d.SetId(id) - return transformed + return []*schema.ResourceData{d}, nil } -func flattenPrivatecaCertificateTemplateTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v +func expandPrivatecaCertificateTemplateIdentityConstraints(o interface{}) *privateca.CertificateTemplateIdentityConstraints { + if o == nil { + return privateca.EmptyCertificateTemplateIdentityConstraints + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplateIdentityConstraints } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplateIdentityConstraints{ + AllowSubjectAltNamesPassthrough: dcl.Bool(obj["allow_subject_alt_names_passthrough"].(bool)), + AllowSubjectPassthrough: dcl.Bool(obj["allow_subject_passthrough"].(bool)), + CelExpression: expandPrivatecaCertificateTemplateIdentityConstraintsCelExpression(obj["cel_expression"]), + } +} - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } +func flattenPrivatecaCertificateTemplateIdentityConstraints(obj *privateca.CertificateTemplateIdentityConstraints) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "allow_subject_alt_names_passthrough": obj.AllowSubjectAltNamesPassthrough, + "allow_subject_passthrough": obj.AllowSubjectPassthrough, + "cel_expression": flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpression(obj.CelExpression), } - return transformed -} + return []interface{}{transformed} -func flattenPrivatecaCertificateTemplateEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v } -func expandPrivatecaCertificateTemplatePredefinedValues(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func expandPrivatecaCertificateTemplateIdentityConstraintsCelExpression(o interface{}) *privateca.CertificateTemplateIdentityConstraintsCelExpression { + if o == nil { + return privateca.EmptyCertificateTemplateIdentityConstraintsCelExpression } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKeyUsage, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsage(original["key_usage"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKeyUsage); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["keyUsage"] = transformedKeyUsage + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplateIdentityConstraintsCelExpression } - - transformedCaOptions, err := expandPrivatecaCertificateTemplatePredefinedValuesCaOptions(original["ca_options"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCaOptions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["caOptions"] = transformedCaOptions + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplateIdentityConstraintsCelExpression{ + Description: dcl.String(obj["description"].(string)), + Expression: dcl.String(obj["expression"].(string)), + Location: dcl.String(obj["location"].(string)), + Title: dcl.String(obj["title"].(string)), } +} - transformedPolicyIds, err := expandPrivatecaCertificateTemplatePredefinedValuesPolicyIds(original["policy_ids"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPolicyIds); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["policyIds"] = transformedPolicyIds +func flattenPrivatecaCertificateTemplateIdentityConstraintsCelExpression(obj *privateca.CertificateTemplateIdentityConstraintsCelExpression) interface{} { + if obj == nil || obj.Empty() { + return nil } - - transformedAiaOcspServers, err := expandPrivatecaCertificateTemplatePredefinedValuesAiaOcspServers(original["aia_ocsp_servers"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAiaOcspServers); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["aiaOcspServers"] = transformedAiaOcspServers + transformed := map[string]interface{}{ + "description": obj.Description, + "expression": obj.Expression, + "location": obj.Location, + "title": obj.Title, } - transformedAdditionalExtensions, err := expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(original["additional_extensions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAdditionalExtensions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["additionalExtensions"] = transformedAdditionalExtensions - } + return []interface{}{transformed} - return transformed, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedBaseKeyUsage, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(original["base_key_usage"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedBaseKeyUsage); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["baseKeyUsage"] = transformedBaseKeyUsage +func expandPrivatecaCertificateTemplatePassthroughExtensions(o interface{}) *privateca.CertificateTemplatePassthroughExtensions { + if o == nil { + return privateca.EmptyCertificateTemplatePassthroughExtensions } - - transformedExtendedKeyUsage, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(original["extended_key_usage"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExtendedKeyUsage); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["extendedKeyUsage"] = transformedExtendedKeyUsage + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePassthroughExtensions } - - transformedUnknownExtendedKeyUsages, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(original["unknown_extended_key_usages"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedUnknownExtendedKeyUsages); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["unknownExtendedKeyUsages"] = transformedUnknownExtendedKeyUsages + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePassthroughExtensions{ + AdditionalExtensions: expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsArray(obj["additional_extensions"]), + KnownExtensions: expandPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensionsArray(obj["known_extensions"]), } - - return transformed, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func flattenPrivatecaCertificateTemplatePassthroughExtensions(obj *privateca.CertificateTemplatePassthroughExtensions) interface{} { + if obj == nil || obj.Empty() { + return nil } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDigitalSignature, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDigitalSignature(original["digital_signature"], d, config) - if err != nil { - return nil, err - } else { - transformed["digitalSignature"] = transformedDigitalSignature + transformed := map[string]interface{}{ + "additional_extensions": flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsArray(obj.AdditionalExtensions), + "known_extensions": flattenPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensionsArray(obj.KnownExtensions), } - transformedContentCommitment, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageContentCommitment(original["content_commitment"], d, config) - if err != nil { - return nil, err - } else { - transformed["contentCommitment"] = transformedContentCommitment - } + return []interface{}{transformed} - transformedKeyEncipherment, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyEncipherment(original["key_encipherment"], d, config) - if err != nil { - return nil, err - } else { - transformed["keyEncipherment"] = transformedKeyEncipherment +} +func expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsArray(o interface{}) []privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions { + if o == nil { + return make([]privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions, 0) } - transformedDataEncipherment, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDataEncipherment(original["data_encipherment"], d, config) - if err != nil { - return nil, err - } else { - transformed["dataEncipherment"] = transformedDataEncipherment + objs := o.([]interface{}) + if len(objs) == 0 || objs[0] == nil { + return make([]privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions, 0) } - transformedKeyAgreement, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyAgreement(original["key_agreement"], d, config) - if err != nil { - return nil, err - } else { - transformed["keyAgreement"] = transformedKeyAgreement + items := make([]privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions, 0, len(objs)) + for _, item := range objs { + i := expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(item) + items = append(items, *i) } - transformedCertSign, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCertSign(original["cert_sign"], d, config) - if err != nil { - return nil, err - } else { - transformed["certSign"] = transformedCertSign + return items +} + +func expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(o interface{}) *privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions { + if o == nil { + return privateca.EmptyCertificateTemplatePassthroughExtensionsAdditionalExtensions } - transformedCrlSign, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCrlSign(original["crl_sign"], d, config) - if err != nil { - return nil, err - } else { - transformed["crlSign"] = transformedCrlSign + obj := o.(map[string]interface{}) + return &privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions{ + ObjectIdPath: tpgdclresource.ExpandIntegerArray(obj["object_id_path"]), } +} - transformedEncipherOnly, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageEncipherOnly(original["encipher_only"], d, config) - if err != nil { - return nil, err - } else { - transformed["encipherOnly"] = transformedEncipherOnly +func flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsArray(objs []privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions) []interface{} { + if objs == nil { + return nil } - transformedDecipherOnly, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDecipherOnly(original["decipher_only"], d, config) - if err != nil { - return nil, err - } else { - transformed["decipherOnly"] = transformedDecipherOnly + items := []interface{}{} + for _, item := range objs { + i := flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(&item) + items = append(items, i) } - return transformed, nil + return items } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDigitalSignature(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func flattenPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(obj *privateca.CertificateTemplatePassthroughExtensionsAdditionalExtensions) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "object_id_path": obj.ObjectIdPath, + } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageContentCommitment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return transformed -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyEncipherment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDataEncipherment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil +func expandPrivatecaCertificateTemplatePredefinedValues(o interface{}) *privateca.CertificateTemplatePredefinedValues { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValues + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePredefinedValues + } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValues{ + AdditionalExtensions: expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsArray(obj["additional_extensions"]), + AiaOcspServers: tpgdclresource.ExpandStringArray(obj["aia_ocsp_servers"]), + CaOptions: expandPrivatecaCertificateTemplatePredefinedValuesCaOptions(obj["ca_options"]), + KeyUsage: expandPrivatecaCertificateTemplatePredefinedValuesKeyUsage(obj["key_usage"]), + PolicyIds: expandPrivatecaCertificateTemplatePredefinedValuesPolicyIdsArray(obj["policy_ids"]), + } } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageKeyAgreement(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func flattenPrivatecaCertificateTemplatePredefinedValues(obj *privateca.CertificateTemplatePredefinedValues) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "additional_extensions": flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsArray(obj.AdditionalExtensions), + "aia_ocsp_servers": obj.AiaOcspServers, + "ca_options": flattenPrivatecaCertificateTemplatePredefinedValuesCaOptions(obj.CaOptions), + "key_usage": flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsage(obj.KeyUsage), + "policy_ids": flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIdsArray(obj.PolicyIds), + } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCertSign(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return []interface{}{transformed} -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageCrlSign(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } +func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsArray(o interface{}) []privateca.CertificateTemplatePredefinedValuesAdditionalExtensions { + if o == nil { + return make([]privateca.CertificateTemplatePredefinedValuesAdditionalExtensions, 0) + } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageEncipherOnly(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + objs := o.([]interface{}) + if len(objs) == 0 || objs[0] == nil { + return make([]privateca.CertificateTemplatePredefinedValuesAdditionalExtensions, 0) + } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsageDecipherOnly(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + items := make([]privateca.CertificateTemplatePredefinedValuesAdditionalExtensions, 0, len(objs)) + for _, item := range objs { + i := expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(item) + items = append(items, *i) + } + + return items } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(o interface{}) *privateca.CertificateTemplatePredefinedValuesAdditionalExtensions { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesAdditionalExtensions } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - transformedServerAuth, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageServerAuth(original["server_auth"], d, config) - if err != nil { - return nil, err - } else { - transformed["serverAuth"] = transformedServerAuth + obj := o.(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesAdditionalExtensions{ + ObjectId: expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(obj["object_id"]), + Value: dcl.String(obj["value"].(string)), + Critical: dcl.Bool(obj["critical"].(bool)), } +} - transformedClientAuth, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageClientAuth(original["client_auth"], d, config) - if err != nil { - return nil, err - } else { - transformed["clientAuth"] = transformedClientAuth +func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsArray(objs []privateca.CertificateTemplatePredefinedValuesAdditionalExtensions) []interface{} { + if objs == nil { + return nil } - transformedCodeSigning, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageCodeSigning(original["code_signing"], d, config) - if err != nil { - return nil, err - } else { - transformed["codeSigning"] = transformedCodeSigning + items := []interface{}{} + for _, item := range objs { + i := flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(&item) + items = append(items, i) } - transformedEmailProtection, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageEmailProtection(original["email_protection"], d, config) - if err != nil { - return nil, err - } else { - transformed["emailProtection"] = transformedEmailProtection - } + return items +} - transformedTimeStamping, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageTimeStamping(original["time_stamping"], d, config) - if err != nil { - return nil, err - } else { - transformed["timeStamping"] = transformedTimeStamping +func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(obj *privateca.CertificateTemplatePredefinedValuesAdditionalExtensions) interface{} { + if obj == nil || obj.Empty() { + return nil } - - transformedOcspSigning, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageOcspSigning(original["ocsp_signing"], d, config) - if err != nil { - return nil, err - } else { - transformed["ocspSigning"] = transformedOcspSigning + transformed := map[string]interface{}{ + "object_id": flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(obj.ObjectId), + "value": obj.Value, + "critical": obj.Critical, } - return transformed, nil -} + return transformed -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageServerAuth(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageClientAuth(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil +func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(o interface{}) *privateca.CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId + } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId{ + ObjectIdPath: tpgdclresource.ExpandIntegerArray(obj["object_id_path"]), + } } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageCodeSigning(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func flattenPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(obj *privateca.CertificateTemplatePredefinedValuesAdditionalExtensionsObjectId) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "object_id_path": obj.ObjectIdPath, + } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageEmailProtection(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return []interface{}{transformed} -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageTimeStamping(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsageOcspSigning(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil +func expandPrivatecaCertificateTemplatePredefinedValuesCaOptions(o interface{}) *privateca.CertificateTemplatePredefinedValuesCaOptions { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesCaOptions + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesCaOptions + } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesCaOptions{ + IsCa: dcl.Bool(obj["is_ca"].(bool)), + MaxIssuerPathLength: dcl.Int64(int64(obj["max_issuer_path_length"].(int))), + } } -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedObjectIdPath, err := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesObjectIdPath(original["object_id_path"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedObjectIdPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["objectIdPath"] = transformedObjectIdPath - } - - req = append(req, transformed) +func flattenPrivatecaCertificateTemplatePredefinedValuesCaOptions(obj *privateca.CertificateTemplatePredefinedValuesCaOptions) interface{} { + if obj == nil || obj.Empty() { + return nil } - return req, nil -} + transformed := map[string]interface{}{ + "is_ca": obj.IsCa, + "max_issuer_path_length": obj.MaxIssuerPathLength, + } + + return []interface{}{transformed} -func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesObjectIdPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesCaOptions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsage(o interface{}) *privateca.CertificateTemplatePredefinedValuesKeyUsage { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsage } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedIsCa, err := expandPrivatecaCertificateTemplatePredefinedValuesCaOptionsIsCa(original["is_ca"], d, config) - if err != nil { - return nil, err - } else { - transformed["isCa"] = transformedIsCa + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsage } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesKeyUsage{ + BaseKeyUsage: expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(obj["base_key_usage"]), + ExtendedKeyUsage: expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(obj["extended_key_usage"]), + UnknownExtendedKeyUsages: expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesArray(obj["unknown_extended_key_usages"]), + } +} - transformedMaxIssuerPathLength, err := expandPrivatecaCertificateTemplatePredefinedValuesCaOptionsMaxIssuerPathLength(original["max_issuer_path_length"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMaxIssuerPathLength); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["maxIssuerPathLength"] = transformedMaxIssuerPathLength +func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsage(obj *privateca.CertificateTemplatePredefinedValuesKeyUsage) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "base_key_usage": flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(obj.BaseKeyUsage), + "extended_key_usage": flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(obj.ExtendedKeyUsage), + "unknown_extended_key_usages": flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesArray(obj.UnknownExtendedKeyUsages), } - return transformed, nil -} + return []interface{}{transformed} -func expandPrivatecaCertificateTemplatePredefinedValuesCaOptionsIsCa(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesCaOptionsMaxIssuerPathLength(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil +func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(o interface{}) *privateca.CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage + } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage{ + CertSign: dcl.Bool(obj["cert_sign"].(bool)), + ContentCommitment: dcl.Bool(obj["content_commitment"].(bool)), + CrlSign: dcl.Bool(obj["crl_sign"].(bool)), + DataEncipherment: dcl.Bool(obj["data_encipherment"].(bool)), + DecipherOnly: dcl.Bool(obj["decipher_only"].(bool)), + DigitalSignature: dcl.Bool(obj["digital_signature"].(bool)), + EncipherOnly: dcl.Bool(obj["encipher_only"].(bool)), + KeyAgreement: dcl.Bool(obj["key_agreement"].(bool)), + KeyEncipherment: dcl.Bool(obj["key_encipherment"].(bool)), + } } -func expandPrivatecaCertificateTemplatePredefinedValuesPolicyIds(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedObjectIdPath, err := expandPrivatecaCertificateTemplatePredefinedValuesPolicyIdsObjectIdPath(original["object_id_path"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedObjectIdPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["objectIdPath"] = transformedObjectIdPath - } - - req = append(req, transformed) +func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage(obj *privateca.CertificateTemplatePredefinedValuesKeyUsageBaseKeyUsage) interface{} { + if obj == nil || obj.Empty() { + return nil + } + transformed := map[string]interface{}{ + "cert_sign": obj.CertSign, + "content_commitment": obj.ContentCommitment, + "crl_sign": obj.CrlSign, + "data_encipherment": obj.DataEncipherment, + "decipher_only": obj.DecipherOnly, + "digital_signature": obj.DigitalSignature, + "encipher_only": obj.EncipherOnly, + "key_agreement": obj.KeyAgreement, + "key_encipherment": obj.KeyEncipherment, } - return req, nil -} -func expandPrivatecaCertificateTemplatePredefinedValuesPolicyIdsObjectIdPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + return []interface{}{transformed} -func expandPrivatecaCertificateTemplatePredefinedValuesAiaOcspServers(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedObjectId, err := expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(original["object_id"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedObjectId); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["objectId"] = transformedObjectId - } - - transformedCritical, err := expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsCritical(original["critical"], d, config) - if err != nil { - return nil, err - } else { - transformed["critical"] = transformedCritical - } - - transformedValue, err := expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsValue(original["value"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValue); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["value"] = transformedValue - } - - req = append(req, transformed) +func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(o interface{}) *privateca.CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + } + objArr := o.([]interface{}) + if len(objArr) == 0 || objArr[0] == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage + } + obj := objArr[0].(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage{ + ClientAuth: dcl.Bool(obj["client_auth"].(bool)), + CodeSigning: dcl.Bool(obj["code_signing"].(bool)), + EmailProtection: dcl.Bool(obj["email_protection"].(bool)), + OcspSigning: dcl.Bool(obj["ocsp_signing"].(bool)), + ServerAuth: dcl.Bool(obj["server_auth"].(bool)), + TimeStamping: dcl.Bool(obj["time_stamping"].(bool)), } - return req, nil } -func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectId(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage(obj *privateca.CertificateTemplatePredefinedValuesKeyUsageExtendedKeyUsage) interface{} { + if obj == nil || obj.Empty() { + return nil } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedObjectIdPath, err := expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdObjectIdPath(original["object_id_path"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedObjectIdPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["objectIdPath"] = transformedObjectIdPath + transformed := map[string]interface{}{ + "client_auth": obj.ClientAuth, + "code_signing": obj.CodeSigning, + "email_protection": obj.EmailProtection, + "ocsp_signing": obj.OcspSigning, + "server_auth": obj.ServerAuth, + "time_stamping": obj.TimeStamping, } - return transformed, nil -} + return []interface{}{transformed} -func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsObjectIdObjectIdPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil } +func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesArray(o interface{}) []privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + if o == nil { + return make([]privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, 0) + } -func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsCritical(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + objs := o.([]interface{}) + if len(objs) == 0 || objs[0] == nil { + return make([]privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, 0) + } -func expandPrivatecaCertificateTemplatePredefinedValuesAdditionalExtensionsValue(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + items := make([]privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages, 0, len(objs)) + for _, item := range objs { + i := expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(item) + items = append(items, *i) + } + + return items } -func expandPrivatecaCertificateTemplateIdentityConstraints(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func expandPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(o interface{}) *privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - transformedCelExpression, err := expandPrivatecaCertificateTemplateIdentityConstraintsCelExpression(original["cel_expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCelExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["celExpression"] = transformedCelExpression + obj := o.(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages{ + ObjectIdPath: tpgdclresource.ExpandIntegerArray(obj["object_id_path"]), } +} - transformedAllowSubjectPassthrough, err := expandPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectPassthrough(original["allow_subject_passthrough"], d, config) - if err != nil { - return nil, err - } else { - transformed["allowSubjectPassthrough"] = transformedAllowSubjectPassthrough +func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsagesArray(objs []privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) []interface{} { + if objs == nil { + return nil } - transformedAllowSubjectAltNamesPassthrough, err := expandPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectAltNamesPassthrough(original["allow_subject_alt_names_passthrough"], d, config) - if err != nil { - return nil, err - } else { - transformed["allowSubjectAltNamesPassthrough"] = transformedAllowSubjectAltNamesPassthrough + items := []interface{}{} + for _, item := range objs { + i := flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(&item) + items = append(items, i) } - return transformed, nil + return items } -func expandPrivatecaCertificateTemplateIdentityConstraintsCelExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func flattenPrivatecaCertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages(obj *privateca.CertificateTemplatePredefinedValuesKeyUsageUnknownExtendedKeyUsages) interface{} { + if obj == nil || obj.Empty() { + return nil } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression + transformed := map[string]interface{}{ + "object_id_path": obj.ObjectIdPath, } - transformedTitle, err := expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } + return transformed - transformedDescription, err := expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription +} +func expandPrivatecaCertificateTemplatePredefinedValuesPolicyIdsArray(o interface{}) []privateca.CertificateTemplatePredefinedValuesPolicyIds { + if o == nil { + return make([]privateca.CertificateTemplatePredefinedValuesPolicyIds, 0) } - transformedLocation, err := expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation + objs := o.([]interface{}) + if len(objs) == 0 || objs[0] == nil { + return make([]privateca.CertificateTemplatePredefinedValuesPolicyIds, 0) } - return transformed, nil -} + items := make([]privateca.CertificateTemplatePredefinedValuesPolicyIds, 0, len(objs)) + for _, item := range objs { + i := expandPrivatecaCertificateTemplatePredefinedValuesPolicyIds(item) + items = append(items, *i) + } -func expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + return items } -func expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func expandPrivatecaCertificateTemplatePredefinedValuesPolicyIds(o interface{}) *privateca.CertificateTemplatePredefinedValuesPolicyIds { + if o == nil { + return privateca.EmptyCertificateTemplatePredefinedValuesPolicyIds + } -func expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + obj := o.(map[string]interface{}) + return &privateca.CertificateTemplatePredefinedValuesPolicyIds{ + ObjectIdPath: tpgdclresource.ExpandIntegerArray(obj["object_id_path"]), + } } -func expandPrivatecaCertificateTemplateIdentityConstraintsCelExpressionLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIdsArray(objs []privateca.CertificateTemplatePredefinedValuesPolicyIds) []interface{} { + if objs == nil { + return nil + } -func expandPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectPassthrough(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} + items := []interface{}{} + for _, item := range objs { + i := flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIds(&item) + items = append(items, i) + } -func expandPrivatecaCertificateTemplateIdentityConstraintsAllowSubjectAltNamesPassthrough(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + return items } -func expandPrivatecaCertificateTemplatePassthroughExtensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil +func flattenPrivatecaCertificateTemplatePredefinedValuesPolicyIds(obj *privateca.CertificateTemplatePredefinedValuesPolicyIds) interface{} { + if obj == nil || obj.Empty() { + return nil } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedKnownExtensions, err := expandPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensions(original["known_extensions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedKnownExtensions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["knownExtensions"] = transformedKnownExtensions + transformed := map[string]interface{}{ + "object_id_path": obj.ObjectIdPath, } - transformedAdditionalExtensions, err := expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(original["additional_extensions"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAdditionalExtensions); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["additionalExtensions"] = transformedAdditionalExtensions - } + return transformed - return transformed, nil } -func expandPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func flattenPrivatecaCertificateTemplateLabels(v map[string]string, d *schema.ResourceData) interface{} { + if v == nil { + return nil + } -func expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensions(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedObjectIdPath, err := expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsObjectIdPath(original["object_id_path"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedObjectIdPath); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["objectIdPath"] = transformedObjectIdPath + transformed := make(map[string]interface{}) + if l, ok := d.Get("labels").(map[string]interface{}); ok { + for k, _ := range l { + transformed[k] = v[k] } - - req = append(req, transformed) } - return req, nil -} -func expandPrivatecaCertificateTemplatePassthroughExtensionsAdditionalExtensionsObjectIdPath(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + return transformed } -func expandPrivatecaCertificateTemplateMaximumLifetime(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} +func flattenPrivatecaCertificateTemplateTerraformLabels(v map[string]string, d *schema.ResourceData) interface{} { + if v == nil { + return nil + } + + transformed := make(map[string]interface{}) + if l, ok := d.Get("terraform_labels").(map[string]interface{}); ok { + for k, _ := range l { + transformed[k] = v[k] + } + } -func expandPrivatecaCertificateTemplateDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + return transformed } -func expandPrivatecaCertificateTemplateEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil +func flattenPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensionsArray(obj []privateca.CertificateTemplatePassthroughExtensionsKnownExtensionsEnum) interface{} { + if obj == nil { + return nil } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) + items := []string{} + for _, item := range obj { + items = append(items, string(item)) + } + return items +} +func expandPrivatecaCertificateTemplatePassthroughExtensionsKnownExtensionsArray(o interface{}) []privateca.CertificateTemplatePassthroughExtensionsKnownExtensionsEnum { + objs := o.([]interface{}) + items := make([]privateca.CertificateTemplatePassthroughExtensionsKnownExtensionsEnum, 0, len(objs)) + for _, item := range objs { + i := privateca.CertificateTemplatePassthroughExtensionsKnownExtensionsEnumRef(item.(string)) + items = append(items, *i) } - return m, nil + return items } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template_sweeper.go index 52846cdbe4a..7760e82f693 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/privateca/resource_privateca_certificate_template_sweeper.go @@ -3,15 +3,16 @@ // ---------------------------------------------------------------------------- // -// *** AUTO GENERATED CODE *** Type: MMv1 *** +// *** AUTO GENERATED CODE *** Type: DCL *** // // ---------------------------------------------------------------------------- // -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. +// This file is managed by Magic Modules (https://github.com/GoogleCloudPlatform/magic-modules) +// and is based on the DCL (https://github.com/GoogleCloudPlatform/declarative-resource-client-library). +// Changes will need to be made to the DCL or Magic Modules instead of here. // -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. +// We are not currently able to accept contributions to this file. If changes +// are required, please file an issue at https://github.com/hashicorp/terraform-provider-google/issues/new/choose // // ---------------------------------------------------------------------------- @@ -20,12 +21,11 @@ package privateca import ( "context" "log" - "strings" "testing" + privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca" "github.com/hashicorp/terraform-provider-google/google/envvar" "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" ) @@ -33,10 +33,8 @@ func init() { sweeper.AddTestSweepers("PrivatecaCertificateTemplate", testSweepPrivatecaCertificateTemplate) } -// At the time of writing, the CI only passes us-central1 as the region func testSweepPrivatecaCertificateTemplate(region string) error { - resourceName := "PrivatecaCertificateTemplate" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) + log.Print("[INFO][SWEEPER_LOG] Starting sweeper for PrivatecaCertificateTemplate") config, err := sweeper.SharedConfigForRegion(region) if err != nil { @@ -53,87 +51,23 @@ func testSweepPrivatecaCertificateTemplate(region string) error { t := &testing.T{} billingId := envvar.GetTestBillingAccountFromEnv(t) - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, + // Setup variables to be used for Delete arguments. + d := map[string]string{ + "project": config.Project, + "region": region, + "location": region, + "zone": "-", + "billing_account": billingId, } - listTemplate := strings.Split("https://privateca.googleapis.com/v1/projects/{{project}}/locations/{{location}}/certificateTemplates", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) + client := transport_tpg.NewDCLPrivatecaClient(config, config.UserAgent, "", 0) + err = client.DeleteAllCertificateTemplate(context.Background(), d["project"], d["location"], isDeletablePrivatecaCertificateTemplate) if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["certificateTemplates"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://privateca.googleapis.com/v1/projects/{{project}}/locations/{{location}}/certificateTemplates/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) + return err } - return nil } + +func isDeletablePrivatecaCertificateTemplate(r *privateca.CertificateTemplate) bool { + return sweeper.IsSweepableTestResource(*r.Name) +} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/publicca/resource_public_ca_external_account_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/publicca/resource_public_ca_external_account_key.go index bbcbf9fd5aa..4b3c7037124 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/publicca/resource_public_ca_external_account_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/publicca/resource_public_ca_external_account_key.go @@ -20,7 +20,6 @@ package publicca import ( "fmt" "log" - "net/http" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" @@ -110,7 +109,6 @@ func resourcePublicCAExternalAccountKeyCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -119,7 +117,6 @@ func resourcePublicCAExternalAccountKeyCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ExternalAccountKey: %s", err) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_schema.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_schema.go index a2dfcee3868..86e09858a47 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_schema.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_schema.go @@ -20,7 +20,6 @@ package pubsub import ( "fmt" "log" - "net/http" "reflect" "time" @@ -136,7 +135,6 @@ func resourcePubsubSchemaCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -145,7 +143,6 @@ func resourcePubsubSchemaCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Schema: %s", err) @@ -230,14 +227,12 @@ func resourcePubsubSchemaRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PubsubSchema %q", d.Id())) @@ -306,7 +301,6 @@ func resourcePubsubSchemaUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Schema %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -321,7 +315,6 @@ func resourcePubsubSchemaUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -360,8 +353,6 @@ func resourcePubsubSchemaDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Schema %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -371,7 +362,6 @@ func resourcePubsubSchemaDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Schema") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_subscription.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_subscription.go index 4bd81d7e623..a5e96bbc340 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_subscription.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_subscription.go @@ -20,10 +20,8 @@ package pubsub import ( "fmt" "log" - "net/http" "reflect" "regexp" - "strconv" "strings" "time" @@ -46,28 +44,6 @@ func comparePubsubSubscriptionExpirationPolicy(_, old, new string, _ *schema.Res return trimmedNew == trimmedOld } -func IgnoreMissingKeyInMap(key string) schema.SchemaDiffSuppressFunc { - return func(k, old, new string, d *schema.ResourceData) bool { - log.Printf("[DEBUG] - suppressing diff %q with old %q, new %q", k, old, new) - if strings.HasSuffix(k, ".%") { - oldNum, err := strconv.Atoi(old) - if err != nil { - log.Printf("[ERROR] could not parse %q as number, no longer attempting diff suppress", old) - return false - } - newNum, err := strconv.Atoi(new) - if err != nil { - log.Printf("[ERROR] could not parse %q as number, no longer attempting diff suppress", new) - return false - } - return oldNum+1 == newNum - } else if strings.HasSuffix(k, "."+key) { - return old == "" - } - return false - } -} - func ResourcePubsubSubscription() *schema.Resource { return &schema.Resource{ Create: resourcePubsubSubscriptionCreate, @@ -141,7 +117,7 @@ If all three are empty, then the subscriber will pull and ack messages using API "table": { Type: schema.TypeString, Required: true, - Description: `The name of the table to which to write data, of the form {projectId}.{datasetId}.{tableId}`, + Description: `The name of the table to which to write data, of the form {projectId}:{datasetId}.{tableId}`, }, "drop_unknown_fields": { Type: schema.TypeBool, @@ -149,13 +125,6 @@ If all three are empty, then the subscriber will pull and ack messages using API Description: `When true and use_topic_schema or use_table_schema is true, any fields that are a part of the topic schema or message schema that are not part of the BigQuery table schema are dropped when writing to BigQuery. Otherwise, the schemas must be kept in sync and any messages with extra fields are not written and remain in the subscription's backlog.`, - }, - "service_account_email": { - Type: schema.TypeString, - Optional: true, - Description: `The service account to use to write to BigQuery. If not specified, the Pub/Sub -[service agent](https://cloud.google.com/iam/docs/service-agents), -service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.`, }, "use_table_schema": { Type: schema.TypeBool, @@ -210,11 +179,6 @@ If all three are empty, then the subscriber will pull and ack messages using API }, }, }, - "filename_datetime_format": { - Type: schema.TypeString, - Optional: true, - Description: `User-provided format string specifying how to represent datetimes in Cloud Storage filenames.`, - }, "filename_prefix": { Type: schema.TypeString, Optional: true, @@ -239,13 +203,6 @@ May not exceed the subscription's acknowledgement deadline. A duration in seconds with up to nine fractional digits, ending with 's'. Example: "3.5s".`, Default: "300s", }, - "service_account_email": { - Type: schema.TypeString, - Optional: true, - Description: `The service account to use to write to Cloud Storage. If not specified, the Pub/Sub -[service agent](https://cloud.google.com/iam/docs/service-agents), -service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com, is used.`, - }, "state": { Type: schema.TypeString, Computed: true, @@ -403,7 +360,7 @@ For example, a Webhook endpoint might use "attributes": { Type: schema.TypeMap, Optional: true, - DiffSuppressFunc: IgnoreMissingKeyInMap("x-goog-version"), + DiffSuppressFunc: tpgresource.IgnoreMissingKeyInMap("x-goog-version"), Description: `Endpoint configuration attributes. Every endpoint has a set of API supported attributes that can @@ -664,7 +621,6 @@ func resourcePubsubSubscriptionCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PUT", @@ -673,7 +629,6 @@ func resourcePubsubSubscriptionCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Subscription: %s", err) @@ -763,14 +718,12 @@ func resourcePubsubSubscriptionRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PubsubSubscription %q", d.Id())) @@ -929,7 +882,6 @@ func resourcePubsubSubscriptionUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Subscription %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("bigquery_config") { @@ -997,7 +949,6 @@ func resourcePubsubSubscriptionUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1038,8 +989,6 @@ func resourcePubsubSubscriptionDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Subscription %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1049,7 +998,6 @@ func resourcePubsubSubscriptionDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Subscription") @@ -1127,8 +1075,6 @@ func flattenPubsubSubscriptionBigqueryConfig(v interface{}, d *schema.ResourceDa flattenPubsubSubscriptionBigqueryConfigWriteMetadata(original["writeMetadata"], d, config) transformed["drop_unknown_fields"] = flattenPubsubSubscriptionBigqueryConfigDropUnknownFields(original["dropUnknownFields"], d, config) - transformed["service_account_email"] = - flattenPubsubSubscriptionBigqueryConfigServiceAccountEmail(original["serviceAccountEmail"], d, config) return []interface{}{transformed} } func flattenPubsubSubscriptionBigqueryConfigTable(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1151,10 +1097,6 @@ func flattenPubsubSubscriptionBigqueryConfigDropUnknownFields(v interface{}, d * return v } -func flattenPubsubSubscriptionBigqueryConfigServiceAccountEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenPubsubSubscriptionCloudStorageConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1170,8 +1112,6 @@ func flattenPubsubSubscriptionCloudStorageConfig(v interface{}, d *schema.Resour flattenPubsubSubscriptionCloudStorageConfigFilenamePrefix(original["filenamePrefix"], d, config) transformed["filename_suffix"] = flattenPubsubSubscriptionCloudStorageConfigFilenameSuffix(original["filenameSuffix"], d, config) - transformed["filename_datetime_format"] = - flattenPubsubSubscriptionCloudStorageConfigFilenameDatetimeFormat(original["filenameDatetimeFormat"], d, config) transformed["max_duration"] = flattenPubsubSubscriptionCloudStorageConfigMaxDuration(original["maxDuration"], d, config) transformed["max_bytes"] = @@ -1180,8 +1120,6 @@ func flattenPubsubSubscriptionCloudStorageConfig(v interface{}, d *schema.Resour flattenPubsubSubscriptionCloudStorageConfigState(original["state"], d, config) transformed["avro_config"] = flattenPubsubSubscriptionCloudStorageConfigAvroConfig(original["avroConfig"], d, config) - transformed["service_account_email"] = - flattenPubsubSubscriptionCloudStorageConfigServiceAccountEmail(original["serviceAccountEmail"], d, config) return []interface{}{transformed} } func flattenPubsubSubscriptionCloudStorageConfigBucket(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -1196,10 +1134,6 @@ func flattenPubsubSubscriptionCloudStorageConfigFilenameSuffix(v interface{}, d return v } -func flattenPubsubSubscriptionCloudStorageConfigFilenameDatetimeFormat(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenPubsubSubscriptionCloudStorageConfigMaxDuration(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1242,10 +1176,6 @@ func flattenPubsubSubscriptionCloudStorageConfigAvroConfigWriteMetadata(v interf return v } -func flattenPubsubSubscriptionCloudStorageConfigServiceAccountEmail(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenPubsubSubscriptionPushConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1512,13 +1442,6 @@ func expandPubsubSubscriptionBigqueryConfig(v interface{}, d tpgresource.Terrafo transformed["dropUnknownFields"] = transformedDropUnknownFields } - transformedServiceAccountEmail, err := expandPubsubSubscriptionBigqueryConfigServiceAccountEmail(original["service_account_email"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAccountEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAccountEmail"] = transformedServiceAccountEmail - } - return transformed, nil } @@ -1542,10 +1465,6 @@ func expandPubsubSubscriptionBigqueryConfigDropUnknownFields(v interface{}, d tp return v, nil } -func expandPubsubSubscriptionBigqueryConfigServiceAccountEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandPubsubSubscriptionCloudStorageConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { @@ -1576,13 +1495,6 @@ func expandPubsubSubscriptionCloudStorageConfig(v interface{}, d tpgresource.Ter transformed["filenameSuffix"] = transformedFilenameSuffix } - transformedFilenameDatetimeFormat, err := expandPubsubSubscriptionCloudStorageConfigFilenameDatetimeFormat(original["filename_datetime_format"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFilenameDatetimeFormat); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["filenameDatetimeFormat"] = transformedFilenameDatetimeFormat - } - transformedMaxDuration, err := expandPubsubSubscriptionCloudStorageConfigMaxDuration(original["max_duration"], d, config) if err != nil { return nil, err @@ -1611,13 +1523,6 @@ func expandPubsubSubscriptionCloudStorageConfig(v interface{}, d tpgresource.Ter transformed["avroConfig"] = transformedAvroConfig } - transformedServiceAccountEmail, err := expandPubsubSubscriptionCloudStorageConfigServiceAccountEmail(original["service_account_email"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAccountEmail); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAccountEmail"] = transformedServiceAccountEmail - } - return transformed, nil } @@ -1633,10 +1538,6 @@ func expandPubsubSubscriptionCloudStorageConfigFilenameSuffix(v interface{}, d t return v, nil } -func expandPubsubSubscriptionCloudStorageConfigFilenameDatetimeFormat(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandPubsubSubscriptionCloudStorageConfigMaxDuration(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -1672,10 +1573,6 @@ func expandPubsubSubscriptionCloudStorageConfigAvroConfigWriteMetadata(v interfa return v, nil } -func expandPubsubSubscriptionCloudStorageConfigServiceAccountEmail(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandPubsubSubscriptionPushConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_topic.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_topic.go index b85fde5cff6..20f4d8b2fe6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_topic.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsub/resource_pubsub_topic.go @@ -20,7 +20,6 @@ package pubsub import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -63,53 +62,6 @@ func ResourcePubsubTopic() *schema.Resource { DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, Description: `Name of the topic.`, }, - "ingestion_data_source_settings": { - Type: schema.TypeList, - Optional: true, - Description: `Settings for ingestion from a data source into this topic.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "aws_kinesis": { - Type: schema.TypeList, - Optional: true, - Description: `Settings for ingestion from Amazon Kinesis Data Streams.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "aws_role_arn": { - Type: schema.TypeString, - Required: true, - Description: `AWS role ARN to be used for Federated Identity authentication with -Kinesis. Check the Pub/Sub docs for how to set up this role and the -required permissions that need to be attached to it.`, - }, - "consumer_arn": { - Type: schema.TypeString, - Required: true, - Description: `The Kinesis consumer ARN to used for ingestion in -Enhanced Fan-Out mode. The consumer must be already -created and ready to be used.`, - }, - "gcp_service_account": { - Type: schema.TypeString, - Required: true, - Description: `The GCP service account to be used for Federated Identity authentication -with Kinesis (via a 'AssumeRoleWithWebIdentity' call for the provided -role). The 'awsRoleArn' must be set up with 'accounts.google.com:sub' -equals to this service account number.`, - }, - "stream_arn": { - Type: schema.TypeString, - Required: true, - Description: `The Kinesis stream ARN to ingest data from.`, - }, - }, - }, - }, - }, - }, - }, "kms_key_name": { Type: schema.TypeString, Optional: true, @@ -255,12 +207,6 @@ func resourcePubsubTopicCreate(d *schema.ResourceData, meta interface{}) error { } else if v, ok := d.GetOkExists("message_retention_duration"); !tpgresource.IsEmptyValue(reflect.ValueOf(messageRetentionDurationProp)) && (ok || !reflect.DeepEqual(v, messageRetentionDurationProp)) { obj["messageRetentionDuration"] = messageRetentionDurationProp } - ingestionDataSourceSettingsProp, err := expandPubsubTopicIngestionDataSourceSettings(d.Get("ingestion_data_source_settings"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ingestion_data_source_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(ingestionDataSourceSettingsProp)) && (ok || !reflect.DeepEqual(v, ingestionDataSourceSettingsProp)) { - obj["ingestionDataSourceSettings"] = ingestionDataSourceSettingsProp - } labelsProp, err := expandPubsubTopicEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -292,7 +238,6 @@ func resourcePubsubTopicCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PUT", @@ -301,7 +246,6 @@ func resourcePubsubTopicCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.PubsubTopicProjectNotReady}, }) if err != nil { @@ -393,14 +337,12 @@ func resourcePubsubTopicRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.PubsubTopicProjectNotReady}, }) if err != nil { @@ -429,9 +371,6 @@ func resourcePubsubTopicRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("message_retention_duration", flattenPubsubTopicMessageRetentionDuration(res["messageRetentionDuration"], d, config)); err != nil { return fmt.Errorf("Error reading Topic: %s", err) } - if err := d.Set("ingestion_data_source_settings", flattenPubsubTopicIngestionDataSourceSettings(res["ingestionDataSourceSettings"], d, config)); err != nil { - return fmt.Errorf("Error reading Topic: %s", err) - } if err := d.Set("terraform_labels", flattenPubsubTopicTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading Topic: %s", err) } @@ -482,12 +421,6 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { } else if v, ok := d.GetOkExists("message_retention_duration"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, messageRetentionDurationProp)) { obj["messageRetentionDuration"] = messageRetentionDurationProp } - ingestionDataSourceSettingsProp, err := expandPubsubTopicIngestionDataSourceSettings(d.Get("ingestion_data_source_settings"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("ingestion_data_source_settings"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, ingestionDataSourceSettingsProp)) { - obj["ingestionDataSourceSettings"] = ingestionDataSourceSettingsProp - } labelsProp, err := expandPubsubTopicEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -506,7 +439,6 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { } log.Printf("[DEBUG] Updating Topic %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("kms_key_name") { @@ -525,10 +457,6 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { updateMask = append(updateMask, "messageRetentionDuration") } - if d.HasChange("ingestion_data_source_settings") { - updateMask = append(updateMask, "ingestionDataSourceSettings") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -554,7 +482,6 @@ func resourcePubsubTopicUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.PubsubTopicProjectNotReady}, }) @@ -596,8 +523,6 @@ func resourcePubsubTopicDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Topic %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -607,7 +532,6 @@ func resourcePubsubTopicDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.PubsubTopicProjectNotReady}, }) if err != nil { @@ -708,54 +632,6 @@ func flattenPubsubTopicMessageRetentionDuration(v interface{}, d *schema.Resourc return v } -func flattenPubsubTopicIngestionDataSourceSettings(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["aws_kinesis"] = - flattenPubsubTopicIngestionDataSourceSettingsAwsKinesis(original["awsKinesis"], d, config) - return []interface{}{transformed} -} -func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesis(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["stream_arn"] = - flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisStreamArn(original["streamArn"], d, config) - transformed["consumer_arn"] = - flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisConsumerArn(original["consumerArn"], d, config) - transformed["aws_role_arn"] = - flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisAwsRoleArn(original["awsRoleArn"], d, config) - transformed["gcp_service_account"] = - flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(original["gcpServiceAccount"], d, config) - return []interface{}{transformed} -} -func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisStreamArn(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisConsumerArn(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisAwsRoleArn(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenPubsubTopicTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -844,81 +720,6 @@ func expandPubsubTopicMessageRetentionDuration(v interface{}, d tpgresource.Terr return v, nil } -func expandPubsubTopicIngestionDataSourceSettings(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedAwsKinesis, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesis(original["aws_kinesis"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAwsKinesis); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["awsKinesis"] = transformedAwsKinesis - } - - return transformed, nil -} - -func expandPubsubTopicIngestionDataSourceSettingsAwsKinesis(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedStreamArn, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisStreamArn(original["stream_arn"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStreamArn); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["streamArn"] = transformedStreamArn - } - - transformedConsumerArn, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisConsumerArn(original["consumer_arn"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedConsumerArn); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["consumerArn"] = transformedConsumerArn - } - - transformedAwsRoleArn, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisAwsRoleArn(original["aws_role_arn"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAwsRoleArn); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["awsRoleArn"] = transformedAwsRoleArn - } - - transformedGcpServiceAccount, err := expandPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(original["gcp_service_account"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedGcpServiceAccount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["gcpServiceAccount"] = transformedGcpServiceAccount - } - - return transformed, nil -} - -func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisStreamArn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisConsumerArn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisAwsRoleArn(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandPubsubTopicIngestionDataSourceSettingsAwsKinesisGcpServiceAccount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandPubsubTopicEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_reservation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_reservation.go index a8fd7843824..eb5acbbc883 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_reservation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_reservation.go @@ -20,7 +20,6 @@ package pubsublite import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -118,7 +117,6 @@ func resourcePubsubLiteReservationCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -127,7 +125,6 @@ func resourcePubsubLiteReservationCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Reservation: %s", err) @@ -170,14 +167,12 @@ func resourcePubsubLiteReservationRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PubsubLiteReservation %q", d.Id())) @@ -223,7 +218,6 @@ func resourcePubsubLiteReservationUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating Reservation %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("throughput_capacity") { @@ -251,7 +245,6 @@ func resourcePubsubLiteReservationUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -292,8 +285,6 @@ func resourcePubsubLiteReservationDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Reservation %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -303,7 +294,6 @@ func resourcePubsubLiteReservationDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Reservation") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_subscription.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_subscription.go index 240e73766c4..4b7b484f8c0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_subscription.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_subscription.go @@ -20,7 +20,6 @@ package pubsublite import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -152,7 +151,6 @@ func resourcePubsubLiteSubscriptionCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -161,7 +159,6 @@ func resourcePubsubLiteSubscriptionCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Subscription: %s", err) @@ -204,14 +201,12 @@ func resourcePubsubLiteSubscriptionRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PubsubLiteSubscription %q", d.Id())) @@ -265,7 +260,6 @@ func resourcePubsubLiteSubscriptionUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating Subscription %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("delivery_config") { @@ -293,7 +287,6 @@ func resourcePubsubLiteSubscriptionUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -334,8 +327,6 @@ func resourcePubsubLiteSubscriptionDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Subscription %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -345,7 +336,6 @@ func resourcePubsubLiteSubscriptionDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Subscription") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_topic.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_topic.go index fc179a52d58..175f5af7aec 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_topic.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/pubsublite/resource_pubsub_lite_topic.go @@ -20,7 +20,6 @@ package pubsublite import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -209,7 +208,6 @@ func resourcePubsubLiteTopicCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -218,7 +216,6 @@ func resourcePubsubLiteTopicCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Topic: %s", err) @@ -261,14 +258,12 @@ func resourcePubsubLiteTopicRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("PubsubLiteTopic %q", d.Id())) @@ -337,7 +332,6 @@ func resourcePubsubLiteTopicUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Topic %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("partition_config") { @@ -373,7 +367,6 @@ func resourcePubsubLiteTopicUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -414,8 +407,6 @@ func resourcePubsubLiteTopicDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Topic %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -425,7 +416,6 @@ func resourcePubsubLiteTopicDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Topic") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_cluster.go index 5d3a833df7a..7f031dd370b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_cluster.go @@ -20,7 +20,6 @@ package redis import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -95,23 +94,6 @@ projects/{network_project_id_or_number}/global/networks/{network_id}.`, Description: `Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. Default value: "AUTH_MODE_DISABLED" Possible values: ["AUTH_MODE_UNSPECIFIED", "AUTH_MODE_IAM_AUTH", "AUTH_MODE_DISABLED"]`, Default: "AUTH_MODE_DISABLED", }, - "node_type": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"REDIS_SHARED_CORE_NANO", "REDIS_HIGHMEM_MEDIUM", "REDIS_HIGHMEM_XLARGE", "REDIS_STANDARD_SMALL", ""}), - Description: `The nodeType for the Redis cluster. -If not provided, REDIS_HIGHMEM_MEDIUM will be used as default Possible values: ["REDIS_SHARED_CORE_NANO", "REDIS_HIGHMEM_MEDIUM", "REDIS_HIGHMEM_XLARGE", "REDIS_STANDARD_SMALL"]`, - }, - "redis_configs": { - Type: schema.TypeMap, - Optional: true, - Description: `Configure Redis Cluster behavior using a subset of native Redis configuration parameters. -Please check Memorystore documentation for the list of supported parameters: -https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, "region": { Type: schema.TypeString, Computed: true, @@ -133,30 +115,6 @@ https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurati If not provided, encryption is disabled for the cluster. Default value: "TRANSIT_ENCRYPTION_MODE_DISABLED" Possible values: ["TRANSIT_ENCRYPTION_MODE_UNSPECIFIED", "TRANSIT_ENCRYPTION_MODE_DISABLED", "TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION"]`, Default: "TRANSIT_ENCRYPTION_MODE_DISABLED", }, - "zone_distribution_config": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Immutable. Zone distribution config for Memorystore Redis cluster.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "mode": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"MULTI_ZONE", "SINGLE_ZONE", ""}), - Description: `Immutable. The mode for zone distribution for Memorystore Redis cluster. -If not provided, MULTI_ZONE will be used as default Possible values: ["MULTI_ZONE", "SINGLE_ZONE"]`, - }, - "zone": { - Type: schema.TypeString, - Optional: true, - Description: `Immutable. The zone for single zone Memorystore Redis cluster.`, - }, - }, - }, - }, "create_time": { Type: schema.TypeString, Computed: true, @@ -203,11 +161,6 @@ projects/{network_project_id}/global/networks/{network_id}.`, }, }, }, - "precise_size_gb": { - Type: schema.TypeFloat, - Computed: true, - Description: `Output only. Redis memory precise size in GB for the entire cluster.`, - }, "psc_connections": { Type: schema.TypeList, Computed: true, @@ -317,18 +270,6 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("transit_encryption_mode"); !tpgresource.IsEmptyValue(reflect.ValueOf(transitEncryptionModeProp)) && (ok || !reflect.DeepEqual(v, transitEncryptionModeProp)) { obj["transitEncryptionMode"] = transitEncryptionModeProp } - nodeTypeProp, err := expandRedisClusterNodeType(d.Get("node_type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("node_type"); !tpgresource.IsEmptyValue(reflect.ValueOf(nodeTypeProp)) && (ok || !reflect.DeepEqual(v, nodeTypeProp)) { - obj["nodeType"] = nodeTypeProp - } - zoneDistributionConfigProp, err := expandRedisClusterZoneDistributionConfig(d.Get("zone_distribution_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("zone_distribution_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(zoneDistributionConfigProp)) && (ok || !reflect.DeepEqual(v, zoneDistributionConfigProp)) { - obj["zoneDistributionConfig"] = zoneDistributionConfigProp - } pscConfigsProp, err := expandRedisClusterPscConfigs(d.Get("psc_configs"), d, config) if err != nil { return err @@ -347,12 +288,6 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("shard_count"); !tpgresource.IsEmptyValue(reflect.ValueOf(shardCountProp)) && (ok || !reflect.DeepEqual(v, shardCountProp)) { obj["shardCount"] = shardCountProp } - redisConfigsProp, err := expandRedisClusterRedisConfigs(d.Get("redis_configs"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("redis_configs"); !tpgresource.IsEmptyValue(reflect.ValueOf(redisConfigsProp)) && (ok || !reflect.DeepEqual(v, redisConfigsProp)) { - obj["redisConfigs"] = redisConfigsProp - } url, err := tpgresource.ReplaceVars(d, config, "{{RedisBasePath}}projects/{{project}}/locations/{{region}}/clusters?clusterId={{name}}") if err != nil { @@ -373,7 +308,6 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -382,7 +316,6 @@ func resourceRedisClusterCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Cluster: %s", err) @@ -435,14 +368,12 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("RedisCluster %q", d.Id())) @@ -475,12 +406,6 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("transit_encryption_mode", flattenRedisClusterTransitEncryptionMode(res["transitEncryptionMode"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } - if err := d.Set("node_type", flattenRedisClusterNodeType(res["nodeType"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } - if err := d.Set("zone_distribution_config", flattenRedisClusterZoneDistributionConfig(res["zoneDistributionConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } if err := d.Set("discovery_endpoints", flattenRedisClusterDiscoveryEndpoints(res["discoveryEndpoints"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } @@ -496,15 +421,9 @@ func resourceRedisClusterRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("size_gb", flattenRedisClusterSizeGb(res["sizeGb"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } - if err := d.Set("precise_size_gb", flattenRedisClusterPreciseSizeGb(res["preciseSizeGb"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } if err := d.Set("shard_count", flattenRedisClusterShardCount(res["shardCount"], d, config)); err != nil { return fmt.Errorf("Error reading Cluster: %s", err) } - if err := d.Set("redis_configs", flattenRedisClusterRedisConfigs(res["redisConfigs"], d, config)); err != nil { - return fmt.Errorf("Error reading Cluster: %s", err) - } return nil } @@ -543,12 +462,6 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("shard_count"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, shardCountProp)) { obj["shardCount"] = shardCountProp } - redisConfigsProp, err := expandRedisClusterRedisConfigs(d.Get("redis_configs"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("redis_configs"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, redisConfigsProp)) { - obj["redisConfigs"] = redisConfigsProp - } url, err := tpgresource.ReplaceVars(d, config, "{{RedisBasePath}}projects/{{project}}/locations/{{region}}/clusters/{{name}}") if err != nil { @@ -556,7 +469,6 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Cluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("psc_configs") { @@ -570,10 +482,6 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error if d.HasChange("shard_count") { updateMask = append(updateMask, "shardCount") } - - if d.HasChange("redis_configs") { - updateMask = append(updateMask, "redisConfigs") - } // updateMask is a URL parameter but not present in the schema, so ReplaceVars // won't set it url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) @@ -596,7 +504,6 @@ func resourceRedisClusterUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -644,8 +551,6 @@ func resourceRedisClusterDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Cluster %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -655,7 +560,6 @@ func resourceRedisClusterDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Cluster") @@ -714,33 +618,6 @@ func flattenRedisClusterTransitEncryptionMode(v interface{}, d *schema.ResourceD return v } -func flattenRedisClusterNodeType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenRedisClusterZoneDistributionConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["mode"] = - flattenRedisClusterZoneDistributionConfigMode(original["mode"], d, config) - transformed["zone"] = - flattenRedisClusterZoneDistributionConfigZone(original["zone"], d, config) - return []interface{}{transformed} -} -func flattenRedisClusterZoneDistributionConfigMode(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenRedisClusterZoneDistributionConfigZone(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenRedisClusterDiscoveryEndpoints(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -937,10 +814,6 @@ func flattenRedisClusterSizeGb(v interface{}, d *schema.ResourceData, config *tr return v // let terraform core handle it otherwise } -func flattenRedisClusterPreciseSizeGb(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenRedisClusterShardCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -958,10 +831,6 @@ func flattenRedisClusterShardCount(v interface{}, d *schema.ResourceData, config return v // let terraform core handle it otherwise } -func flattenRedisClusterRedisConfigs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func expandRedisClusterAuthorizationMode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } @@ -970,44 +839,6 @@ func expandRedisClusterTransitEncryptionMode(v interface{}, d tpgresource.Terraf return v, nil } -func expandRedisClusterNodeType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandRedisClusterZoneDistributionConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMode, err := expandRedisClusterZoneDistributionConfigMode(original["mode"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMode); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["mode"] = transformedMode - } - - transformedZone, err := expandRedisClusterZoneDistributionConfigZone(original["zone"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedZone); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["zone"] = transformedZone - } - - return transformed, nil -} - -func expandRedisClusterZoneDistributionConfigMode(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandRedisClusterZoneDistributionConfigZone(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandRedisClusterPscConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) req := make([]interface{}, 0, len(l)) @@ -1041,14 +872,3 @@ func expandRedisClusterReplicaCount(v interface{}, d tpgresource.TerraformResour func expandRedisClusterShardCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } - -func expandRedisClusterRedisConfigs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_instance.go index 3a6dc620d4f..23f3c46fe41 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/redis/resource_redis_instance.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "strconv" @@ -280,12 +279,6 @@ resolution and up to nine fractional digits.`, }, }, }, - "maintenance_version": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: `The self service update maintenance version.`, - }, "persistence_config": { Type: schema.TypeList, Computed: true, @@ -652,12 +645,6 @@ func resourceRedisInstanceCreate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("maintenance_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(maintenancePolicyProp)) && (ok || !reflect.DeepEqual(v, maintenancePolicyProp)) { obj["maintenancePolicy"] = maintenancePolicyProp } - maintenanceVersionProp, err := expandRedisInstanceMaintenanceVersion(d.Get("maintenance_version"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("maintenance_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(maintenanceVersionProp)) && (ok || !reflect.DeepEqual(v, maintenanceVersionProp)) { - obj["maintenanceVersion"] = maintenanceVersionProp - } memorySizeGbProp, err := expandRedisInstanceMemorySizeGb(d.Get("memory_size_gb"), d, config) if err != nil { return err @@ -743,7 +730,6 @@ func resourceRedisInstanceCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -752,7 +738,6 @@ func resourceRedisInstanceCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -805,14 +790,12 @@ func resourceRedisInstanceRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("RedisInstance %q", d.Id())) @@ -887,9 +870,6 @@ func resourceRedisInstanceRead(d *schema.ResourceData, meta interface{}) error { if err := d.Set("maintenance_schedule", flattenRedisInstanceMaintenanceSchedule(res["maintenanceSchedule"], d, config)); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } - if err := d.Set("maintenance_version", flattenRedisInstanceMaintenanceVersion(res["maintenanceVersion"], d, config)); err != nil { - return fmt.Errorf("Error reading Instance: %s", err) - } if err := d.Set("memory_size_gb", flattenRedisInstanceMemorySizeGb(res["memorySizeGb"], d, config)); err != nil { return fmt.Errorf("Error reading Instance: %s", err) } @@ -988,12 +968,6 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error } else if v, ok := d.GetOkExists("maintenance_policy"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, maintenancePolicyProp)) { obj["maintenancePolicy"] = maintenancePolicyProp } - maintenanceVersionProp, err := expandRedisInstanceMaintenanceVersion(d.Get("maintenance_version"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("maintenance_version"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, maintenanceVersionProp)) { - obj["maintenanceVersion"] = maintenanceVersionProp - } memorySizeGbProp, err := expandRedisInstanceMemorySizeGb(d.Get("memory_size_gb"), d, config) if err != nil { return err @@ -1036,7 +1010,6 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("auth_enabled") { @@ -1059,10 +1032,6 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error updateMask = append(updateMask, "maintenancePolicy") } - if d.HasChange("maintenance_version") { - updateMask = append(updateMask, "maintenanceVersion") - } - if d.HasChange("memory_size_gb") { updateMask = append(updateMask, "memorySizeGb") } @@ -1104,7 +1073,6 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1138,8 +1106,6 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -1153,7 +1119,6 @@ func resourceRedisInstanceUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Instance %q: %s", d.Id(), err) @@ -1201,8 +1166,6 @@ func resourceRedisInstanceDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1212,7 +1175,6 @@ func resourceRedisInstanceDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") @@ -1520,10 +1482,6 @@ func flattenRedisInstanceMaintenanceScheduleScheduleDeadlineTime(v interface{}, return v } -func flattenRedisInstanceMaintenanceVersion(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenRedisInstanceMemorySizeGb(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { // Handles the string fixed64 format if strVal, ok := v.(string); ok { @@ -1968,10 +1926,6 @@ func expandRedisInstanceMaintenancePolicyWeeklyMaintenanceWindowStartTimeNanos(v return v, nil } -func expandRedisInstanceMaintenanceVersion(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandRedisInstanceMemorySizeGb(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_active_folder.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_active_folder.go index f2e344d7256..c8b7e642e57 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_active_folder.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_active_folder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" resourceManagerV3 "google.golang.org/api/cloudresourcemanager/v3" ) @@ -29,13 +28,6 @@ func DataSourceGoogleActiveFolder() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "api_method": { - Type: schema.TypeString, - Optional: true, - Description: "Provides the REST method through which to find the folder. LIST is recommended as it is strongly consistent.", - Default: "LIST", - ValidateFunc: verify.ValidateEnum([]string{"LIST", "SEARCH"}), - }, }, } } @@ -50,43 +42,24 @@ func dataSourceGoogleActiveFolderRead(d *schema.ResourceData, meta interface{}) var folderMatch *resourceManagerV3.Folder parent := d.Get("parent").(string) displayName := d.Get("display_name").(string) - apiMethod := d.Get("api_method").(string) - - if apiMethod == "LIST" { - token := "" - - for paginate := true; paginate; { - resp, err := config.NewResourceManagerV3Client(userAgent).Folders.List().Parent(parent).PageSize(300).PageToken(token).Do() - if err != nil { - return fmt.Errorf("error reading folder list: %s", err) - } + token := "" - for _, folder := range resp.Folders { - if folder.DisplayName == displayName && folder.State == "ACTIVE" { - if folderMatch != nil { - return fmt.Errorf("more than one matching folder found") - } - folderMatch = folder - } - } - token = resp.NextPageToken - paginate = token != "" - } - } else { - queryString := fmt.Sprintf("lifecycleState=ACTIVE AND parent=%s AND displayName=\"%s\"", parent, displayName) - searchRequest := config.NewResourceManagerV3Client(userAgent).Folders.Search() - searchRequest.Query(queryString) - searchResponse, err := searchRequest.Do() + for paginate := true; paginate; { + resp, err := config.NewResourceManagerV3Client(userAgent).Folders.List().Parent(parent).PageSize(300).PageToken(token).Do() if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Folder Not Found : %s", displayName)) + return fmt.Errorf("error reading folder list: %s", err) } - for _, folder := range searchResponse.Folders { - if folder.DisplayName == displayName { + for _, folder := range resp.Folders { + if folder.DisplayName == displayName && folder.State == "ACTIVE" { + if folderMatch != nil { + return fmt.Errorf("more than one matching folder found") + } folderMatch = folder - break } } + token = resp.NextPageToken + paginate = token != "" } if folderMatch == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_netblock_ip_ranges.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_netblock_ip_ranges.go index beb5e05776a..941d7690c5e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_netblock_ip_ranges.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/data_source_google_netblock_ip_ranges.go @@ -7,11 +7,8 @@ import ( "fmt" "io/ioutil" "net/http" - "net/netip" - "sort" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "go4.org/netipx" ) type googRanges struct { @@ -25,11 +22,6 @@ type prefixes struct { Ipv6Prefix string `json:"ipv6Prefix"` } -const ( - CLOUD_NETBLOCK_URL = "https://www.gstatic.com/ipranges/cloud.json" - GOOGLE_NETBLOCK_URL = "https://www.gstatic.com/ipranges/goog.json" -) - func DataSourceGoogleNetblockIpRanges() *schema.Resource { return &schema.Resource{ Read: dataSourceGoogleNetblockIpRangesRead, @@ -68,6 +60,7 @@ func dataSourceGoogleNetblockIpRangesRead(d *schema.ResourceData, meta interface // Dynamic ranges case "cloud-netblocks": // https://cloud.google.com/compute/docs/faq#find_ip_range + const CLOUD_NETBLOCK_URL = "https://www.gstatic.com/ipranges/cloud.json" CidrBlocks, err := getCidrBlocksFromUrl(CLOUD_NETBLOCK_URL) if err != nil { @@ -84,35 +77,12 @@ func dataSourceGoogleNetblockIpRangesRead(d *schema.ResourceData, meta interface } case "google-netblocks": // https://cloud.google.com/vpc/docs/configure-private-google-access?hl=en#ip-addr-defaults + const GOOGLE_NETBLOCK_URL = "https://www.gstatic.com/ipranges/goog.json" CidrBlocks, err := getCidrBlocksFromUrl(GOOGLE_NETBLOCK_URL) if err != nil { return err } - if err := d.Set("cidr_blocks", CidrBlocks["cidr_blocks"]); err != nil { - return fmt.Errorf("Error setting cidr_blocks: %s", err) - } - if err := d.Set("cidr_blocks_ipv4", CidrBlocks["cidr_blocks_ipv4"]); err != nil { - return fmt.Errorf("Error setting cidr_blocks_ipv4: %s", err) - } - if err := d.Set("cidr_blocks_ipv6", CidrBlocks["cidr_blocks_ipv6"]); err != nil { - return fmt.Errorf("Error setting cidr_blocks_ipv6: %s", err) - } - case "default-domains-netblocks": - // https: //cloud.google.com/vpc/docs/configure-private-google-access#ip-addr-defaults - googleBlocks, err := getCidrBlocksFromUrl(GOOGLE_NETBLOCK_URL) - if err != nil { - return err - } - cloudBlocks, err := getCidrBlocksFromUrl(CLOUD_NETBLOCK_URL) - if err != nil { - return err - } - CidrBlocks, err := getCidrsDifference(googleBlocks, cloudBlocks) - if err != nil { - return err - } - if err := d.Set("cidr_blocks", CidrBlocks["cidr_blocks"]); err != nil { return fmt.Errorf("Error setting cidr_blocks: %s", err) } @@ -231,42 +201,3 @@ func getCidrBlocksFromUrl(url string) (map[string][]string, error) { return cidrBlocks, nil } - -func getCidrsDifference(reference, excluded map[string][]string) (map[string][]string, error) { - result := make(map[string][]string) - - for blockName := range reference { - var ipSetBuilder netipx.IPSetBuilder - for _, cidr := range reference[blockName] { - net, err := netip.ParsePrefix(cidr) - if err != nil { - return result, err - } - ipSetBuilder.AddPrefix(net) - } - - for _, cidr := range excluded[blockName] { - net, err := netip.ParsePrefix(cidr) - if err != nil { - return result, err - } - ipSetBuilder.RemovePrefix(net) - } - - ipSet, err := ipSetBuilder.IPSet() - if err != nil { - return result, err - } - - var ipRangeStrings []string - for _, ipRange := range ipSet.Prefixes() { - ipRangeStrings = append(ipRangeStrings, ipRange.String()) - } - - sort.Strings(ipRangeStrings) - - result[blockName] = ipRangeStrings - } - - return result, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project.go index 8c3017559d6..f700ecd72c8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project.go @@ -122,7 +122,7 @@ func ResourceGoogleProject() *schema.Resource { "terraform_labels": { Type: schema.TypeMap, Computed: true, - Description: `(ReadOnly) The combination of labels configured directly on the resource and default labels configured on the provider.`, + Description: `The combination of labels configured directly on the resource and default labels configured on the provider.`, Elem: &schema.Schema{Type: schema.TypeString}, }, diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project_iam_member_remove.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project_iam_member_remove.go deleted file mode 100644 index e24c0cac373..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_project_iam_member_remove.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package resourcemanager - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - cloudresourcemanager "google.golang.org/api/cloudresourcemanager/v1" -) - -func ResourceGoogleProjectIamMemberRemove() *schema.Resource { - return &schema.Resource{ - Create: resourceGoogleProjectIamMemberRemoveCreate, - Read: resourceGoogleProjectIamMemberRemoveRead, - Delete: resourceGoogleProjectIamMemberRemoveDelete, - - Schema: map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - Description: `The project id of the target project.`, - }, - "role": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - Description: `The target role that should be removed.`, - }, - "member": { - Type: schema.TypeString, - ForceNew: true, - Required: true, - Description: `The IAM principal that should not have the target role.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceGoogleProjectIamMemberRemoveCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - - project := d.Get("project").(string) - role := d.Get("role").(string) - member := d.Get("member").(string) - - found := false - iamPolicy, err := config.NewResourceManagerClient(config.UserAgent).Projects.GetIamPolicy(project, - &cloudresourcemanager.GetIamPolicyRequest{ - Options: &cloudresourcemanager.GetPolicyOptions{ - RequestedPolicyVersion: tpgiamresource.IamPolicyVersion, - }, - }).Do() - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, d.Id()) - } - - for i := 0; i < len(iamPolicy.Bindings); i++ { - if role == iamPolicy.Bindings[i].Role { - for j := 0; j < len(iamPolicy.Bindings[i].Members); j++ { - if member == iamPolicy.Bindings[i].Members[j] { - found = true - iamPolicy.Bindings[i].Members = append(iamPolicy.Bindings[i].Members[:j], iamPolicy.Bindings[i].Members[j+1:]...) - break - } - } - } - } - - if found == false { - fmt.Printf("[DEBUG] Could not find Member %s with the corresponding role %s. No removal necessary", member, role) - } else { - updateRequest := &cloudresourcemanager.SetIamPolicyRequest{ - Policy: iamPolicy, - UpdateMask: "bindings", - } - _, err = config.NewResourceManagerClient(config.UserAgent).Projects.SetIamPolicy(project, updateRequest).Do() - if err != nil { - return fmt.Errorf("cannot update IAM policy on project %s: %v", project, err) - } - } - - d.SetId(fmt.Sprintf("%s/%s/%s", project, member, role)) - - return resourceGoogleProjectIamMemberRemoveRead(d, meta) -} - -func resourceGoogleProjectIamMemberRemoveRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - - project := d.Get("project").(string) - role := d.Get("role").(string) - member := d.Get("member").(string) - - found := false - iamPolicy, err := config.NewResourceManagerClient(config.UserAgent).Projects.GetIamPolicy(project, - &cloudresourcemanager.GetIamPolicyRequest{ - Options: &cloudresourcemanager.GetPolicyOptions{ - RequestedPolicyVersion: tpgiamresource.IamPolicyVersion, - }, - }).Do() - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, d.Id()) - } - - for i := 0; i < len(iamPolicy.Bindings); i++ { - if role == iamPolicy.Bindings[i].Role { - for j := 0; j < len(iamPolicy.Bindings[i].Members); j++ { - if member == iamPolicy.Bindings[i].Members[j] { - found = true - break - } - } - } - } - - if found { - fmt.Printf("[DEBUG] found membership in project's policy %v, removing from state", d.Id()) - d.SetId("") - } - - return nil -} - -func resourceGoogleProjectIamMemberRemoveDelete(d *schema.ResourceData, meta interface{}) error { - fmt.Printf("[DEBUG] clearing resource %v from state", d.Id()) - d.SetId("") - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account.go index 30cf8684213..3dc68718fa9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account.go @@ -121,53 +121,61 @@ func resourceGoogleServiceAccountCreate(d *schema.ResourceData, meta interface{} ServiceAccount: sa, } - sa, err = config.NewIamClient(userAgent).Projects.ServiceAccounts.Create("projects/"+project, r).Do() + iamClient := config.NewIamClient(userAgent) + sa, err = iamClient.Projects.ServiceAccounts.Create("projects/"+project, r).Do() if err != nil { gerr, ok := err.(*googleapi.Error) alreadyExists := ok && gerr.Code == 409 && d.Get("create_ignore_already_exists").(bool) if alreadyExists { - sa = &iam.ServiceAccount{ - Name: fmt.Sprintf("projects/%s/serviceAccounts/%s@%s.iam.gserviceaccount.com", project, aid, project), - } + fullServiceAccountName := fmt.Sprintf("projects/%s/serviceAccounts/%s@%s.iam.gserviceaccount.com", project, aid, project) + err = transport_tpg.Retry(transport_tpg.RetryOptions{ + RetryFunc: func() (operr error) { + sa, saerr := iamClient.Projects.ServiceAccounts.Get(fullServiceAccountName).Do() + + if saerr != nil { + return saerr + } + + d.SetId(sa.Name) + return populateResourceData(d, sa) + }, + Timeout: d.Timeout(schema.TimeoutCreate), + ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{ + transport_tpg.IsNotFoundRetryableError("service account creation"), + }, + }) + + return nil } else { return fmt.Errorf("Error creating service account: %s", err) } } d.SetId(sa.Name) - - err = transport_tpg.Retry(transport_tpg.RetryOptions{ - RetryFunc: func() (operr error) { - _, saerr := config.NewIamClient(userAgent).Projects.ServiceAccounts.Get(d.Id()).Do() - return saerr - }, - Timeout: d.Timeout(schema.TimeoutCreate), - ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{ - transport_tpg.IsNotFoundRetryableError("service account creation"), - transport_tpg.IsForbiddenIamServiceAccountRetryableError("service account creation"), - }, - }) - - if err != nil { - return fmt.Errorf("Error reading service account after creation: %s", err) - } + populateResourceData(d, sa) // We poll until the resource is found due to eventual consistency issue - // on part of the api https://cloud.google.com/iam/docs/overview#consistency - err = transport_tpg.PollingWaitTime(resourceServiceAccountPollRead(d, meta), transport_tpg.PollCheckForExistence, "Creating Service Account", d.Timeout(schema.TimeoutCreate), 1) - - if err != nil { - return err - } + // on part of the api https://cloud.google.com/iam/docs/overview#consistency. + // Wait for at least 3 successful responses in a row to ensure result is consistent. + // IAM API returns 403 when the queried SA is not found, so we must ignore both 404 & 403 errors + transport_tpg.PollingWaitTime( + resourceServiceAccountPollRead(d, meta), + transport_tpg.PollCheckForExistence, + "Creating Service Account", + d.Timeout(schema.TimeoutCreate), + 3, // Number of consecutive occurences. + ) // We can't guarantee complete consistency even after polling, // so sleep for some additional time to reduce the likelihood of // eventual consistency failures. time.Sleep(10 * time.Second) - return resourceGoogleServiceAccountRead(d, meta) + return nil } +// PollReadFunc for checking Service Account existence. +// If resourceData is not nil, it will be updated with the response. func resourceServiceAccountPollRead(d *schema.ResourceData, meta interface{}) transport_tpg.PollReadFunc { return func() (map[string]interface{}, error) { config := meta.(*transport_tpg.Config) @@ -199,6 +207,10 @@ func resourceGoogleServiceAccountRead(d *schema.ResourceData, meta interface{}) return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("Service Account %q", d.Id())) } + return populateResourceData(d, sa) +} + +func populateResourceData(d *schema.ResourceData, sa *iam.ServiceAccount) error { if err := d.Set("email", sa.Email); err != nil { return fmt.Errorf("Error setting email: %s", err) } @@ -273,16 +285,21 @@ func resourceGoogleServiceAccountUpdate(d *schema.ResourceData, meta interface{} if err != nil { return err } + + if len(updateMask) == 0 { + return nil + } + } else if d.HasChange("disabled") && d.Get("disabled").(bool) { _, err = config.NewIamClient(userAgent).Projects.ServiceAccounts.Disable(d.Id(), &iam.DisableServiceAccountRequest{}).Do() if err != nil { return err } - } - if len(updateMask) == 0 { - return nil + if len(updateMask) == 0 { + return nil + } } _, err = config.NewIamClient(userAgent).Projects.ServiceAccounts.Patch(d.Id(), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account_key.go index 771c8c9e05c..6a08d9d3302 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_google_service_account_key.go @@ -147,12 +147,6 @@ func resourceGoogleServiceAccountKeyCreate(d *schema.ResourceData, meta interfac if err != nil { return err } - - // We can't guarantee complete consistency even after waiting on - // the results, so sleep for some additional time to reduce the - // likelihood of eventual consistency failures. - time.Sleep(10 * time.Second) - return resourceGoogleServiceAccountKeyRead(d, meta) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_resource_manager_lien.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_resource_manager_lien.go index 892fb8aeb3a..cfb14923c5f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_resource_manager_lien.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/resource_resource_manager_lien.go @@ -20,7 +20,6 @@ package resourcemanager import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -145,7 +144,6 @@ func resourceResourceManagerLienCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -154,7 +152,6 @@ func resourceResourceManagerLienCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Lien: %s", err) @@ -206,14 +203,12 @@ func resourceResourceManagerLienRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ResourceManagerLien %q", d.Id())) @@ -286,7 +281,6 @@ func resourceResourceManagerLienDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) // log the old URL to make the ineffassign linter happy // in theory, we should find a way to disable the default URL and not construct // both, but that's a problem for another day. Today, we cheat. @@ -305,7 +299,6 @@ func resourceResourceManagerLienDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Lien") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/service_account_waiter.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/service_account_waiter.go index 172f873b66b..cc17f6f6c9f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/service_account_waiter.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/resourcemanager/service_account_waiter.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "google.golang.org/api/googleapi" "google.golang.org/api/iam/v1" ) @@ -17,7 +17,7 @@ type ServiceAccountKeyWaiter struct { KeyName string } -func (w *ServiceAccountKeyWaiter) RefreshFunc() retry.StateRefreshFunc { +func (w *ServiceAccountKeyWaiter) RefreshFunc() resource.StateRefreshFunc { return func() (interface{}, string, error) { var err error var sak *iam.ServiceAccountKey @@ -42,7 +42,7 @@ func ServiceAccountKeyWaitTime(client *iam.ProjectsServiceAccountsKeysService, k KeyName: keyName, } - c := &retry.StateChangeConf{ + c := &resource.StateChangeConf{ Pending: []string{"PENDING"}, Target: []string{"DONE"}, Refresh: w.RefreshFunc(), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/iam_secret_manager_secret.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/iam_secret_manager_secret.go index 6688b1bcb07..22774058466 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/iam_secret_manager_secret.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/iam_secret_manager_secret.go @@ -133,10 +133,6 @@ func (u *SecretManagerSecretIamUpdater) GetResourceIamPolicy() (*cloudresourcema return nil, err } var obj map[string]interface{} - url, err = transport_tpg.AddQueryParams(url, map[string]string{"options.requestedPolicyVersion": fmt.Sprintf("%d", tpgiamresource.IamPolicyVersion)}) - if err != nil { - return nil, err - } userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret.go index a5cbcffa5d0..2f433a42872 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -287,15 +286,6 @@ An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "version_destroy_ttl": { - Type: schema.TypeString, - Optional: true, - Description: `Secret Version TTL after destruction request. -This is a part of the delayed delete feature on Secret Version. -For secret with versionDestroyTtl>0, version destruction doesn't happen immediately -on calling destroy instead the version goes to a disabled state and -the actual destruction happens after this TTL expires.`, - }, "create_time": { Type: schema.TypeString, Computed: true, @@ -351,12 +341,6 @@ func resourceSecretManagerSecretCreate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("version_aliases"); !tpgresource.IsEmptyValue(reflect.ValueOf(versionAliasesProp)) && (ok || !reflect.DeepEqual(v, versionAliasesProp)) { obj["versionAliases"] = versionAliasesProp } - versionDestroyTtlProp, err := expandSecretManagerSecretVersionDestroyTtl(d.Get("version_destroy_ttl"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("version_destroy_ttl"); !tpgresource.IsEmptyValue(reflect.ValueOf(versionDestroyTtlProp)) && (ok || !reflect.DeepEqual(v, versionDestroyTtlProp)) { - obj["versionDestroyTtl"] = versionDestroyTtlProp - } replicationProp, err := expandSecretManagerSecretReplication(d.Get("replication"), d, config) if err != nil { return err @@ -419,7 +403,6 @@ func resourceSecretManagerSecretCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -428,7 +411,6 @@ func resourceSecretManagerSecretCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Secret: %s", err) @@ -474,14 +456,12 @@ func resourceSecretManagerSecretRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecretManagerSecret %q", d.Id())) @@ -506,9 +486,6 @@ func resourceSecretManagerSecretRead(d *schema.ResourceData, meta interface{}) e if err := d.Set("version_aliases", flattenSecretManagerSecretVersionAliases(res["versionAliases"], d, config)); err != nil { return fmt.Errorf("Error reading Secret: %s", err) } - if err := d.Set("version_destroy_ttl", flattenSecretManagerSecretVersionDestroyTtl(res["versionDestroyTtl"], d, config)); err != nil { - return fmt.Errorf("Error reading Secret: %s", err) - } if err := d.Set("replication", flattenSecretManagerSecretReplication(res["replication"], d, config)); err != nil { return fmt.Errorf("Error reading Secret: %s", err) } @@ -556,12 +533,6 @@ func resourceSecretManagerSecretUpdate(d *schema.ResourceData, meta interface{}) } else if v, ok := d.GetOkExists("version_aliases"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, versionAliasesProp)) { obj["versionAliases"] = versionAliasesProp } - versionDestroyTtlProp, err := expandSecretManagerSecretVersionDestroyTtl(d.Get("version_destroy_ttl"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("version_destroy_ttl"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, versionDestroyTtlProp)) { - obj["versionDestroyTtl"] = versionDestroyTtlProp - } topicsProp, err := expandSecretManagerSecretTopics(d.Get("topics"), d, config) if err != nil { return err @@ -605,17 +576,12 @@ func resourceSecretManagerSecretUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Secret %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("version_aliases") { updateMask = append(updateMask, "versionAliases") } - if d.HasChange("version_destroy_ttl") { - updateMask = append(updateMask, "versionDestroyTtl") - } - if d.HasChange("topics") { updateMask = append(updateMask, "topics") } @@ -684,7 +650,6 @@ func resourceSecretManagerSecretUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -725,8 +690,6 @@ func resourceSecretManagerSecretDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Secret %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -736,7 +699,6 @@ func resourceSecretManagerSecretDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Secret") @@ -808,10 +770,6 @@ func flattenSecretManagerSecretVersionAliases(v interface{}, d *schema.ResourceD return v } -func flattenSecretManagerSecretVersionDestroyTtl(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenSecretManagerSecretReplication(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -990,10 +948,6 @@ func expandSecretManagerSecretVersionAliases(v interface{}, d tpgresource.Terraf return m, nil } -func expandSecretManagerSecretVersionDestroyTtl(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandSecretManagerSecretReplication(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { l := v.([]interface{}) if len(l) == 0 || l[0] == nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret_version.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret_version.go index d0217d2662e..953c34cb4c4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret_version.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/secretmanager/resource_secret_manager_secret_version.go @@ -21,7 +21,6 @@ import ( "encoding/base64" "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -152,7 +151,6 @@ func resourceSecretManagerSecretVersionCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -161,7 +159,6 @@ func resourceSecretManagerSecretVersionCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SecretVersion: %s", err) @@ -216,7 +213,6 @@ func resourceSecretManagerSecretVersionRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) // Explicitly set the field to default value if unset if _, ok := d.GetOkExists("is_secret_data_base64"); !ok { if err := d.Set("is_secret_data_base64", false); err != nil { @@ -229,7 +225,6 @@ func resourceSecretManagerSecretVersionRead(d *schema.ResourceData, meta interfa Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecretManagerSecretVersion %q", d.Id())) @@ -319,7 +314,6 @@ func resourceSecretManagerSecretVersionDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) deletionPolicy := d.Get("deletion_policy") if deletionPolicy == "ABANDON" { @@ -340,7 +334,6 @@ func resourceSecretManagerSecretVersionDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SecretVersion") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/iam_secure_source_manager_repository.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/iam_secure_source_manager_repository.go deleted file mode 100644 index a32203fdc1f..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/iam_secure_source_manager_repository.go +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securesourcemanager - -import ( - "fmt" - - "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/cloudresourcemanager/v1" - - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -var SecureSourceManagerRepositoryIamSchema = map[string]*schema.Schema{ - "project": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "location": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - }, - "repository_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - }, -} - -type SecureSourceManagerRepositoryIamUpdater struct { - project string - location string - repositoryId string - d tpgresource.TerraformResourceData - Config *transport_tpg.Config -} - -func SecureSourceManagerRepositoryIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - if err := d.Set("project", project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - } - values["project"] = project - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - if err := d.Set("location", location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - } - values["location"] = location - if v, ok := d.GetOk("repository_id"); ok { - values["repository_id"] = v.(string) - } - - // We may have gotten either a long or short name, so attempt to parse long name if possible - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/repositories/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Get("repository_id").(string)) - if err != nil { - return nil, err - } - - for k, v := range m { - values[k] = v - } - - u := &SecureSourceManagerRepositoryIamUpdater{ - project: values["project"], - location: values["location"], - repositoryId: values["repository_id"], - d: d, - Config: config, - } - - if err := d.Set("project", u.project); err != nil { - return nil, fmt.Errorf("Error setting project: %s", err) - } - if err := d.Set("location", u.location); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - if err := d.Set("repository_id", u.GetResourceId()); err != nil { - return nil, fmt.Errorf("Error setting repository_id: %s", err) - } - - return u, nil -} - -func SecureSourceManagerRepositoryIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { - values := make(map[string]string) - - project, _ := tpgresource.GetProject(d, config) - if project != "" { - values["project"] = project - } - - location, _ := tpgresource.GetLocation(d, config) - if location != "" { - values["location"] = location - } - - m, err := tpgresource.GetImportIdQualifiers([]string{"projects/(?P[^/]+)/locations/(?P[^/]+)/repositories/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)/(?P[^/]+)", "(?P[^/]+)"}, d, config, d.Id()) - if err != nil { - return err - } - - for k, v := range m { - values[k] = v - } - - u := &SecureSourceManagerRepositoryIamUpdater{ - project: values["project"], - location: values["location"], - repositoryId: values["repository_id"], - d: d, - Config: config, - } - if err := d.Set("repository_id", u.GetResourceId()); err != nil { - return fmt.Errorf("Error setting repository_id: %s", err) - } - d.SetId(u.GetResourceId()) - return nil -} - -func (u *SecureSourceManagerRepositoryIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { - url, err := u.qualifyRepositoryUrl("getIamPolicy") - if err != nil { - return nil, err - } - - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return nil, err - } - var obj map[string]interface{} - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return nil, err - } - - policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "GET", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - }) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - out := &cloudresourcemanager.Policy{} - err = tpgresource.Convert(policy, out) - if err != nil { - return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) - } - - return out, nil -} - -func (u *SecureSourceManagerRepositoryIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { - json, err := tpgresource.ConvertToMap(policy) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - obj["policy"] = json - - url, err := u.qualifyRepositoryUrl("setIamPolicy") - if err != nil { - return err - } - project, err := tpgresource.GetProject(u.d, u.Config) - if err != nil { - return err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "POST", - Project: project, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: u.d.Timeout(schema.TimeoutCreate), - }) - if err != nil { - return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - return nil -} - -func (u *SecureSourceManagerRepositoryIamUpdater) qualifyRepositoryUrl(methodIdentifier string) (string, error) { - urlTemplate := fmt.Sprintf("{{SecureSourceManagerBasePath}}%s:%s", fmt.Sprintf("projects/%s/locations/%s/repositories/%s", u.project, u.location, u.repositoryId), methodIdentifier) - url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) - if err != nil { - return "", err - } - return url, nil -} - -func (u *SecureSourceManagerRepositoryIamUpdater) GetResourceId() string { - return fmt.Sprintf("projects/%s/locations/%s/repositories/%s", u.project, u.location, u.repositoryId) -} - -func (u *SecureSourceManagerRepositoryIamUpdater) GetMutexKey() string { - return fmt.Sprintf("iam-securesourcemanager-repository-%s", u.GetResourceId()) -} - -func (u *SecureSourceManagerRepositoryIamUpdater) DescribeResource() string { - return fmt.Sprintf("securesourcemanager repository %q", u.GetResourceId()) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_instance.go index 55d891a25bc..08b7e773a5f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_instance.go @@ -20,7 +20,6 @@ package securesourcemanager import ( "fmt" "log" - "net/http" "reflect" "time" @@ -240,7 +239,6 @@ func resourceSecureSourceManagerInstanceCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -249,7 +247,6 @@ func resourceSecureSourceManagerInstanceCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -302,14 +299,12 @@ func resourceSecureSourceManagerInstanceRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecureSourceManagerInstance %q", d.Id())) @@ -388,8 +383,6 @@ func resourceSecureSourceManagerInstanceDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -399,7 +392,6 @@ func resourceSecureSourceManagerInstanceDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_repository.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_repository.go deleted file mode 100644 index 670475829b3..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_repository.go +++ /dev/null @@ -1,517 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securesourcemanager - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceSecureSourceManagerRepository() *schema.Resource { - return &schema.Resource{ - Create: resourceSecureSourceManagerRepositoryCreate, - Read: resourceSecureSourceManagerRepositoryRead, - Delete: resourceSecureSourceManagerRepositoryDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSecureSourceManagerRepositoryImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "instance": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.ProjectNumberDiffSuppress, - Description: `The name of the instance in which the repository is hosted.`, - }, - "location": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The location for the Repository.`, - }, - "repository_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The ID for the Repository.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Description of the repository, which cannot exceed 500 characters.`, - }, - "initial_config": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `Initial configurations for the repository.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "default_branch": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Default branch name of the repository.`, - }, - "gitignores": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `List of gitignore template names user can choose from. -Valid values can be viewed at https://cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories#initialconfig.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - "license": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `License template name user can choose from. -Valid values can be viewed at https://cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories#initialconfig.`, - }, - "readme": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `README template name. -Valid values can be viewed at https://cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.repositories#initialconfig.`, - }, - }, - }, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the repository was created in UTC.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The resource name for the Repository.`, - }, - "uid": { - Type: schema.TypeString, - Computed: true, - Description: `Unique identifier of the repository.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `Time the repository was updated in UTC.`, - }, - "uris": { - Type: schema.TypeList, - Computed: true, - Description: `URIs for the repository.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "api": { - Type: schema.TypeString, - Computed: true, - Description: `API is the URI for API access.`, - }, - "git_https": { - Type: schema.TypeString, - Computed: true, - Description: `git_https is the git HTTPS URI for git operations.`, - }, - "html": { - Type: schema.TypeString, - Computed: true, - Description: `HTML is the URI for the user to view the repository in a browser.`, - }, - }, - }, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSecureSourceManagerRepositoryCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandSecureSourceManagerRepositoryDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - instanceProp, err := expandSecureSourceManagerRepositoryInstance(d.Get("instance"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("instance"); !tpgresource.IsEmptyValue(reflect.ValueOf(instanceProp)) && (ok || !reflect.DeepEqual(v, instanceProp)) { - obj["instance"] = instanceProp - } - initialConfigProp, err := expandSecureSourceManagerRepositoryInitialConfig(d.Get("initial_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("initial_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(initialConfigProp)) && (ok || !reflect.DeepEqual(v, initialConfigProp)) { - obj["initialConfig"] = initialConfigProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecureSourceManagerBasePath}}projects/{{project}}/locations/{{location}}/repositories?repository_id={{repository_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new Repository: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Repository: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating Repository: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = SecureSourceManagerOperationWaitTime( - config, res, project, "Creating Repository", userAgent, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to create Repository: %s", err) - } - - log.Printf("[DEBUG] Finished creating Repository %q: %#v", d.Id(), res) - - return resourceSecureSourceManagerRepositoryRead(d, meta) -} - -func resourceSecureSourceManagerRepositoryRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecureSourceManagerBasePath}}projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Repository: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecureSourceManagerRepository %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - - if err := d.Set("name", flattenSecureSourceManagerRepositoryName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - if err := d.Set("description", flattenSecureSourceManagerRepositoryDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - if err := d.Set("instance", flattenSecureSourceManagerRepositoryInstance(res["instance"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - if err := d.Set("uid", flattenSecureSourceManagerRepositoryUid(res["uid"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - if err := d.Set("create_time", flattenSecureSourceManagerRepositoryCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - if err := d.Set("update_time", flattenSecureSourceManagerRepositoryUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - if err := d.Set("uris", flattenSecureSourceManagerRepositoryUris(res["uris"], d, config)); err != nil { - return fmt.Errorf("Error reading Repository: %s", err) - } - - return nil -} - -func resourceSecureSourceManagerRepositoryDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for Repository: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{SecureSourceManagerBasePath}}projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting Repository %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "Repository") - } - - err = SecureSourceManagerOperationWaitTime( - config, res, project, "Deleting Repository", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting Repository %q: %#v", d.Id(), res) - return nil -} - -func resourceSecureSourceManagerRepositoryImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/repositories/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenSecureSourceManagerRepositoryName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryInstance(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryUid(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryUris(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["html"] = - flattenSecureSourceManagerRepositoryUrisHtml(original["html"], d, config) - transformed["git_https"] = - flattenSecureSourceManagerRepositoryUrisGitHttps(original["gitHttps"], d, config) - transformed["api"] = - flattenSecureSourceManagerRepositoryUrisApi(original["api"], d, config) - return []interface{}{transformed} -} -func flattenSecureSourceManagerRepositoryUrisHtml(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryUrisGitHttps(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecureSourceManagerRepositoryUrisApi(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSecureSourceManagerRepositoryDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecureSourceManagerRepositoryInstance(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecureSourceManagerRepositoryInitialConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedDefaultBranch, err := expandSecureSourceManagerRepositoryInitialConfigDefaultBranch(original["default_branch"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDefaultBranch); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["defaultBranch"] = transformedDefaultBranch - } - - transformedGitignores, err := expandSecureSourceManagerRepositoryInitialConfigGitignores(original["gitignores"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedGitignores); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["gitignores"] = transformedGitignores - } - - transformedLicense, err := expandSecureSourceManagerRepositoryInitialConfigLicense(original["license"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLicense); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["license"] = transformedLicense - } - - transformedReadme, err := expandSecureSourceManagerRepositoryInitialConfigReadme(original["readme"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedReadme); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["readme"] = transformedReadme - } - - return transformed, nil -} - -func expandSecureSourceManagerRepositoryInitialConfigDefaultBranch(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecureSourceManagerRepositoryInitialConfigGitignores(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecureSourceManagerRepositoryInitialConfigLicense(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecureSourceManagerRepositoryInitialConfigReadme(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_repository_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_repository_sweeper.go deleted file mode 100644 index edae15d7742..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager/resource_secure_source_manager_repository_sweeper.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securesourcemanager - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SecureSourceManagerRepository", testSweepSecureSourceManagerRepository) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSecureSourceManagerRepository(region string) error { - resourceName := "SecureSourceManagerRepository" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://securesourcemanager.googleapis.com/v1/projects/{{project}}/locations/{{location}}/repositories?repository_id={{repository_id}}", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["repositories"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - var name string - // Id detected in the delete URL, attempt to use id. - if obj["id"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["id"].(string)) - } else if obj["name"] != nil { - name = tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - } else { - log.Printf("[INFO][SWEEPER_LOG] %s resource name and id were nil", resourceName) - return nil - } - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://securesourcemanager.googleapis.com/v1/projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go index 6c1dc395ba6..b1f7fda866c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_event_threat_detection_custom_module.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -161,7 +160,6 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleCreate(d *schema.Reso billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -170,7 +168,6 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleCreate(d *schema.Reso UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating EventThreatDetectionCustomModule: %s", err) @@ -210,14 +207,12 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleRead(d *schema.Resour billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterEventThreatDetectionCustomModule %q", d.Id())) @@ -290,7 +285,6 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleUpdate(d *schema.Reso } log.Printf("[DEBUG] Updating EventThreatDetectionCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("config") { @@ -326,7 +320,6 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleUpdate(d *schema.Reso UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -368,8 +361,6 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleDelete(d *schema.Reso billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting EventThreatDetectionCustomModule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -379,7 +370,6 @@ func resourceSecurityCenterEventThreatDetectionCustomModuleDelete(d *schema.Reso UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "EventThreatDetectionCustomModule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_folder_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_folder_custom_module.go index 806c14f0102..45f1e51c94a 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_folder_custom_module.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_folder_custom_module.go @@ -20,7 +20,6 @@ package securitycenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -292,7 +291,6 @@ func resourceSecurityCenterFolderCustomModuleCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -301,7 +299,6 @@ func resourceSecurityCenterFolderCustomModuleCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FolderCustomModule: %s", err) @@ -341,14 +338,12 @@ func resourceSecurityCenterFolderCustomModuleRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterFolderCustomModule %q", d.Id())) @@ -415,7 +410,6 @@ func resourceSecurityCenterFolderCustomModuleUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating FolderCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enablement_state") { @@ -447,7 +441,6 @@ func resourceSecurityCenterFolderCustomModuleUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -489,8 +482,6 @@ func resourceSecurityCenterFolderCustomModuleDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FolderCustomModule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -500,7 +491,6 @@ func resourceSecurityCenterFolderCustomModuleDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FolderCustomModule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_mute_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_mute_config.go index 6046bf2add0..8d8fb6d4e4b 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_mute_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_mute_config.go @@ -20,7 +20,6 @@ package securitycenter import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -145,7 +144,6 @@ func resourceSecurityCenterMuteConfigCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -154,7 +152,6 @@ func resourceSecurityCenterMuteConfigCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating MuteConfig: %s", err) @@ -194,14 +191,12 @@ func resourceSecurityCenterMuteConfigRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterMuteConfig %q", d.Id())) @@ -258,7 +253,6 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating MuteConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -290,7 +284,6 @@ func resourceSecurityCenterMuteConfigUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -325,8 +318,6 @@ func resourceSecurityCenterMuteConfigDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting MuteConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -336,7 +327,6 @@ func resourceSecurityCenterMuteConfigDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "MuteConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_notification_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_notification_config.go index 3bdd8045c8f..e30fdc23088 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_notification_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_notification_config.go @@ -20,7 +20,6 @@ package securitycenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -171,7 +170,6 @@ func resourceSecurityCenterNotificationConfigCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -180,7 +178,6 @@ func resourceSecurityCenterNotificationConfigCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NotificationConfig: %s", err) @@ -238,14 +235,12 @@ func resourceSecurityCenterNotificationConfigRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterNotificationConfig %q", d.Id())) @@ -305,7 +300,6 @@ func resourceSecurityCenterNotificationConfigUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating NotificationConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -341,7 +335,6 @@ func resourceSecurityCenterNotificationConfigUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -376,8 +369,6 @@ func resourceSecurityCenterNotificationConfigDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NotificationConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -387,7 +378,6 @@ func resourceSecurityCenterNotificationConfigDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NotificationConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_organization_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_organization_custom_module.go index 513a13058da..a0fd519729f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_organization_custom_module.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_organization_custom_module.go @@ -20,7 +20,6 @@ package securitycenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -292,7 +291,6 @@ func resourceSecurityCenterOrganizationCustomModuleCreate(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -301,7 +299,6 @@ func resourceSecurityCenterOrganizationCustomModuleCreate(d *schema.ResourceData UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating OrganizationCustomModule: %s", err) @@ -341,14 +338,12 @@ func resourceSecurityCenterOrganizationCustomModuleRead(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterOrganizationCustomModule %q", d.Id())) @@ -415,7 +410,6 @@ func resourceSecurityCenterOrganizationCustomModuleUpdate(d *schema.ResourceData } log.Printf("[DEBUG] Updating OrganizationCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enablement_state") { @@ -447,7 +441,6 @@ func resourceSecurityCenterOrganizationCustomModuleUpdate(d *schema.ResourceData UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -489,8 +482,6 @@ func resourceSecurityCenterOrganizationCustomModuleDelete(d *schema.ResourceData billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting OrganizationCustomModule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -500,7 +491,6 @@ func resourceSecurityCenterOrganizationCustomModuleDelete(d *schema.ResourceData UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "OrganizationCustomModule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_project_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_project_custom_module.go index 9f2c4b55118..db2fc1e9730 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_project_custom_module.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_project_custom_module.go @@ -20,7 +20,6 @@ package securitycenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -303,7 +302,6 @@ func resourceSecurityCenterProjectCustomModuleCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -312,7 +310,6 @@ func resourceSecurityCenterProjectCustomModuleCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ProjectCustomModule: %s", err) @@ -358,14 +355,12 @@ func resourceSecurityCenterProjectCustomModuleRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterProjectCustomModule %q", d.Id())) @@ -442,7 +437,6 @@ func resourceSecurityCenterProjectCustomModuleUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating ProjectCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enablement_state") { @@ -474,7 +468,6 @@ func resourceSecurityCenterProjectCustomModuleUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -522,8 +515,6 @@ func resourceSecurityCenterProjectCustomModuleDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ProjectCustomModule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -533,7 +524,6 @@ func resourceSecurityCenterProjectCustomModuleDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ProjectCustomModule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_source.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_source.go index 02e9294c9a3..fb67eb8e961 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_source.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenter/resource_scc_source.go @@ -20,7 +20,6 @@ package securitycenter import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -119,7 +118,6 @@ func resourceSecurityCenterSourceCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -128,7 +126,6 @@ func resourceSecurityCenterSourceCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Source: %s", err) @@ -186,14 +183,12 @@ func resourceSecurityCenterSourceRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterSource %q", d.Id())) @@ -241,7 +236,6 @@ func resourceSecurityCenterSourceUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Source %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -273,7 +267,6 @@ func resourceSecurityCenterSourceUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go deleted file mode 100644 index 2182e24a4a9..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module.go +++ /dev/null @@ -1,983 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule() *schema.Resource { - return &schema.Resource{ - Create: resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCreate, - Read: resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRead, - Update: resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleUpdate, - Delete: resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "folder": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Numerical ID of the parent folder.`, - }, - "custom_config": { - Type: schema.TypeList, - Optional: true, - Description: `The user specified custom configuration for the module.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "custom_output": { - Type: schema.TypeList, - Optional: true, - Description: `Custom output properties.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "properties": { - Type: schema.TypeList, - Optional: true, - Description: `A list of custom output properties to add to the finding.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - Description: `Name of the property for the custom output.`, - }, - "value_expression": { - Type: schema.TypeList, - Optional: true, - Description: `The CEL expression for the custom output. A resource property can be specified -to return the value of the property or a text string enclosed in quotation marks.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the expression. This is a longer text which describes the -expression, e.g. when hovered over it in a UI.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `String indicating the location of the expression for error reporting, e.g. a -file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Title for the expression, i.e. a short string describing its purpose. This can -be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Text that describes the vulnerability or misconfiguration that the custom -module detects. This explanation is returned with each finding instance to -help investigators understand the detected issue. The text must be enclosed in quotation marks.`, - }, - "predicate": { - Type: schema.TypeList, - Optional: true, - Description: `The CEL expression to evaluate to produce findings. When the expression evaluates -to true against a resource, a finding is generated.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the expression. This is a longer text which describes the -expression, e.g. when hovered over it in a UI.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `String indicating the location of the expression for error reporting, e.g. a -file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Title for the expression, i.e. a short string describing its purpose. This can -be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - "recommendation": { - Type: schema.TypeString, - Optional: true, - Description: `An explanation of the recommended steps that security teams can take to resolve -the detected issue. This explanation is returned with each finding generated by -this module in the nextSteps property of the finding JSON.`, - }, - "resource_selector": { - Type: schema.TypeList, - Optional: true, - Description: `The resource types that the custom module operates on. Each custom module -can specify up to 5 resource types.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resource_types": { - Type: schema.TypeList, - Required: true, - Description: `The resource types to run the detector on.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "severity": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"CRITICAL", "HIGH", "MEDIUM", "LOW", ""}), - Description: `The severity to assign to findings generated by the module. Possible values: ["CRITICAL", "HIGH", "MEDIUM", "LOW"]`, - }, - }, - }, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^[a-z][\w_]{0,127}$`), - Description: `The display name of the Security Health Analytics custom module. This -display name becomes the finding category for all findings that are -returned by this custom module. The display name must be between 1 and -128 characters, start with a lowercase letter, and contain alphanumeric -characters or underscores only.`, - }, - "enablement_state": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"ENABLED", "DISABLED", ""}), - Description: `The enablement state of the custom module. Possible values: ["ENABLED", "DISABLED"]`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Location ID of the parent organization. If not provided, 'global' will be used as the default location.`, - Default: "global", - }, - "ancestor_module": { - Type: schema.TypeString, - Computed: true, - Description: `If empty, indicates that the custom module was created in the organization, folder, -or project in which you are viewing the custom module. Otherwise, ancestor_module -specifies the organization or folder from which the custom module is inherited.`, - }, - "last_editor": { - Type: schema.TypeString, - Computed: true, - Description: `The editor that last updated the custom module.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The resource name of the custom module. Its format is "folders/{folder}/locations/{location}/securityHealthAnalyticsCustomModules/{securityHealthAnalyticsCustomModule}". -The id {securityHealthAnalyticsCustomModule} is server-generated and is not user settable. It will be a numeric id containing 1-20 digits.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time at which the custom module was last 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".`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - displayNameProp, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - enablementStateProp, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(enablementStateProp)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - customConfigProp, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfig(d.Get("custom_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(customConfigProp)) && (ok || !reflect.DeepEqual(v, customConfigProp)) { - obj["customConfig"] = customConfigProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new FolderSecurityHealthAnalyticsCustomModule: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("name", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating FolderSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - - return resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule %q", d.Id())) - } - - if err := d.Set("name", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("display_name", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("enablement_state", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleEnablementState(res["enablementState"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("update_time", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("last_editor", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleLastEditor(res["lastEditor"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("ancestor_module", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleAncestorModule(res["ancestorModule"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("custom_config", flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfig(res["customConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading FolderSecurityHealthAnalyticsCustomModule: %s", err) - } - - return nil -} - -func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - enablementStateProp, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - customConfigProp, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfig(d.Get("custom_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customConfigProp)) { - obj["customConfig"] = customConfigProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating FolderSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("enablement_state") { - updateMask = append(updateMask, "enablementState") - } - - if d.HasChange("custom_config") { - updateMask = append(updateMask, "customConfig") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating FolderSecurityHealthAnalyticsCustomModule %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating FolderSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - } - - } - - return resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - lockName, err := tpgresource.ReplaceVars(d, config, "folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting FolderSecurityHealthAnalyticsCustomModule %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "FolderSecurityHealthAnalyticsCustomModule") - } - - log.Printf("[DEBUG] Finished deleting FolderSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - return nil -} - -func resourceSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^folders/(?P[^/]+)/locations/(?P[^/]+)/securityHealthAnalyticsCustomModules/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleEnablementState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleLastEditor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleAncestorModule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["predicate"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(original["predicate"], d, config) - transformed["custom_output"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(original["customOutput"], d, config) - transformed["resource_selector"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(original["resourceSelector"], d, config) - transformed["severity"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(original["severity"], d, config) - transformed["description"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigDescription(original["description"], d, config) - transformed["recommendation"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(original["recommendation"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(original["expression"], d, config) - transformed["title"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(original["title"], d, config) - transformed["description"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(original["description"], d, config) - transformed["location"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["properties"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(original["properties"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(original["name"], d, config), - "value_expression": flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(original["valueExpression"], d, config), - }) - } - return transformed -} -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(original["expression"], d, config) - transformed["title"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(original["title"], d, config) - transformed["description"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(original["description"], d, config) - transformed["location"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["resource_types"] = - flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(original["resourceTypes"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleEnablementState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPredicate, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(original["predicate"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPredicate); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["predicate"] = transformedPredicate - } - - transformedCustomOutput, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(original["custom_output"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomOutput); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customOutput"] = transformedCustomOutput - } - - transformedResourceSelector, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(original["resource_selector"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceSelector); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceSelector"] = transformedResourceSelector - } - - transformedSeverity, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(original["severity"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeverity); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["severity"] = transformedSeverity - } - - transformedDescription, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedRecommendation, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(original["recommendation"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRecommendation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["recommendation"] = transformedRecommendation - } - - return transformed, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - transformedTitle, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } - - transformedDescription, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedLocation, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProperties, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(original["properties"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProperties); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["properties"] = transformedProperties - } - - return transformed, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedValueExpression, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(original["value_expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValueExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["valueExpression"] = transformedValueExpression - } - - req = append(req, transformed) - } - return req, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - transformedTitle, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } - - transformedDescription, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedLocation, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedResourceTypes, err := expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(original["resource_types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceTypes"] = transformedResourceTypes - } - - return transformed, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_sweeper.go deleted file mode 100644 index 353301fd2bc..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_folder_security_health_analytics_custom_module_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule", testSweepSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule(region string) error { - resourceName := "SecurityCenterManagementFolderSecurityHealthAnalyticsCustomModule" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://securitycentermanagement.googleapis.com/v1/folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["folderSecurityHealthAnalyticsCustomModules"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://securitycentermanagement.googleapis.com/v1/folders/{{folder}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go deleted file mode 100644 index a329fd50243..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module.go +++ /dev/null @@ -1,479 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "encoding/json" - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModule() *schema.Resource { - return &schema.Resource{ - Create: resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleCreate, - Read: resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleRead, - Update: resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleUpdate, - Delete: resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "organization": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Numerical ID of the parent organization.`, - }, - "config": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringIsJSON, - StateFunc: func(v interface{}) string { s, _ := structure.NormalizeJsonString(v); return s }, - Description: `Config for the module. For the resident module, its config value is defined at this level. -For the inherited module, its config value is inherited from the ancestor module.`, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - Description: `The human readable name to be displayed for the module.`, - }, - "enablement_state": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"ENABLED", "DISABLED", ""}), - Description: `The state of enablement for the module at the given level of the hierarchy. Possible values: ["ENABLED", "DISABLED"]`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Location ID of the parent organization. Only global is supported at the moment.`, - Default: "global", - }, - "type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Immutable. Type for the module. e.g. CONFIGURABLE_BAD_IP.`, - }, - "last_editor": { - Type: schema.TypeString, - Computed: true, - Description: `The editor that last updated the custom module`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The resource name of the Event Threat Detection custom module. -Its format is "organizations/{organization}/locations/{location}/eventThreatDetectionCustomModules/{eventThreatDetectionCustomModule}".`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time at which the custom module was last 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".`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - configProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleConfig(d.Get("config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("config"); !tpgresource.IsEmptyValue(reflect.ValueOf(configProp)) && (ok || !reflect.DeepEqual(v, configProp)) { - obj["config"] = configProp - } - enablementStateProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(enablementStateProp)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - typeProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleType(d.Get("type"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("type"); !tpgresource.IsEmptyValue(reflect.ValueOf(typeProp)) && (ok || !reflect.DeepEqual(v, typeProp)) { - obj["type"] = typeProp - } - displayNameProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new OrganizationEventThreatDetectionCustomModule: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("name", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating OrganizationEventThreatDetectionCustomModule %q: %#v", d.Id(), res) - - return resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterManagementOrganizationEventThreatDetectionCustomModule %q", d.Id())) - } - - if err := d.Set("name", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("config", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleConfig(res["config"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("enablement_state", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleEnablementState(res["enablementState"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("type", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleType(res["type"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("display_name", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("update_time", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - if err := d.Set("last_editor", flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleLastEditor(res["lastEditor"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationEventThreatDetectionCustomModule: %s", err) - } - - return nil -} - -func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - configProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleConfig(d.Get("config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, configProp)) { - obj["config"] = configProp - } - enablementStateProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - displayNameProp, err := expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating OrganizationEventThreatDetectionCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("config") { - updateMask = append(updateMask, "config") - } - - if d.HasChange("enablement_state") { - updateMask = append(updateMask, "enablementState") - } - - if d.HasChange("display_name") { - updateMask = append(updateMask, "displayName") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating OrganizationEventThreatDetectionCustomModule %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating OrganizationEventThreatDetectionCustomModule %q: %#v", d.Id(), res) - } - - } - - return resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - lockName, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting OrganizationEventThreatDetectionCustomModule %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "OrganizationEventThreatDetectionCustomModule") - } - - log.Printf("[DEBUG] Finished deleting OrganizationEventThreatDetectionCustomModule %q: %#v", d.Id(), res) - return nil -} - -func resourceSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^organizations/(?P[^/]+)/locations/(?P[^/]+)/eventThreatDetectionCustomModules/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - b, err := json.Marshal(v) - if err != nil { - // TODO: return error once https://github.com/GoogleCloudPlatform/magic-modules/issues/3257 is fixed. - log.Printf("[ERROR] failed to marshal schema to JSON: %v", err) - } - return string(b) -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleEnablementState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleLastEditor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - b := []byte(v.(string)) - if len(b) == 0 { - return nil, nil - } - m := make(map[string]interface{}) - if err := json.Unmarshal(b, &m); err != nil { - return nil, err - } - return m, nil -} - -func expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleEnablementState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationEventThreatDetectionCustomModuleDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_sweeper.go deleted file mode 100644 index d2b6d041dae..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_event_threat_detection_custom_module_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SecurityCenterManagementOrganizationEventThreatDetectionCustomModule", testSweepSecurityCenterManagementOrganizationEventThreatDetectionCustomModule) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSecurityCenterManagementOrganizationEventThreatDetectionCustomModule(region string) error { - resourceName := "SecurityCenterManagementOrganizationEventThreatDetectionCustomModule" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://securitycentermanagement.googleapis.com/v1/organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["organizationEventThreatDetectionCustomModules"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://securitycentermanagement.googleapis.com/v1/organizations/{{organization}}/locations/{{location}}/eventThreatDetectionCustomModules/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go deleted file mode 100644 index dbd1cbed5fc..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module.go +++ /dev/null @@ -1,983 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule() *schema.Resource { - return &schema.Resource{ - Create: resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCreate, - Read: resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleRead, - Update: resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleUpdate, - Delete: resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "organization": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `Numerical ID of the parent organization.`, - }, - "custom_config": { - Type: schema.TypeList, - Optional: true, - Description: `The user specified custom configuration for the module.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "predicate": { - Type: schema.TypeList, - Required: true, - Description: `The CEL expression to evaluate to produce findings. When the expression evaluates -to true against a resource, a finding is generated.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the expression. This is a longer text which describes the -expression, e.g. when hovered over it in a UI.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `String indicating the location of the expression for error reporting, e.g. a -file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Title for the expression, i.e. a short string describing its purpose. This can -be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - "recommendation": { - Type: schema.TypeString, - Required: true, - Description: `An explanation of the recommended steps that security teams can take to resolve -the detected issue. This explanation is returned with each finding generated by -this module in the nextSteps property of the finding JSON.`, - }, - "resource_selector": { - Type: schema.TypeList, - Required: true, - Description: `The resource types that the custom module operates on. Each custom module -can specify up to 5 resource types.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resource_types": { - Type: schema.TypeList, - Required: true, - Description: `The resource types to run the detector on.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "severity": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"CRITICAL", "HIGH", "MEDIUM", "LOW"}), - Description: `The severity to assign to findings generated by the module. Possible values: ["CRITICAL", "HIGH", "MEDIUM", "LOW"]`, - }, - "custom_output": { - Type: schema.TypeList, - Optional: true, - Description: `Custom output properties.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "properties": { - Type: schema.TypeList, - Optional: true, - Description: `A list of custom output properties to add to the finding.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - Description: `Name of the property for the custom output.`, - }, - "value_expression": { - Type: schema.TypeList, - Optional: true, - Description: `The CEL expression for the custom output. A resource property can be specified -to return the value of the property or a text string enclosed in quotation marks.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the expression. This is a longer text which describes the -expression, e.g. when hovered over it in a UI.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `String indicating the location of the expression for error reporting, e.g. a -file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Title for the expression, i.e. a short string describing its purpose. This can -be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Text that describes the vulnerability or misconfiguration that the custom -module detects. This explanation is returned with each finding instance to -help investigators understand the detected issue. The text must be enclosed in quotation marks.`, - }, - }, - }, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^[a-z][\w_]{0,127}$`), - Description: `The display name of the Security Health Analytics custom module. This -display name becomes the finding category for all findings that are -returned by this custom module. The display name must be between 1 and -128 characters, start with a lowercase letter, and contain alphanumeric -characters or underscores only.`, - }, - "enablement_state": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"ENABLED", "DISABLED", ""}), - Description: `The enablement state of the custom module. Possible values: ["ENABLED", "DISABLED"]`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Location ID of the parent organization. If not provided, 'global' will be used as the default location.`, - Default: "global", - }, - "ancestor_module": { - Type: schema.TypeString, - Computed: true, - Description: `If empty, indicates that the custom module was created in the organization, folder, -or project in which you are viewing the custom module. Otherwise, ancestor_module -specifies the organization or folder from which the custom module is inherited.`, - }, - "last_editor": { - Type: schema.TypeString, - Computed: true, - Description: `The editor that last updated the custom module.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The resource name of the custom module. Its format is "organizations/{organization}/locations/{location}/securityHealthAnalyticsCustomModules/{securityHealthAnalyticsCustomModule}". -The id {securityHealthAnalyticsCustomModule} is server-generated and is not user settable. It will be a numeric id containing 1-20 digits.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time at which the custom module was last 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".`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - displayNameProp, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - enablementStateProp, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(enablementStateProp)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - customConfigProp, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfig(d.Get("custom_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(customConfigProp)) && (ok || !reflect.DeepEqual(v, customConfigProp)) { - obj["customConfig"] = customConfigProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new OrganizationSecurityHealthAnalyticsCustomModule: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("name", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating OrganizationSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - - return resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule %q", d.Id())) - } - - if err := d.Set("name", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("display_name", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("enablement_state", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleEnablementState(res["enablementState"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("update_time", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("last_editor", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleLastEditor(res["lastEditor"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("ancestor_module", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleAncestorModule(res["ancestorModule"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("custom_config", flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfig(res["customConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationSecurityHealthAnalyticsCustomModule: %s", err) - } - - return nil -} - -func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - enablementStateProp, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - customConfigProp, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfig(d.Get("custom_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customConfigProp)) { - obj["customConfig"] = customConfigProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating OrganizationSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("enablement_state") { - updateMask = append(updateMask, "enablementState") - } - - if d.HasChange("custom_config") { - updateMask = append(updateMask, "customConfig") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating OrganizationSecurityHealthAnalyticsCustomModule %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating OrganizationSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - } - - } - - return resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - lockName, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting OrganizationSecurityHealthAnalyticsCustomModule %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "OrganizationSecurityHealthAnalyticsCustomModule") - } - - log.Printf("[DEBUG] Finished deleting OrganizationSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - return nil -} - -func resourceSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^organizations/(?P[^/]+)/locations/(?P[^/]+)/securityHealthAnalyticsCustomModules/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleEnablementState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleLastEditor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleAncestorModule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["predicate"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(original["predicate"], d, config) - transformed["custom_output"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(original["customOutput"], d, config) - transformed["resource_selector"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(original["resourceSelector"], d, config) - transformed["severity"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(original["severity"], d, config) - transformed["description"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigDescription(original["description"], d, config) - transformed["recommendation"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(original["recommendation"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(original["expression"], d, config) - transformed["title"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(original["title"], d, config) - transformed["description"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(original["description"], d, config) - transformed["location"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["properties"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(original["properties"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(original["name"], d, config), - "value_expression": flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(original["valueExpression"], d, config), - }) - } - return transformed -} -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(original["expression"], d, config) - transformed["title"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(original["title"], d, config) - transformed["description"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(original["description"], d, config) - transformed["location"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["resource_types"] = - flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(original["resourceTypes"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleEnablementState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPredicate, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(original["predicate"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPredicate); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["predicate"] = transformedPredicate - } - - transformedCustomOutput, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(original["custom_output"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomOutput); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customOutput"] = transformedCustomOutput - } - - transformedResourceSelector, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(original["resource_selector"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceSelector); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceSelector"] = transformedResourceSelector - } - - transformedSeverity, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(original["severity"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeverity); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["severity"] = transformedSeverity - } - - transformedDescription, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedRecommendation, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(original["recommendation"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRecommendation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["recommendation"] = transformedRecommendation - } - - return transformed, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - transformedTitle, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } - - transformedDescription, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedLocation, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProperties, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(original["properties"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProperties); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["properties"] = transformedProperties - } - - return transformed, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedValueExpression, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(original["value_expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValueExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["valueExpression"] = transformedValueExpression - } - - req = append(req, transformed) - } - return req, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - transformedTitle, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } - - transformedDescription, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedLocation, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedResourceTypes, err := expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(original["resource_types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceTypes"] = transformedResourceTypes - } - - return transformed, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_sweeper.go deleted file mode 100644 index 0ce44a6940a..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_organization_security_health_analytics_custom_module_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule", testSweepSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule(region string) error { - resourceName := "SecurityCenterManagementOrganizationSecurityHealthAnalyticsCustomModule" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://securitycentermanagement.googleapis.com/v1/organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["organizationSecurityHealthAnalyticsCustomModules"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://securitycentermanagement.googleapis.com/v1/organizations/{{organization}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go deleted file mode 100644 index 0d710e358f2..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module.go +++ /dev/null @@ -1,1017 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule() *schema.Resource { - return &schema.Resource{ - Create: resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCreate, - Read: resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleRead, - Update: resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleUpdate, - Delete: resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "custom_config": { - Type: schema.TypeList, - Optional: true, - Description: `The user specified custom configuration for the module.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "predicate": { - Type: schema.TypeList, - Required: true, - Description: `The CEL expression to evaluate to produce findings. When the expression evaluates -to true against a resource, a finding is generated.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the expression. This is a longer text which describes the -expression, e.g. when hovered over it in a UI.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `String indicating the location of the expression for error reporting, e.g. a -file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Title for the expression, i.e. a short string describing its purpose. This can -be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - "recommendation": { - Type: schema.TypeString, - Required: true, - Description: `An explanation of the recommended steps that security teams can take to resolve -the detected issue. This explanation is returned with each finding generated by -this module in the nextSteps property of the finding JSON.`, - }, - "resource_selector": { - Type: schema.TypeList, - Required: true, - Description: `The resource types that the custom module operates on. Each custom module -can specify up to 5 resource types.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "resource_types": { - Type: schema.TypeList, - Required: true, - Description: `The resource types to run the detector on.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "severity": { - Type: schema.TypeString, - Required: true, - ValidateFunc: verify.ValidateEnum([]string{"CRITICAL", "HIGH", "MEDIUM", "LOW"}), - Description: `The severity to assign to findings generated by the module. Possible values: ["CRITICAL", "HIGH", "MEDIUM", "LOW"]`, - }, - "custom_output": { - Type: schema.TypeList, - Optional: true, - Description: `Custom output properties.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "properties": { - Type: schema.TypeList, - Optional: true, - Description: `A list of custom output properties to add to the finding.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - Description: `Name of the property for the custom output.`, - }, - "value_expression": { - Type: schema.TypeList, - Optional: true, - Description: `The CEL expression for the custom output. A resource property can be specified -to return the value of the property or a text string enclosed in quotation marks.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "expression": { - Type: schema.TypeString, - Required: true, - Description: `Textual representation of an expression in Common Expression Language syntax.`, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Description of the expression. This is a longer text which describes the -expression, e.g. when hovered over it in a UI.`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - Description: `String indicating the location of the expression for error reporting, e.g. a -file name and a position in the file.`, - }, - "title": { - Type: schema.TypeString, - Optional: true, - Description: `Title for the expression, i.e. a short string describing its purpose. This can -be used e.g. in UIs which allow to enter the expression.`, - }, - }, - }, - }, - }, - }, - }, - }, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - Description: `Text that describes the vulnerability or misconfiguration that the custom -module detects. This explanation is returned with each finding instance to -help investigators understand the detected issue. The text must be enclosed in quotation marks.`, - }, - }, - }, - }, - "display_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`^[a-z][\w_]{0,127}$`), - Description: `The display name of the Security Health Analytics custom module. This -display name becomes the finding category for all findings that are -returned by this custom module. The display name must be between 1 and -128 characters, start with a lowercase letter, and contain alphanumeric -characters or underscores only.`, - }, - "enablement_state": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: verify.ValidateEnum([]string{"ENABLED", "DISABLED", ""}), - Description: `The enablement state of the custom module. Possible values: ["ENABLED", "DISABLED"]`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `Location ID of the parent organization. If not provided, 'global' will be used as the default location.`, - Default: "global", - }, - "ancestor_module": { - Type: schema.TypeString, - Computed: true, - Description: `If empty, indicates that the custom module was created in the organization,folder, -or project in which you are viewing the custom module. Otherwise, ancestor_module -specifies the organization or folder from which the custom module is inherited.`, - }, - "last_editor": { - Type: schema.TypeString, - Computed: true, - Description: `The editor that last updated the custom module.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The resource name of the custom module. Its format is "projects/{project}/locations/{location}/securityHealthAnalyticsCustomModules/{securityHealthAnalyticsCustomModule}". -The id {securityHealthAnalyticsCustomModule} is server-generated and is not user settable. It will be a numeric id containing 1-20 digits.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The time at which the custom module was last 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".`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - displayNameProp, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - enablementStateProp, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(enablementStateProp)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - customConfigProp, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfig(d.Get("custom_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(customConfigProp)) && (ok || !reflect.DeepEqual(v, customConfigProp)) { - obj["customConfig"] = customConfigProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new ProjectSecurityHealthAnalyticsCustomModule: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("name", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating ProjectSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - - return resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - - if err := d.Set("name", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("display_name", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("enablement_state", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleEnablementState(res["enablementState"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("update_time", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("last_editor", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleLastEditor(res["lastEditor"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("ancestor_module", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleAncestorModule(res["ancestorModule"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - if err := d.Set("custom_config", flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfig(res["customConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - - return nil -} - -func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - enablementStateProp, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleEnablementState(d.Get("enablement_state"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("enablement_state"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, enablementStateProp)) { - obj["enablementState"] = enablementStateProp - } - customConfigProp, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfig(d.Get("custom_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("custom_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, customConfigProp)) { - obj["customConfig"] = customConfigProp - } - - lockName, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating ProjectSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("enablement_state") { - updateMask = append(updateMask, "enablementState") - } - - if d.HasChange("custom_config") { - updateMask = append(updateMask, "customConfig") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating ProjectSecurityHealthAnalyticsCustomModule %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating ProjectSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - } - - } - - return resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleRead(d, meta) -} - -func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for ProjectSecurityHealthAnalyticsCustomModule: %s", err) - } - billingProject = project - - lockName, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules") - if err != nil { - return err - } - transport_tpg.MutexStore.Lock(lockName) - defer transport_tpg.MutexStore.Unlock(lockName) - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterManagementBasePath}}projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting ProjectSecurityHealthAnalyticsCustomModule %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ProjectSecurityHealthAnalyticsCustomModule") - } - - log.Printf("[DEBUG] Finished deleting ProjectSecurityHealthAnalyticsCustomModule %q: %#v", d.Id(), res) - return nil -} - -func resourceSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/securityHealthAnalyticsCustomModules/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleEnablementState(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleLastEditor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleAncestorModule(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["predicate"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(original["predicate"], d, config) - transformed["custom_output"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(original["customOutput"], d, config) - transformed["resource_selector"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(original["resourceSelector"], d, config) - transformed["severity"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(original["severity"], d, config) - transformed["description"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigDescription(original["description"], d, config) - transformed["recommendation"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(original["recommendation"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(original["expression"], d, config) - transformed["title"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(original["title"], d, config) - transformed["description"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(original["description"], d, config) - transformed["location"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["properties"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(original["properties"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "name": flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(original["name"], d, config), - "value_expression": flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(original["valueExpression"], d, config), - }) - } - return transformed -} -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["expression"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(original["expression"], d, config) - transformed["title"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(original["title"], d, config) - transformed["description"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(original["description"], d, config) - transformed["location"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(original["location"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["resource_types"] = - flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(original["resourceTypes"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleEnablementState(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPredicate, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(original["predicate"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPredicate); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["predicate"] = transformedPredicate - } - - transformedCustomOutput, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(original["custom_output"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedCustomOutput); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["customOutput"] = transformedCustomOutput - } - - transformedResourceSelector, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(original["resource_selector"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceSelector); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceSelector"] = transformedResourceSelector - } - - transformedSeverity, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(original["severity"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSeverity); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["severity"] = transformedSeverity - } - - transformedDescription, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedRecommendation, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(original["recommendation"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedRecommendation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["recommendation"] = transformedRecommendation - } - - return transformed, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicate(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - transformedTitle, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } - - transformedDescription, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedLocation, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigPredicateLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutput(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedProperties, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(original["properties"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProperties); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["properties"] = transformedProperties - } - - return transformed, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputProperties(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedName, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(original["name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["name"] = transformedName - } - - transformedValueExpression, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(original["value_expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedValueExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["valueExpression"] = transformedValueExpression - } - - req = append(req, transformed) - } - return req, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedExpression, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(original["expression"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedExpression); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["expression"] = transformedExpression - } - - transformedTitle, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(original["title"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTitle); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["title"] = transformedTitle - } - - transformedDescription, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(original["description"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDescription); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["description"] = transformedDescription - } - - transformedLocation, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - return transformed, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionExpression(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionTitle(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigCustomOutputPropertiesValueExpressionLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelector(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedResourceTypes, err := expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(original["resource_types"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedResourceTypes); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["resourceTypes"] = transformedResourceTypes - } - - return transformed, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigResourceSelectorResourceTypes(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigSeverity(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModuleCustomConfigRecommendation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_sweeper.go deleted file mode 100644 index 35c2d188c3b..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement/resource_scc_management_project_security_health_analytics_custom_module_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycentermanagement - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule", testSweepSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule(region string) error { - resourceName := "SecurityCenterManagementProjectSecurityHealthAnalyticsCustomModule" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://securitycentermanagement.googleapis.com/v1/projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["projectSecurityHealthAnalyticsCustomModules"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://securitycentermanagement.googleapis.com/v1/projects/{{project}}/locations/{{location}}/securityHealthAnalyticsCustomModules/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go deleted file mode 100644 index 4fa815681af..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2/resource_scc_v2_organization_notification_config.go +++ /dev/null @@ -1,498 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycenterv2 - -import ( - "fmt" - "log" - "net/http" - "reflect" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceSecurityCenterV2OrganizationNotificationConfig() *schema.Resource { - return &schema.Resource{ - Create: resourceSecurityCenterV2OrganizationNotificationConfigCreate, - Read: resourceSecurityCenterV2OrganizationNotificationConfigRead, - Update: resourceSecurityCenterV2OrganizationNotificationConfigUpdate, - Delete: resourceSecurityCenterV2OrganizationNotificationConfigDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSecurityCenterV2OrganizationNotificationConfigImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "config_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `This must be unique within the organization.`, - }, - "organization": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The organization whose Cloud Security Command Center the Notification -Config lives in.`, - }, - "pubsub_topic": { - Type: schema.TypeString, - Required: true, - Description: `The Pub/Sub topic to send notifications to. Its format is -"projects/[project_id]/topics/[topic]".`, - }, - "streaming_config": { - Type: schema.TypeList, - Required: true, - Description: `The config for triggering streaming-based notifications.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "filter": { - Type: schema.TypeString, - Required: true, - Description: `Expression that defines the filter to apply across create/update -events of assets or findings as specified by the event type. The -expression is a list of zero or more restrictions combined via -logical operators AND and OR. Parentheses are supported, and OR -has higher precedence than AND. - -Restrictions have the form and may have -a - character in front of them to indicate negation. The fields -map to those defined in the corresponding resource. - -The supported operators are: - -* = for all value types. -* >, <, >=, <= for integer values. -* :, meaning substring matching, for strings. - -The supported value types are: - -* string literals in quotes. -* integer literals without quotes. -* boolean literals true and false without quotes. - -See -[Filtering notifications](https://cloud.google.com/security-command-center/docs/how-to-api-filter-notifications) -for information on how to write a filter.`, - }, - }, - }, - }, - "description": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringLenBetween(0, 1024), - Description: `The description of the notification config (max of 1024 characters).`, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `location Id is provided by organization. If not provided, Use global as default.`, - Default: "global", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: `The resource name of this notification config, in the format -'organizations/{{organization}}/notificationConfigs/{{config_id}}'.`, - }, - "service_account": { - Type: schema.TypeString, - Computed: true, - Description: `The service account that needs "pubsub.topics.publish" permission to -publish to the Pub/Sub topic.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceSecurityCenterV2OrganizationNotificationConfigCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - descriptionProp, err := expandSecurityCenterV2OrganizationNotificationConfigDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(descriptionProp)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - pubsubTopicProp, err := expandSecurityCenterV2OrganizationNotificationConfigPubsubTopic(d.Get("pubsub_topic"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("pubsub_topic"); !tpgresource.IsEmptyValue(reflect.ValueOf(pubsubTopicProp)) && (ok || !reflect.DeepEqual(v, pubsubTopicProp)) { - obj["pubsubTopic"] = pubsubTopicProp - } - streamingConfigProp, err := expandSecurityCenterV2OrganizationNotificationConfigStreamingConfig(d.Get("streaming_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("streaming_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(streamingConfigProp)) && (ok || !reflect.DeepEqual(v, streamingConfigProp)) { - obj["streamingConfig"] = streamingConfigProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterV2BasePath}}organizations/{{organization}}/locations/{{location}}/notificationConfigs?configId={{config_id}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new OrganizationNotificationConfig: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating OrganizationNotificationConfig: %s", err) - } - if err := d.Set("name", flattenSecurityCenterV2OrganizationNotificationConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf(`Error setting computed identity field "name": %s`, err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // `name` is autogenerated from the api so needs to be set post-create - name, ok := res["name"] - if !ok { - respBody, ok := res["response"] - if !ok { - return fmt.Errorf("Create response didn't contain critical fields. Create may not have succeeded.") - } - - name, ok = respBody.(map[string]interface{})["name"] - if !ok { - return fmt.Errorf("Create response didn't contain critical fields. Create may not have succeeded.") - } - } - if err := d.Set("name", name.(string)); err != nil { - return fmt.Errorf("Error setting name: %s", err) - } - d.SetId(name.(string)) - - log.Printf("[DEBUG] Finished creating OrganizationNotificationConfig %q: %#v", d.Id(), res) - - return resourceSecurityCenterV2OrganizationNotificationConfigRead(d, meta) -} - -func resourceSecurityCenterV2OrganizationNotificationConfigRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterV2BasePath}}{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityCenterV2OrganizationNotificationConfig %q", d.Id())) - } - - if err := d.Set("name", flattenSecurityCenterV2OrganizationNotificationConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationNotificationConfig: %s", err) - } - if err := d.Set("description", flattenSecurityCenterV2OrganizationNotificationConfigDescription(res["description"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationNotificationConfig: %s", err) - } - if err := d.Set("pubsub_topic", flattenSecurityCenterV2OrganizationNotificationConfigPubsubTopic(res["pubsubTopic"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationNotificationConfig: %s", err) - } - if err := d.Set("service_account", flattenSecurityCenterV2OrganizationNotificationConfigServiceAccount(res["serviceAccount"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationNotificationConfig: %s", err) - } - if err := d.Set("streaming_config", flattenSecurityCenterV2OrganizationNotificationConfigStreamingConfig(res["streamingConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading OrganizationNotificationConfig: %s", err) - } - - return nil -} - -func resourceSecurityCenterV2OrganizationNotificationConfigUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - obj := make(map[string]interface{}) - descriptionProp, err := expandSecurityCenterV2OrganizationNotificationConfigDescription(d.Get("description"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("description"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, descriptionProp)) { - obj["description"] = descriptionProp - } - pubsubTopicProp, err := expandSecurityCenterV2OrganizationNotificationConfigPubsubTopic(d.Get("pubsub_topic"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("pubsub_topic"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, pubsubTopicProp)) { - obj["pubsubTopic"] = pubsubTopicProp - } - streamingConfigProp, err := expandSecurityCenterV2OrganizationNotificationConfigStreamingConfig(d.Get("streaming_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("streaming_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, streamingConfigProp)) { - obj["streamingConfig"] = streamingConfigProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterV2BasePath}}{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating OrganizationNotificationConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("description") { - updateMask = append(updateMask, "description") - } - - if d.HasChange("pubsub_topic") { - updateMask = append(updateMask, "pubsubTopic") - } - - if d.HasChange("streaming_config") { - updateMask = append(updateMask, "streamingConfig.filter") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating OrganizationNotificationConfig %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating OrganizationNotificationConfig %q: %#v", d.Id(), res) - } - - } - - return resourceSecurityCenterV2OrganizationNotificationConfigRead(d, meta) -} - -func resourceSecurityCenterV2OrganizationNotificationConfigDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{SecurityCenterV2BasePath}}{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting OrganizationNotificationConfig %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "OrganizationNotificationConfig") - } - - log.Printf("[DEBUG] Finished deleting OrganizationNotificationConfig %q: %#v", d.Id(), res) - return nil -} - -func resourceSecurityCenterV2OrganizationNotificationConfigImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - - // current import_formats can't import fields with forward slashes in their value - if err := tpgresource.ParseImportId([]string{"(?P.+)"}, d, config); err != nil { - return nil, err - } - - stringParts := strings.Split(d.Get("name").(string), "/") - if len(stringParts) != 6 { - return nil, fmt.Errorf( - "Saw %s when the name is expected to have shape %s", - d.Get("name"), - "organizations/{{organization}}/locations/{{location}}/notificationConfigs/{{config_id}}", - ) - } - - if err := d.Set("organization", stringParts[1]); err != nil { - return nil, fmt.Errorf("Error setting organization: %s", err) - } - if err := d.Set("location", stringParts[3]); err != nil { - return nil, fmt.Errorf("Error setting location: %s", err) - } - if err := d.Set("config_id", stringParts[5]); err != nil { - return nil, fmt.Errorf("Error setting config_id: %s", err) - } - return []*schema.ResourceData{d}, nil -} - -func flattenSecurityCenterV2OrganizationNotificationConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterV2OrganizationNotificationConfigDescription(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterV2OrganizationNotificationConfigPubsubTopic(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterV2OrganizationNotificationConfigServiceAccount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSecurityCenterV2OrganizationNotificationConfigStreamingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["filter"] = - flattenSecurityCenterV2OrganizationNotificationConfigStreamingConfigFilter(original["filter"], d, config) - return []interface{}{transformed} -} -func flattenSecurityCenterV2OrganizationNotificationConfigStreamingConfigFilter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSecurityCenterV2OrganizationNotificationConfigDescription(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterV2OrganizationNotificationConfigPubsubTopic(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSecurityCenterV2OrganizationNotificationConfigStreamingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedFilter, err := expandSecurityCenterV2OrganizationNotificationConfigStreamingConfigFilter(original["filter"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedFilter); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["filter"] = transformedFilter - } - - return transformed, nil -} - -func expandSecurityCenterV2OrganizationNotificationConfigStreamingConfigFilter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_sweeper.go deleted file mode 100644 index 35e9c045cb4..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2/resource_scc_v2_organization_notification_config_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package securitycenterv2 - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SecurityCenterV2OrganizationNotificationConfig", testSweepSecurityCenterV2OrganizationNotificationConfig) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSecurityCenterV2OrganizationNotificationConfig(region string) error { - resourceName := "SecurityCenterV2OrganizationNotificationConfig" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://securitycenter.googleapis.com/v2/organizations/{{organization}}/locations/{{location}}/notificationConfigs", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["organizationNotificationConfigs"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://securitycenter.googleapis.com/v2/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture.go index 49147c24257..e9a31cbffd6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -680,7 +679,6 @@ func resourceSecurityposturePostureCreate(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -689,7 +687,6 @@ func resourceSecurityposturePostureCreate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Posture: %s", err) @@ -736,14 +733,12 @@ func resourceSecurityposturePostureRead(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityposturePosture %q", d.Id())) @@ -821,7 +816,6 @@ func resourceSecurityposturePostureUpdate(d *schema.ResourceData, meta interface } log.Printf("[DEBUG] Updating Posture %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("state") { @@ -861,7 +855,6 @@ func resourceSecurityposturePostureUpdate(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -903,8 +896,6 @@ func resourceSecurityposturePostureDelete(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Posture %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -914,7 +905,6 @@ func resourceSecurityposturePostureDelete(d *schema.ResourceData, meta interface UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Posture") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture_deployment.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture_deployment.go index 09614b1f289..4901e61accb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture_deployment.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/securityposture/resource_securityposture_posture_deployment.go @@ -20,7 +20,6 @@ package securityposture import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -196,7 +195,6 @@ func resourceSecurityposturePostureDeploymentCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -205,7 +203,6 @@ func resourceSecurityposturePostureDeploymentCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating PostureDeployment: %s", err) @@ -252,14 +249,12 @@ func resourceSecurityposturePostureDeploymentRead(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SecurityposturePostureDeployment %q", d.Id())) @@ -343,7 +338,6 @@ func resourceSecurityposturePostureDeploymentUpdate(d *schema.ResourceData, meta } log.Printf("[DEBUG] Updating PostureDeployment %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("posture_id") { @@ -379,7 +373,6 @@ func resourceSecurityposturePostureDeploymentUpdate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -421,8 +414,6 @@ func resourceSecurityposturePostureDeploymentDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PostureDeployment %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -432,7 +423,6 @@ func resourceSecurityposturePostureDeploymentDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "PostureDeployment") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go index 4a47d931645..e11fa0c4ea0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_google_service_networking_peered_dns_domain.go @@ -137,7 +137,7 @@ func resourceGoogleServiceNetworkingPeeredDNSDomainCreate(d *schema.ResourceData return err } - if err := ServiceNetworkingOperationWaitTimeHW(config, op, "Create Service Networking Peered DNS Domain", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { + if err := ServiceNetworkingOperationWaitTime(config, op, "Create Service Networking Peered DNS Domain", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { return err } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_connection.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_connection.go index 0c95ae62ddd..f88cd60d257 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_connection.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_connection.go @@ -119,7 +119,7 @@ func resourceServiceNetworkingConnectionCreate(d *schema.ResourceData, meta inte return err } - if err := ServiceNetworkingOperationWaitTimeHW(config, op, "Create Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { + if err := ServiceNetworkingOperationWaitTime(config, op, "Create Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { return err } @@ -248,7 +248,7 @@ func resourceServiceNetworkingConnectionUpdate(d *schema.ResourceData, meta inte if err != nil { return err } - if err := ServiceNetworkingOperationWaitTimeHW(config, op, "Update Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutUpdate)); err != nil { + if err := ServiceNetworkingOperationWaitTime(config, op, "Update Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutUpdate)); err != nil { return err } } @@ -299,7 +299,7 @@ func resourceServiceNetworkingConnectionDelete(d *schema.ResourceData, meta inte return err } - if err := ServiceNetworkingOperationWaitTimeHW(config, op, "Delete Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { + if err := ServiceNetworkingOperationWaitTime(config, op, "Delete Service Networking Connection", userAgent, project, d.Timeout(schema.TimeoutCreate)); err != nil { return errwrap.Wrapf("Unable to remove Service Networking Connection, err: {{err}}", err) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go deleted file mode 100644 index 111a23ad3f7..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/resource_service_networking_vpc_service_controls.go +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package servicenetworking - -import ( - "fmt" - "log" - "net/http" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func resourceServiceNetworkingVPCServiceControlsSet(d *schema.ResourceData, meta interface{}, config *transport_tpg.Config) error { - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - projectNumber, err := getProjectNumber(d, config, project, userAgent) - if err != nil { - return err - } - - network := d.Get("network").(string) - enabled := d.Get("enabled").(bool) - - obj := make(map[string]interface{}) - obj["consumerNetwork"] = fmt.Sprintf("projects/%s/global/networks/%s", projectNumber, network) - - url, err := tpgresource.ReplaceVars(d, config, "{{ServiceNetworkingBasePath}}services/{{service}}") - if err != nil { - return err - } - - if enabled { - url = url + ":enableVpcServiceControls" - } else { - url = url + ":disableVpcServiceControls" - } - - log.Printf("[DEBUG] Setting service networking VPC service controls: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating VPCServiceControls: %s", err) - } - - id, err := tpgresource.ReplaceVars(d, config, "services/{{service}}/projects/{{project}}/networks/{{network}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - err = ServiceNetworkingOperationWaitTime( - config, res, "Setting service networking VPC service controls", userAgent, project, - d.Timeout(schema.TimeoutCreate)) - - if err != nil { - // The resource didn't actually create - d.SetId("") - return fmt.Errorf("Error waiting to set service networking VPC service controls: %s", err) - } - - log.Printf("[DEBUG] Finished setting service networking VPC service controls %q: %#v", d.Id(), res) - - return resourceServiceNetworkingVPCServiceControlsRead(d, meta) -} - -func ResourceServiceNetworkingVPCServiceControls() *schema.Resource { - return &schema.Resource{ - Create: resourceServiceNetworkingVPCServiceControlsCreate, - Read: resourceServiceNetworkingVPCServiceControlsRead, - Update: resourceServiceNetworkingVPCServiceControlsUpdate, - Delete: resourceServiceNetworkingVPCServiceControlsDelete, - - Importer: &schema.ResourceImporter{ - State: resourceServiceNetworkingVPCServiceControlsImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Required: true, - Description: `Desired VPC Service Controls state service producer VPC network, as -described at the top of this page.`, - }, - "network": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The network that the consumer is using to connect with services.`, - }, - "service": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The service that is managing peering connectivity for a service -producer's organization. For Google services that support this -functionality, this value is 'servicenetworking.googleapis.com'.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The id of the Google Cloud project containing the consumer network.`, - }, - }, - UseJSONNumber: true, - } -} - -func resourceServiceNetworkingVPCServiceControlsCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - return resourceServiceNetworkingVPCServiceControlsSet(d, meta, config) -} - -func resourceServiceNetworkingVPCServiceControlsRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{ServiceNetworkingBasePath}}/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - project, err := tpgresource.GetProject(d, config) - if err != nil { - return err - } - projectNumber, err := getProjectNumber(d, config, project, userAgent) - if err != nil { - return err - } - - service := d.Get("service").(string) - network := d.Get("network").(string) - parent := fmt.Sprintf("services/%s/projects/%s/global/networks/%s", service, projectNumber, network) - url, err = tpgresource.ReplaceVars(d, config, "{{ServiceNetworkingBasePath}}"+parent+"/vpcServiceControls") - if err != nil { - return err - } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("ServiceNetworkingVPCServiceControls %q", d.Id())) - } - - if err := d.Set("enabled", flattenServiceNetworkingVPCServiceControlsEnabled(res["enabled"], d, config)); err != nil { - return fmt.Errorf("Error reading VPCServiceControls: %s", err) - } - - return nil -} - -func resourceServiceNetworkingVPCServiceControlsUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - return resourceServiceNetworkingVPCServiceControlsSet(d, meta, config) -} - -func resourceServiceNetworkingVPCServiceControlsDelete(d *schema.ResourceData, meta interface{}) error { - log.Printf("[WARNING] ServiceNetworking VPCServiceControls resources"+ - " cannot be deleted from Google Cloud. The resource %s will be removed from Terraform"+ - " state, but will still be present on Google Cloud.", d.Id()) - d.SetId("") - - return nil -} - -func resourceServiceNetworkingVPCServiceControlsImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^services/(?P[^/]+)/projects/(?P[^/]+)/networks/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "services/{{service}}/projects/{{project}}/networks/{{network}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenServiceNetworkingVPCServiceControlsEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandServiceNetworkingVPCServiceControlsEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandServiceNetworkingVPCServiceControlsProject(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation.go index fd37b99d724..c750b32ae7f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation.go @@ -1,91 +1,38 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - package servicenetworking import ( - "encoding/json" - "errors" - "fmt" "time" "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" + "google.golang.org/api/servicenetworking/v1" ) type ServiceNetworkingOperationWaiter struct { - Config *transport_tpg.Config - UserAgent string - Project string + Service *servicenetworking.APIService + Project string + UserProjectOverride bool tpgresource.CommonOperationWaiter } func (w *ServiceNetworkingOperationWaiter) QueryOp() (interface{}, error) { - if w == nil { - return nil, fmt.Errorf("Cannot query operation, it's unset or nil.") + opGetCall := w.Service.Operations.Get(w.Op.Name) + if w.UserProjectOverride { + opGetCall.Header().Add("X-Goog-User-Project", w.Project) } - // Returns the proper get. - url := fmt.Sprintf("%s%s", w.Config.ServiceNetworkingBasePath, w.CommonOperationWaiter.Op.Name) - - return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: w.Config, - Method: "GET", - Project: w.Project, - RawURL: url, - UserAgent: w.UserAgent, - }) + return opGetCall.Do() } -func createServiceNetworkingWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*ServiceNetworkingOperationWaiter, error) { +func ServiceNetworkingOperationWaitTime(config *transport_tpg.Config, op *servicenetworking.Operation, activity, userAgent, project string, timeout time.Duration) error { w := &ServiceNetworkingOperationWaiter{ - Config: config, - UserAgent: userAgent, - Project: project, - } - if err := w.CommonOperationWaiter.SetOp(op); err != nil { - return nil, err + Service: config.NewServiceNetworkingClient(userAgent), + Project: project, + UserProjectOverride: config.UserProjectOverride, } - return w, nil -} -// nolint: deadcode,unused -func ServiceNetworkingOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { - w, err := createServiceNetworkingWaiter(config, op, project, activity, userAgent) - if err != nil { - return err - } - if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil { - return err - } - rawResponse := []byte(w.CommonOperationWaiter.Op.Response) - if len(rawResponse) == 0 { - return errors.New("`resource` not set in operation response") - } - return json.Unmarshal(rawResponse, response) -} - -func ServiceNetworkingOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error { - if val, ok := op["name"]; !ok || val == "" { - // This was a synchronous call - there is no operation to wait for. - return nil - } - w, err := createServiceNetworkingWaiter(config, op, project, activity, userAgent) - if err != nil { - // If w is nil, the op was synchronous. + if err := w.SetOp(op); err != nil { return err } return tpgresource.OperationWait(w, activity, timeout, config.PollInterval) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation_hw.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation_hw.go deleted file mode 100644 index b50c64c1cc2..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/servicenetworking/service_networking_operation_hw.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package servicenetworking - -import ( - "time" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "google.golang.org/api/servicenetworking/v1" -) - -type ServiceNetworkingOperationWaiterHW struct { - Service *servicenetworking.APIService - Project string - UserProjectOverride bool - tpgresource.CommonOperationWaiter -} - -func (w *ServiceNetworkingOperationWaiterHW) QueryOp() (interface{}, error) { - opGetCall := w.Service.Operations.Get(w.Op.Name) - if w.UserProjectOverride { - opGetCall.Header().Add("X-Goog-User-Project", w.Project) - } - return opGetCall.Do() -} - -func ServiceNetworkingOperationWaitTimeHW(config *transport_tpg.Config, op *servicenetworking.Operation, activity, userAgent, project string, timeout time.Duration) error { - w := &ServiceNetworkingOperationWaiterHW{ - Service: config.NewServiceNetworkingClient(userAgent), - Project: project, - UserProjectOverride: config.UserProjectOverride, - } - - if err := w.SetOp(op); err != nil { - return err - } - return tpgresource.OperationWait(w, activity, timeout, config.PollInterval) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sourcerepo/resource_sourcerepo_repository.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sourcerepo/resource_sourcerepo_repository.go index a2aadb12040..3d26796b31c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sourcerepo/resource_sourcerepo_repository.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sourcerepo/resource_sourcerepo_repository.go @@ -21,7 +21,6 @@ import ( "bytes" "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -173,7 +172,6 @@ func resourceSourceRepoRepositoryCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -182,7 +180,6 @@ func resourceSourceRepoRepositoryCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Repository: %s", err) @@ -231,14 +228,12 @@ func resourceSourceRepoRepositoryRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SourceRepoRepository %q", d.Id())) @@ -298,7 +293,6 @@ func resourceSourceRepoRepositoryUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Repository %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("pubsub_configs") { @@ -326,7 +320,6 @@ func resourceSourceRepoRepositoryUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -367,8 +360,6 @@ func resourceSourceRepoRepositoryDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Repository %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -378,7 +369,6 @@ func resourceSourceRepoRepositoryDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Repository") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_database.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_database.go index a7d7f7ecf28..5bdaa391a93 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_database.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_database.go @@ -21,8 +21,9 @@ import ( "context" "fmt" "log" - "net/http" "reflect" + "regexp" + "strconv" "strings" "time" @@ -66,6 +67,44 @@ func resourceSpannerDBDdlCustomDiff(_ context.Context, diff *schema.ResourceDiff return resourceSpannerDBDdlCustomDiffFunc(diff) } +func ValidateDatabaseRetentionPeriod(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + valueError := fmt.Errorf("version_retention_period should be in range [1h, 7d], in a format resembling 1d, 24h, 1440m, or 86400s") + + r := regexp.MustCompile("^(\\d{1}d|\\d{1,3}h|\\d{2,5}m|\\d{4,6}s)$") + if !r.MatchString(value) { + errors = append(errors, valueError) + return + } + + unit := value[len(value)-1:] + multiple := value[:len(value)-1] + num, err := strconv.Atoi(multiple) + if err != nil { + errors = append(errors, valueError) + return + } + + if unit == "d" && (num < 1 || num > 7) { + errors = append(errors, valueError) + return + } + if unit == "h" && (num < 1 || num > 7*24) { + errors = append(errors, valueError) + return + } + if unit == "m" && (num < 1*60 || num > 7*24*60) { + errors = append(errors, valueError) + return + } + if unit == "s" && (num < 1*60*60 || num > 7*24*60*60) { + errors = append(errors, valueError) + return + } + + return +} + func resourceSpannerDBVirtualUpdate(d *schema.ResourceData, resourceSchema map[string]*schema.Schema) bool { // deletion_protection is the only virtual field if d.HasChange("deletion_protection") { @@ -171,9 +210,10 @@ in the same location as the Spanner Database.`, }, }, "version_retention_period": { - Type: schema.TypeString, - Computed: true, - Optional: true, + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: ValidateDatabaseRetentionPeriod, Description: `The retention period for the database. The retention period must be between 1 hour and 7 days, and can be specified in days, hours, minutes, or seconds. For example, the values 1d, 24h, 1440m, and 86400s are equivalent. Default value is 1h. @@ -189,12 +229,8 @@ update the database's version_retention_period.`, Type: schema.TypeBool, Optional: true, Default: true, - Description: `Whether Terraform will be prevented from destroying the database. Defaults to true. -When a'terraform destroy' or 'terraform apply' would delete the database, -the command will fail if this field is not set to false in Terraform state. -When the field is set to true or unset in Terraform state, a 'terraform apply' -or 'terraform destroy' that would delete the database will fail. -When the field is set to false, deleting the database is allowed.`, + Description: `Whether or not to allow Terraform to destroy the database. Defaults to true. Unless this field is set to false +in Terraform state, a 'terraform destroy' or 'terraform apply' that would delete the database will fail.`, }, "project": { Type: schema.TypeString, @@ -282,7 +318,6 @@ func resourceSpannerDatabaseCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -291,7 +326,6 @@ func resourceSpannerDatabaseCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Database: %s", err) @@ -473,14 +507,12 @@ func resourceSpannerDatabaseRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SpannerDatabase %q", d.Id())) @@ -567,7 +599,6 @@ func resourceSpannerDatabaseUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Database %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("enable_drop_protection") { @@ -613,7 +644,6 @@ func resourceSpannerDatabaseUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -658,8 +688,6 @@ func resourceSpannerDatabaseUpdate(d *schema.ResourceData, meta interface{}) err return err } - headers := make(http.Header) - if obj["statements"] != nil { if len(obj["statements"].([]string)) == 0 { // Return early to avoid making an API call that errors, @@ -691,7 +719,6 @@ func resourceSpannerDatabaseUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Database %q: %s", d.Id(), err) @@ -739,7 +766,6 @@ func resourceSpannerDatabaseDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) if d.Get("deletion_protection").(bool) { return fmt.Errorf("cannot destroy instance without setting deletion_protection=false and running `terraform apply`") } @@ -753,7 +779,6 @@ func resourceSpannerDatabaseDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Database") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance.go index 8aa422069be..58ca5dd1cbd 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance.go @@ -20,14 +20,13 @@ package spanner import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -369,7 +368,6 @@ func resourceSpannerInstanceCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -378,7 +376,6 @@ func resourceSpannerInstanceCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -458,14 +455,12 @@ func resourceSpannerInstanceRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SpannerInstance %q", d.Id())) @@ -585,7 +580,6 @@ func resourceSpannerInstanceUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) if resourceSpannerInstanceVirtualUpdate(d, ResourceSpannerInstance().Schema) { if d.Get("force_destroy") != nil { if err := d.Set("force_destroy", d.Get("force_destroy")); err != nil { @@ -608,7 +602,6 @@ func resourceSpannerInstanceUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -655,8 +648,6 @@ func resourceSpannerInstanceDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - if d.Get("force_destroy").(bool) { backupsUrl, err := tpgresource.ReplaceVars(d, config, "{{SpannerBasePath}}projects/{{project}}/instances/{{name}}/backups") if err != nil { @@ -690,7 +681,6 @@ func resourceSpannerInstanceDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") @@ -1131,7 +1121,7 @@ func resourceSpannerInstanceEncoder(d *schema.ResourceData, meta interface{}, ob newObj := make(map[string]interface{}) newObj["instance"] = obj if obj["name"] == nil { - if err := d.Set("name", id.PrefixedUniqueId("tfgen-spanid-")[:30]); err != nil { + if err := d.Set("name", resource.PrefixedUniqueId("tfgen-spanid-")[:30]); err != nil { return nil, fmt.Errorf("Error setting name: %s", err) } newObj["instanceId"] = d.Get("name").(string) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance_config.go deleted file mode 100644 index 29f14ecfdf0..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance_config.go +++ /dev/null @@ -1,799 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package spanner - -import ( - "bytes" - "fmt" - "log" - "net/http" - "reflect" - "regexp" - "strings" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func replicasHash(v interface{}) int { - var buf bytes.Buffer - m := v.(map[string]interface{}) - buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["location"].(string)))) // ToLower just in case - buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["type"].(string)))) - var isLeader interface{} - if m["defaultLeaderLocation"] != nil { - isLeader = m["defaultLeaderLocation"] - } else { - isLeader = false - } - buf.WriteString(fmt.Sprintf("%v-", isLeader.(bool))) - return tpgresource.Hashcode(buf.String()) -} - -func getBaseInstanceConfigReplicas(d *schema.ResourceData, config *transport_tpg.Config, baseConfigProp interface{}, billingProject, userAgent string) ([]interface{}, error) { - url, err := tpgresource.ReplaceVars(d, config, "{{SpannerBasePath}}") - if err != nil { - return nil, err - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: fmt.Sprintf("%s%s", url, baseConfigProp.(string)), - UserAgent: userAgent, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return nil, fmt.Errorf("Error fetching base InstanceConfig: %s", err) - } - - data, ok := res["replicas"] - if !ok || data == nil { - log.Print("[DEBUG] No replicas in the base InstanceConfig.") - return nil, nil - } - - return data.([]interface{}), nil -} - -func ResourceSpannerInstanceConfig() *schema.Resource { - return &schema.Resource{ - Create: resourceSpannerInstanceConfigCreate, - Read: resourceSpannerInstanceConfigRead, - Update: resourceSpannerInstanceConfigUpdate, - Delete: resourceSpannerInstanceConfigDelete, - - Importer: &schema.ResourceImporter{ - State: resourceSpannerInstanceConfigImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Update: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.SetLabelsDiff, - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "display_name": { - Type: schema.TypeString, - Required: true, - Description: `The name of this instance configuration as it appears in UIs.`, - }, - "name": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `A unique identifier for the instance configuration. Values are of the -form projects//instanceConfigs/[a-z][-a-z0-9]*`, - }, - "replicas": { - Type: schema.TypeSet, - Required: true, - ForceNew: true, - Description: `The geographic placement of nodes in this instance configuration and their replication properties.`, - Elem: spannerInstanceConfigReplicasSchema(), - Set: replicasHash, - }, - "base_config": { - Type: schema.TypeString, - Computed: true, - Optional: true, - ForceNew: true, - Description: `Base configuration name, e.g. nam3, based on which this configuration is created. -Only set for user managed configurations. -baseConfig must refer to a configuration of type GOOGLE_MANAGED in the same project as this configuration.`, - }, - "labels": { - Type: schema.TypeMap, - Optional: true, - Description: `An object containing a list of "key": value pairs. -Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }. - - -**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. -Please refer to the field 'effective_labels' for all of the labels present on the resource.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "config_type": { - Type: schema.TypeString, - Computed: true, - Description: `Output only. Whether this instance config is a Google or User Managed Configuration.`, - }, - "effective_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "terraform_labels": { - Type: schema.TypeMap, - Computed: true, - Description: `The combination of labels configured directly on the resource - and default labels configured on the provider.`, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func spannerInstanceConfigReplicasSchema() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "default_leader_location": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: `If true, this location is designated as the default leader location where -leader replicas are placed.`, - Default: false, - }, - "location": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The location of the serving resources, e.g. "us-central1".`, - }, - "type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"READ_WRITE", "READ_ONLY", "WITNESS", ""}), - Description: `Indicates the type of replica. See the [replica types -documentation](https://cloud.google.com/spanner/docs/replication#replica_types) -for more details. Possible values: ["READ_WRITE", "READ_ONLY", "WITNESS"]`, - }, - }, - } -} - -func resourceSpannerInstanceConfigCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - nameProp, err := expandSpannerInstanceConfigName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - displayNameProp, err := expandSpannerInstanceConfigDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(displayNameProp)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - baseConfigProp, err := expandSpannerInstanceConfigBaseConfig(d.Get("base_config"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("base_config"); !tpgresource.IsEmptyValue(reflect.ValueOf(baseConfigProp)) && (ok || !reflect.DeepEqual(v, baseConfigProp)) { - obj["baseConfig"] = baseConfigProp - } - replicasProp, err := expandSpannerInstanceConfigReplicas(d.Get("replicas"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("replicas"); !tpgresource.IsEmptyValue(reflect.ValueOf(replicasProp)) && (ok || !reflect.DeepEqual(v, replicasProp)) { - obj["replicas"] = replicasProp - } - labelsProp, err := expandSpannerInstanceConfigEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(labelsProp)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - obj, err = resourceSpannerInstanceConfigEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SpannerBasePath}}projects/{{project}}/instanceConfigs") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new InstanceConfig: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceConfig: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating InstanceConfig: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // Use the resource in the operation response to populate - // identity fields and d.Id() before read - var opRes map[string]interface{} - err = SpannerOperationWaitTimeWithResponse( - config, res, &opRes, project, "Creating InstanceConfig", userAgent, - d.Timeout(schema.TimeoutCreate)) - if err != nil { - // The resource didn't actually create - d.SetId("") - - return fmt.Errorf("Error waiting to create InstanceConfig: %s", err) - } - - opRes, err = resourceSpannerInstanceConfigDecoder(d, meta, opRes) - if err != nil { - return fmt.Errorf("Error decoding response from operation: %s", err) - } - if opRes == nil { - return fmt.Errorf("Error decoding response from operation, could not find object") - } - - if err := d.Set("name", flattenSpannerInstanceConfigName(opRes["name"], d, config)); err != nil { - return err - } - - // This may have caused the ID to update - update it if so. - id, err = tpgresource.ReplaceVars(d, config, "{{project}}/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating InstanceConfig %q: %#v", d.Id(), res) - - return resourceSpannerInstanceConfigRead(d, meta) -} - -func resourceSpannerInstanceConfigRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SpannerBasePath}}projects/{{project}}/instanceConfigs/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceConfig: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SpannerInstanceConfig %q", d.Id())) - } - - res, err = resourceSpannerInstanceConfigDecoder(d, meta, res) - if err != nil { - return err - } - - if res == nil { - // Decoding the object has resulted in it being gone. It may be marked deleted - log.Printf("[DEBUG] Removing SpannerInstanceConfig because it no longer exists.") - d.SetId("") - return nil - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - - if err := d.Set("name", flattenSpannerInstanceConfigName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("display_name", flattenSpannerInstanceConfigDisplayName(res["displayName"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("base_config", flattenSpannerInstanceConfigBaseConfig(res["baseConfig"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("config_type", flattenSpannerInstanceConfigConfigType(res["configType"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("replicas", flattenSpannerInstanceConfigReplicas(res["replicas"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("labels", flattenSpannerInstanceConfigLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("terraform_labels", flattenSpannerInstanceConfigTerraformLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - if err := d.Set("effective_labels", flattenSpannerInstanceConfigEffectiveLabels(res["labels"], d, config)); err != nil { - return fmt.Errorf("Error reading InstanceConfig: %s", err) - } - - return nil -} - -func resourceSpannerInstanceConfigUpdate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceConfig: %s", err) - } - billingProject = project - - obj := make(map[string]interface{}) - displayNameProp, err := expandSpannerInstanceConfigDisplayName(d.Get("display_name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("display_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, displayNameProp)) { - obj["displayName"] = displayNameProp - } - labelsProp, err := expandSpannerInstanceConfigEffectiveLabels(d.Get("effective_labels"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("effective_labels"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, labelsProp)) { - obj["labels"] = labelsProp - } - - obj, err = resourceSpannerInstanceConfigUpdateEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{SpannerBasePath}}projects/{{project}}/instanceConfigs/{{name}}") - if err != nil { - return err - } - - log.Printf("[DEBUG] Updating InstanceConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) - updateMask := []string{} - - if d.HasChange("display_name") { - updateMask = append(updateMask, "displayName") - } - - if d.HasChange("effective_labels") { - updateMask = append(updateMask, "labels") - } - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) - - if err != nil { - return fmt.Errorf("Error updating InstanceConfig %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating InstanceConfig %q: %#v", d.Id(), res) - } - - err = SpannerOperationWaitTime( - config, res, project, "Updating InstanceConfig", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } - } - - return resourceSpannerInstanceConfigRead(d, meta) -} - -func resourceSpannerInstanceConfigDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for InstanceConfig: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{SpannerBasePath}}projects/{{project}}/instanceConfigs/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting InstanceConfig %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "InstanceConfig") - } - - log.Printf("[DEBUG] Finished deleting InstanceConfig %q: %#v", d.Id(), res) - return nil -} - -func resourceSpannerInstanceConfigImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/instanceConfigs/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenSpannerInstanceConfigName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSpannerInstanceConfigDisplayName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSpannerInstanceConfigBaseConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenSpannerInstanceConfigConfigType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSpannerInstanceConfigReplicas(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := schema.NewSet(replicasHash, []interface{}{}) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed.Add(map[string]interface{}{ - "location": flattenSpannerInstanceConfigReplicasLocation(original["location"], d, config), - "type": flattenSpannerInstanceConfigReplicasType(original["type"], d, config), - "default_leader_location": flattenSpannerInstanceConfigReplicasDefaultLeaderLocation(original["defaultLeaderLocation"], d, config), - }) - } - return transformed -} -func flattenSpannerInstanceConfigReplicasLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSpannerInstanceConfigReplicasType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSpannerInstanceConfigReplicasDefaultLeaderLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenSpannerInstanceConfigLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenSpannerInstanceConfigTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - - transformed := make(map[string]interface{}) - if l, ok := d.GetOkExists("terraform_labels"); ok { - for k := range l.(map[string]interface{}) { - transformed[k] = v.(map[string]interface{})[k] - } - } - - return transformed -} - -func flattenSpannerInstanceConfigEffectiveLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandSpannerInstanceConfigName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSpannerInstanceConfigDisplayName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSpannerInstanceConfigBaseConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - r := regexp.MustCompile("projects/(.+)/instanceConfigs/(.+)") - if r.MatchString(v.(string)) { - return v.(string), nil - } - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return nil, err - } - - return fmt.Sprintf("projects/%s/instanceConfigs/%s", project, v.(string)), nil -} - -func expandSpannerInstanceConfigReplicas(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - v = v.(*schema.Set).List() - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedLocation, err := expandSpannerInstanceConfigReplicasLocation(original["location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["location"] = transformedLocation - } - - transformedType, err := expandSpannerInstanceConfigReplicasType(original["type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["type"] = transformedType - } - - transformedDefaultLeaderLocation, err := expandSpannerInstanceConfigReplicasDefaultLeaderLocation(original["default_leader_location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedDefaultLeaderLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["defaultLeaderLocation"] = transformedDefaultLeaderLocation - } - - req = append(req, transformed) - } - return req, nil -} - -func expandSpannerInstanceConfigReplicasLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSpannerInstanceConfigReplicasType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSpannerInstanceConfigReplicasDefaultLeaderLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandSpannerInstanceConfigEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { - if v == nil { - return map[string]string{}, nil - } - m := make(map[string]string) - for k, val := range v.(map[string]interface{}) { - m[k] = val.(string) - } - return m, nil -} - -func resourceSpannerInstanceConfigEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - config := meta.(*transport_tpg.Config) - project, err := tpgresource.GetProject(d, config) - if err != nil { - return nil, err - } - newObj := make(map[string]interface{}) - if obj["name"] == nil { - return nil, fmt.Errorf("Error setting instance config name") - } - newObj["instanceConfigId"] = obj["name"] - obj["name"] = fmt.Sprintf("projects/%s/instanceConfigs/%s", project, obj["name"]) - baseReplicas, err := getBaseInstanceConfigReplicas(d, config, obj["baseConfig"], project, meta.(*transport_tpg.Config).UserAgent) - if err != nil { - return nil, err - } - r := obj["replicas"].([]interface{}) - obj["replicas"] = append(r, baseReplicas...) - newObj["instanceConfig"] = obj - return newObj, nil -} - -func resourceSpannerInstanceConfigUpdateEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - project, err := tpgresource.GetProject(d, meta.(*transport_tpg.Config)) - if err != nil { - return nil, err - } - obj["name"] = fmt.Sprintf("projects/%s/instanceConfigs/%s", project, obj["name"]) - newObj := make(map[string]interface{}) - newObj["instanceConfig"] = obj - return newObj, nil -} - -func resourceSpannerInstanceConfigDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) { - config := meta.(*transport_tpg.Config) - d.SetId(res["name"].(string)) - if err := tpgresource.ParseImportId([]string{"projects/(?P[^/]+)/instanceConfigs/(?P[^/]+)"}, d, config); err != nil { - return nil, err - } - res["project"] = d.Get("project").(string) - res["name"] = d.Get("name").(string) - id, err := tpgresource.ReplaceVars(d, config, "{{project}}/{{name}}") - if err != nil { - return nil, err - } - baseReplicas, err := getBaseInstanceConfigReplicas(d, config, res["baseConfig"], res["project"].(string), config.UserAgent) - if err != nil { - return nil, err - } - customReplica := make(map[int]interface{}) - for _, b := range baseReplicas { - customReplica[replicasHash(b)] = b - } - var cR []interface{} - for _, r := range res["replicas"].([]interface{}) { - if _, ok := customReplica[replicasHash(r)]; !ok { - cR = append(cR, r) - } - } - res["replicas"] = cR - d.SetId(id) - return res, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance_config_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance_config_sweeper.go deleted file mode 100644 index a8062d5b57f..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/spanner/resource_spanner_instance_config_sweeper.go +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package spanner - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("SpannerInstanceConfig", testSweepSpannerInstanceConfig) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepSpannerInstanceConfig(region string) error { - resourceName := "SpannerInstanceConfig" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://spanner.googleapis.com/v1/projects/{{project}}/instanceConfigs", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["instanceConfigs"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(strings.ReplaceAll(name, "custom-", "")) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://spanner.googleapis.com/v1/projects/{{project}}/instanceConfigs/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database.go index bcd1bd19d63..bf3b9121bbc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database.go @@ -20,7 +20,6 @@ package sql import ( "fmt" "log" - "net/http" "reflect" "time" @@ -171,7 +170,6 @@ func resourceSQLDatabaseCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -180,7 +178,6 @@ func resourceSQLDatabaseCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Database: %s", err) @@ -233,14 +230,12 @@ func resourceSQLDatabaseRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(transformSQLDatabaseReadError(err), d, fmt.Sprintf("SQLDatabase %q", d.Id())) @@ -329,7 +324,6 @@ func resourceSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { } log.Printf("[DEBUG] Updating Database %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -344,7 +338,6 @@ func resourceSQLDatabaseUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -398,7 +391,6 @@ func resourceSQLDatabaseDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) if deletionPolicy := d.Get("deletion_policy"); deletionPolicy == "ABANDON" { // Allows for database to be abandoned without deletion to avoid deletion failing // for Postgres databases in some circumstances due to existing SQL users @@ -414,7 +406,6 @@ func resourceSQLDatabaseDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Database") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database_instance.go index fbc6b9b7cd2..4dfb9b5fb19 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_database_instance.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/go-cty/cty" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -130,9 +130,9 @@ func ResourceSqlDatabaseInstance() *schema.Resource { }, Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(90 * time.Minute), - Update: schema.DefaultTimeout(90 * time.Minute), - Delete: schema.DefaultTimeout(90 * time.Minute), + Create: schema.DefaultTimeout(40 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), + Delete: schema.DefaultTimeout(30 * time.Minute), }, CustomizeDiff: customdiff.All( @@ -397,11 +397,6 @@ is set to true. Defaults to ZONAL.`, Default: 0, Description: `The maximum size, in GB, to which storage capacity can be automatically increased. The default value is 0, which specifies that there is no limit.`, }, - "enable_google_ml_integration": { - Type: schema.TypeBool, - Optional: true, - Description: `Enables Vertex AI Integration.`, - }, "disk_size": { Type: schema.TypeInt, Optional: true, @@ -443,7 +438,6 @@ is set to true. Defaults to ZONAL.`, Optional: true, AtLeastOneOf: ipConfigurationKeys, Description: `Whether SSL connections over IP are enforced or not. To change this field, also set the corresponding value in ssl_mode if it has been set too.`, - Deprecated: "`require_ssl` will be fully deprecated in a future major release. For now, please use `ssl_mode` with a compatible `require_ssl` value instead.", }, "private_network": { Type: schema.TypeString, @@ -493,7 +487,7 @@ is set to true. Defaults to ZONAL.`, Optional: true, Computed: true, ValidateFunc: validation.StringInSlice([]string{"ALLOW_UNENCRYPTED_AND_ENCRYPTED", "ENCRYPTED_ONLY", "TRUSTED_CLIENT_CERTIFICATE_REQUIRED"}, false), - Description: `Specify how SSL connection should be enforced in DB connections. This field provides more SSL enforcment options compared to require_ssl. To change this field, also set the correspoding value in require_ssl until next major release.`, + Description: `Specify how SSL connection should be enforced in DB connections. This field provides more SSL enforcment options compared to require_ssl. To change this field, also set the correspoding value in require_ssl.`, AtLeastOneOf: ipConfigurationKeys, }, }, @@ -550,7 +544,7 @@ is set to true. Defaults to ZONAL.`, Type: schema.TypeString, Optional: true, AtLeastOneOf: maintenanceWindowKeys, - Description: `Receive updates after one week (canary) or after two weeks (stable) or after five weeks (week5) of notification.`, + Description: `Receive updates earlier (canary) or later (stable)`, }, }, }, @@ -1054,7 +1048,7 @@ func resourceSqlDatabaseInstanceCreate(d *schema.ResourceData, meta interface{}) if v, ok := d.GetOk("name"); ok { name = v.(string) } else { - name = id.UniqueId() + name = resource.UniqueId() } if err := d.Set("name", name); err != nil { @@ -1274,7 +1268,7 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}, databaseVersion Tier: _settings["tier"].(string), Edition: _settings["edition"].(string), AdvancedMachineFeatures: expandSqlServerAdvancedMachineFeatures(_settings["advanced_machine_features"].([]interface{})), - ForceSendFields: []string{"StorageAutoResize", "EnableGoogleMlIntegration"}, + ForceSendFields: []string{"StorageAutoResize"}, ActivationPolicy: _settings["activation_policy"].(string), ActiveDirectoryConfig: expandActiveDirectoryConfig(_settings["active_directory_config"].([]interface{})), DenyMaintenancePeriods: expandDenyMaintenancePeriod(_settings["deny_maintenance_period"].([]interface{})), @@ -1287,7 +1281,6 @@ func expandSqlDatabaseInstanceSettings(configured []interface{}, databaseVersion DataDiskType: _settings["disk_type"].(string), PricingPlan: _settings["pricing_plan"].(string), DeletionProtectionEnabled: _settings["deletion_protection_enabled"].(bool), - EnableGoogleMlIntegration: _settings["enable_google_ml_integration"].(bool), UserLabels: tpgresource.ConvertStringMap(_settings["user_labels"].(map[string]interface{})), BackupConfiguration: expandBackupConfiguration(_settings["backup_configuration"].([]interface{})), DatabaseFlags: expandDatabaseFlags(_settings["database_flags"].(*schema.Set).List()), @@ -1939,11 +1932,6 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) instance.InstanceType = d.Get("instance_type").(string) } - // Database Version is required for all calls with Google ML integration enabled or it will be rejected by the API. - if d.Get("settings.0.enable_google_ml_integration").(bool) { - instance.DatabaseVersion = databaseVersion - } - err = transport_tpg.Retry(transport_tpg.RetryOptions{ RetryFunc: func() (rerr error) { op, rerr = config.NewSqlAdminClient(userAgent).Instances.Update(project, d.Get("name").(string), instance).Do() @@ -2111,8 +2099,6 @@ func flattenSettings(settings *sqladmin.Settings, d *schema.ResourceData) []map[ data["disk_autoresize"] = settings.StorageAutoResize data["disk_autoresize_limit"] = settings.StorageAutoResizeLimit - data["enable_google_ml_integration"] = settings.EnableGoogleMlIntegration - if settings.UserLabels != nil { data["user_labels"] = settings.UserLabels } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_source_representation_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_source_representation_instance.go index e020355334c..d1a073c70b0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_source_representation_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_source_representation_instance.go @@ -20,7 +20,6 @@ package sql import ( "fmt" "log" - "net/http" "reflect" "strconv" "strings" @@ -199,7 +198,6 @@ func resourceSQLSourceRepresentationInstanceCreate(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -208,7 +206,6 @@ func resourceSQLSourceRepresentationInstanceCreate(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating SourceRepresentationInstance: %s", err) @@ -261,14 +258,12 @@ func resourceSQLSourceRepresentationInstanceRead(d *schema.ResourceData, meta in billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("SQLSourceRepresentationInstance %q", d.Id())) @@ -345,8 +340,6 @@ func resourceSQLSourceRepresentationInstanceDelete(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting SourceRepresentationInstance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -356,7 +349,6 @@ func resourceSQLSourceRepresentationInstanceDelete(d *schema.ResourceData, meta UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "SourceRepresentationInstance") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_user.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_user.go index 06aecb190ec..f309c7a4eac 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_user.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/sql/resource_sql_user.go @@ -95,7 +95,7 @@ func ResourceSqlUser() *schema.Resource { Optional: true, Sensitive: true, Description: `The password for the user. Can be updated. For Postgres instances this is a Required field, unless type is set to - either CLOUD_IAM_USER or CLOUD_IAM_SERVICE_ACCOUNT.`, + either CLOUD_IAM_USER or CLOUD_IAM_SERVICE_ACCOUNT.`, }, "type": { @@ -104,7 +104,8 @@ func ResourceSqlUser() *schema.Resource { ForceNew: true, DiffSuppressFunc: tpgresource.EmptyOrDefaultStringSuppress("BUILT_IN"), Description: `The user type. It determines the method to authenticate the user during login. - The default is the database's built-in user type.`, + The default is the database's built-in user type. Flags include "BUILT_IN", "CLOUD_IAM_USER", "CLOUD_IAM_GROUP" or "CLOUD_IAM_SERVICE_ACCOUNT".`, + ValidateFunc: validation.StringInSlice([]string{"BUILT_IN", "CLOUD_IAM_USER", "CLOUD_IAM_GROUP", "CLOUD_IAM_SERVICE_ACCOUNT", ""}, false), }, "sql_server_user_details": { Type: schema.TypeList, diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket.go index 78f30e6c484..33a46a3555d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket.go @@ -14,7 +14,6 @@ func DataSourceGoogleStorageBucket() *schema.Resource { dsSchema := tpgresource.DatasourceSchemaFromResourceSchema(ResourceStorageBucket().Schema) - tpgresource.AddOptionalFieldsToSchema(dsSchema, "project") tpgresource.AddRequiredFieldsToSchema(dsSchema, "name") return &schema.Resource{ diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_object.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_object.go index 42cd71d6c11..3858ec91d24 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_object.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_object.go @@ -43,10 +43,7 @@ func dataSourceGoogleStorageBucketObjectRead(d *schema.ResourceData, meta interf name = url.QueryEscape(name) } // Using REST apis because the storage go client doesn't support folders - url, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("{{StorageBasePath}}b/%s/o/%s", bucket, name)) - if err != nil { - return fmt.Errorf("Error formatting url for storage bucket object: %s", err) - } + url := fmt.Sprintf("https://www.googleapis.com/storage/v1/b/%s/o/%s", bucket, name) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_objects.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_objects.go deleted file mode 100644 index a193b710827..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_bucket_objects.go +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package storage - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleStorageBucketObjects() *schema.Resource { - return &schema.Resource{ - Read: datasourceGoogleStorageBucketObjectsRead, - Schema: map[string]*schema.Schema{ - "bucket": { - Type: schema.TypeString, - Required: true, - }, - "match_glob": { - Type: schema.TypeString, - Optional: true, - }, - "prefix": { - Type: schema.TypeString, - Optional: true, - }, - "bucket_objects": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "content_type": { - Type: schema.TypeString, - Computed: true, - }, - "media_link": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - }, - "storage_class": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func datasourceGoogleStorageBucketObjectsRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - params := make(map[string]string) - bucketObjects := make([]map[string]interface{}, 0) - - for { - bucket := d.Get("bucket").(string) - url, err := tpgresource.ReplaceVars(d, config, fmt.Sprintf("{{StorageBasePath}}b/%s/o", bucket)) - if err != nil { - return err - } - - if v, ok := d.GetOk("match_glob"); ok { - params["matchGlob"] = v.(string) - } - - if v, ok := d.GetOk("prefix"); ok { - params["prefix"] = v.(string) - } - - url, err = transport_tpg.AddQueryParams(url, params) - if err != nil { - return err - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return fmt.Errorf("Error retrieving bucket objects: %s", err) - } - - pageBucketObjects := flattenDatasourceGoogleBucketObjectsList(res["items"]) - bucketObjects = append(bucketObjects, pageBucketObjects...) - - pToken, ok := res["nextPageToken"] - if ok && pToken != nil && pToken.(string) != "" { - params["pageToken"] = pToken.(string) - } else { - break - } - } - - if err := d.Set("bucket_objects", bucketObjects); err != nil { - return fmt.Errorf("Error retrieving bucket_objects: %s", err) - } - - d.SetId(d.Get("bucket").(string)) - - return nil -} - -func flattenDatasourceGoogleBucketObjectsList(v interface{}) []map[string]interface{} { - if v == nil { - return make([]map[string]interface{}, 0) - } - - ls := v.([]interface{}) - bucketObjects := make([]map[string]interface{}, 0, len(ls)) - for _, raw := range ls { - o := raw.(map[string]interface{}) - - var mContentType, mMediaLink, mName, mSelfLink, mStorageClass interface{} - if oContentType, ok := o["contentType"]; ok { - mContentType = oContentType - } - if oMediaLink, ok := o["mediaLink"]; ok { - mMediaLink = oMediaLink - } - if oName, ok := o["name"]; ok { - mName = oName - } - if oSelfLink, ok := o["selfLink"]; ok { - mSelfLink = oSelfLink - } - if oStorageClass, ok := o["storageClass"]; ok { - mStorageClass = oStorageClass - } - bucketObjects = append(bucketObjects, map[string]interface{}{ - "content_type": mContentType, - "media_link": mMediaLink, - "name": mName, - "self_link": mSelfLink, - "storage_class": mStorageClass, - }) - } - - return bucketObjects -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_buckets.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_buckets.go deleted file mode 100644 index c3af9cec566..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/data_source_google_storage_buckets.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package storage - -import ( - "fmt" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func DataSourceGoogleStorageBuckets() *schema.Resource { - return &schema.Resource{ - Read: datasourceGoogleStorageBucketsRead, - Schema: map[string]*schema.Schema{ - "prefix": { - Type: schema.TypeString, - Optional: true, - }, - "project": { - Type: schema.TypeString, - Optional: true, - }, - "buckets": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "labels": { - Type: schema.TypeMap, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "location": { - Type: schema.TypeString, - Computed: true, - }, - "name": { - Type: schema.TypeString, - Computed: true, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - }, - "storage_class": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func datasourceGoogleStorageBucketsRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - params := make(map[string]string) - buckets := make([]map[string]interface{}, 0) - - for { - url := "https://storage.googleapis.com/storage/v1/b" - - params["project"], err = tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for bucket: %s", err) - } - - if v, ok := d.GetOk("prefix"); ok { - params["prefix"] = v.(string) - } - - url, err = transport_tpg.AddQueryParams(url, params) - if err != nil { - return err - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - }) - if err != nil { - return fmt.Errorf("Error retrieving buckets: %s", err) - } - - pageBuckets := flattenDatasourceGoogleBucketsList(res["items"]) - buckets = append(buckets, pageBuckets...) - - pToken, ok := res["nextPageToken"] - if ok && pToken != nil && pToken.(string) != "" { - params["pageToken"] = pToken.(string) - } else { - break - } - } - - if err := d.Set("buckets", buckets); err != nil { - return fmt.Errorf("Error retrieving buckets: %s", err) - } - - d.SetId(params["project"]) - - return nil -} - -func flattenDatasourceGoogleBucketsList(v interface{}) []map[string]interface{} { - if v == nil { - return make([]map[string]interface{}, 0) - } - - ls := v.([]interface{}) - buckets := make([]map[string]interface{}, 0, len(ls)) - for _, raw := range ls { - o := raw.(map[string]interface{}) - - var mLabels, mLocation, mName, mSelfLink, mStorageClass interface{} - if oLabels, ok := o["labels"]; ok { - mLabels = oLabels - } - if oLocation, ok := o["location"]; ok { - mLocation = oLocation - } - if oName, ok := o["name"]; ok { - mName = oName - } - if oSelfLink, ok := o["selfLink"]; ok { - mSelfLink = oSelfLink - } - if oStorageClass, ok := o["storageClass"]; ok { - mStorageClass = oStorageClass - } - buckets = append(buckets, map[string]interface{}{ - "labels": mLabels, - "location": mLocation, - "name": mName, - "self_link": mSelfLink, - "storage_class": mStorageClass, - }) - } - - return buckets -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/iam_storage_managed_folder.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/iam_storage_managed_folder.go deleted file mode 100644 index f09254363a0..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/iam_storage_managed_folder.go +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package storage - -import ( - "fmt" - "net/url" - - "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "google.golang.org/api/cloudresourcemanager/v1" - - "github.com/hashicorp/terraform-provider-google/google/tpgiamresource" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -var StorageManagedFolderIamSchema = map[string]*schema.Schema{ - "bucket": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "managed_folder": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - ValidateFunc: verify.ValidateRegexp(`/$`), - }, -} - -type StorageManagedFolderIamUpdater struct { - bucket string - managedFolder string - d tpgresource.TerraformResourceData - Config *transport_tpg.Config -} - -func StorageManagedFolderIamUpdaterProducer(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (tpgiamresource.ResourceIamUpdater, error) { - values := make(map[string]string) - - if v, ok := d.GetOk("bucket"); ok { - values["bucket"] = v.(string) - } - - if v, ok := d.GetOk("managed_folder"); ok { - values["managed_folder"] = v.(string) - } - - u := &StorageManagedFolderIamUpdater{ - bucket: values["bucket"], - managedFolder: values["managed_folder"], - d: d, - Config: config, - } - - if err := d.Set("bucket", u.bucket); err != nil { - return nil, fmt.Errorf("Error setting bucket: %s", err) - } - if err := d.Set("managed_folder", u.managedFolder); err != nil { - return nil, fmt.Errorf("Error setting managed_folder: %s", err) - } - - return u, nil -} - -func StorageManagedFolderIdParseFunc(d *schema.ResourceData, config *transport_tpg.Config) error { - values := make(map[string]string) - - m, err := tpgresource.GetImportIdQualifiers([]string{"(?P[^/]+)/managedFolders/(?P.+)", "(?P[^/]+)/(?P.+)"}, d, config, d.Id()) - if err != nil { - return err - } - - for k, v := range m { - values[k] = v - } - - u := &StorageManagedFolderIamUpdater{ - bucket: values["bucket"], - managedFolder: values["managed_folder"], - d: d, - Config: config, - } - if err := d.Set("bucket", u.bucket); err != nil { - return fmt.Errorf("Error setting bucket: %s", err) - } - if err := d.Set("managed_folder", u.managedFolder); err != nil { - return fmt.Errorf("Error setting managed_folder: %s", err) - } - d.SetId(u.GetResourceId()) - return nil -} - -func (u *StorageManagedFolderIamUpdater) GetResourceIamPolicy() (*cloudresourcemanager.Policy, error) { - url, err := u.qualifyManagedFolderUrl("iam") - if err != nil { - return nil, err - } - - var obj map[string]interface{} - url, err = transport_tpg.AddQueryParams(url, map[string]string{"optionsRequestedPolicyVersion": fmt.Sprintf("%d", tpgiamresource.IamPolicyVersion)}) - if err != nil { - return nil, err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return nil, err - } - - policy, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "GET", - RawURL: url, - UserAgent: userAgent, - Body: obj, - }) - if err != nil { - return nil, errwrap.Wrapf(fmt.Sprintf("Error retrieving IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - out := &cloudresourcemanager.Policy{} - err = tpgresource.Convert(policy, out) - if err != nil { - return nil, errwrap.Wrapf("Cannot convert a policy to a resource manager policy: {{err}}", err) - } - - return out, nil -} - -func (u *StorageManagedFolderIamUpdater) SetResourceIamPolicy(policy *cloudresourcemanager.Policy) error { - json, err := tpgresource.ConvertToMap(policy) - if err != nil { - return err - } - - obj := json - - url, err := u.qualifyManagedFolderUrl("iam") - if err != nil { - return err - } - - userAgent, err := tpgresource.GenerateUserAgentString(u.d, u.Config.UserAgent) - if err != nil { - return err - } - - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: u.Config, - Method: "PUT", - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: u.d.Timeout(schema.TimeoutCreate), - }) - if err != nil { - return errwrap.Wrapf(fmt.Sprintf("Error setting IAM policy for %s: {{err}}", u.DescribeResource()), err) - } - - return nil -} - -func (u *StorageManagedFolderIamUpdater) qualifyManagedFolderUrl(methodIdentifier string) (string, error) { - urlTemplate := fmt.Sprintf("{{StorageBasePath}}b/%s/managedFolders/%s/%s", u.bucket, url.PathEscape(u.managedFolder), methodIdentifier) - url, err := tpgresource.ReplaceVars(u.d, u.Config, urlTemplate) - if err != nil { - return "", err - } - return url, nil -} - -func (u *StorageManagedFolderIamUpdater) GetResourceId() string { - return fmt.Sprintf("b/%s/managedFolders/%s", u.bucket, u.managedFolder) -} - -func (u *StorageManagedFolderIamUpdater) GetMutexKey() string { - return fmt.Sprintf("iam-storage-managedfolder-%s", u.GetResourceId()) -} - -func (u *StorageManagedFolderIamUpdater) DescribeResource() string { - return fmt.Sprintf("storage managedfolder %q", u.GetResourceId()) -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket.go index 1ac1a847b75..16f0611343d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket.go @@ -9,7 +9,6 @@ import ( "fmt" "log" "math" - "regexp" "runtime" "strconv" "strings" @@ -17,11 +16,10 @@ import ( "github.com/hashicorp/terraform-provider-google/google/tpgresource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" "github.com/gammazero/workerpool" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -60,11 +58,10 @@ func ResourceStorageBucket() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The name of the bucket.`, - ValidateFunc: verify.ValidateGCSName, + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: `The name of the bucket.`, }, "encryption": { @@ -97,11 +94,10 @@ func ResourceStorageBucket() *schema.Resource { }, "labels": { - Type: schema.TypeMap, - ValidateFunc: labelKeyValidator, - Optional: true, - Elem: &schema.Schema{Type: schema.TypeString}, - Description: `A set of key/value label pairs to assign to the bucket.`, + Type: schema.TypeMap, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: `A set of key/value label pairs to assign to the bucket.`, }, "terraform_labels": { @@ -136,12 +132,6 @@ func ResourceStorageBucket() *schema.Resource { Description: `The ID of the project in which the resource belongs. If it is not provided, the provider project is used.`, }, - "project_number": { - Type: schema.TypeInt, - Computed: true, - Description: `The project number of the project in which the resource belongs.`, - }, - "self_link": { Type: schema.TypeString, Computed: true, @@ -263,21 +253,6 @@ func ResourceStorageBucket() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Description: `One or more matching name suffixes to satisfy this condition.`, }, - "send_days_since_noncurrent_time_if_zero": { - Type: schema.TypeBool, - Optional: true, - Description: `While set true, days_since_noncurrent_time value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the days_since_noncurrent_time field. It can be used alone or together with days_since_noncurrent_time.`, - }, - "send_days_since_custom_time_if_zero": { - Type: schema.TypeBool, - Optional: true, - Description: `While set true, days_since_custom_time value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the days_since_custom_time field. It can be used alone or together with days_since_custom_time.`, - }, - "send_num_newer_versions_if_zero": { - Type: schema.TypeBool, - Optional: true, - Description: `While set true, num_newer_versions value will be sent in the request even for zero value of the field. This field is only useful for setting 0 value to the num_newer_versions field. It can be used alone or together with num_newer_versions.`, - }, }, }, Description: `The Lifecycle Rule's condition configuration.`, @@ -347,14 +322,6 @@ func ResourceStorageBucket() *schema.Resource { return true } } - if new == "0" && old == "1" { - n := d.Get(strings.TrimSuffix(k, ".#")) - l = n.([]interface{}) - contents := l[0].(map[string]interface{}) - if contents["enabled"] == false { - return true - } - } return false }, }, @@ -497,9 +464,6 @@ func ResourceStorageBucket() *schema.Resource { MinItems: 2, Elem: &schema.Schema{ Type: schema.TypeString, - StateFunc: func(s interface{}) string { - return strings.ToUpper(s.(string)) - }, }, Description: `The list of individual regions that comprise a dual-region bucket. See the docs for a list of acceptable regions. Note: If any of the data_locations changes, it will recreate the bucket.`, }, @@ -519,28 +483,6 @@ func ResourceStorageBucket() *schema.Resource { Computed: true, Description: `Prevents public access to a bucket.`, }, - "soft_delete_policy": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Computed: true, - Description: `The bucket's soft delete policy, which defines the period of time that soft-deleted objects will be retained, and cannot be permanently deleted. If it is not provided, by default Google Cloud Storage sets this to default soft delete policy`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "retention_duration_seconds": { - Type: schema.TypeInt, - Default: 604800, - Optional: true, - Description: `The duration in seconds that soft-deleted objects in the bucket will be retained and cannot be permanently deleted. Default value is 604800.`, - }, - "effective_time": { - Type: schema.TypeString, - Computed: true, - Description: `Server-determined value that indicates the time from which the policy, or one with a greater retention, was effective. This value is in RFC 3339 format.`, - }, - }, - }, - }, }, UseJSONNumber: true, } @@ -549,22 +491,6 @@ func ResourceStorageBucket() *schema.Resource { const resourceDataplexGoogleLabelPrefix = "goog-dataplex" const resourceDataplexGoogleProvidedLabelPrefix = "labels." + resourceDataplexGoogleLabelPrefix -var labelKeyRegex = regexp.MustCompile(`^[a-z0-9_-]{1,63}$`) - -func labelKeyValidator(val interface{}, key string) (warns []string, errs []error) { - if val == nil { - return - } - - m := val.(map[string]interface{}) - for k := range m { - if !labelKeyRegex.MatchString(k) { - errs = append(errs, fmt.Errorf("%q is an invalid label key. See https://cloud.google.com/storage/docs/tags-and-labels#bucket-labels", k)) - } - } - return -} - func resourceDataplexLabelDiffSuppress(k, old, new string, d *schema.ResourceData) bool { if strings.HasPrefix(k, resourceDataplexGoogleProvidedLabelPrefix) && new == "" { return true @@ -607,6 +533,9 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error // Get the bucket and location bucket := d.Get("name").(string) + if err := tpgresource.CheckGCSName(bucket); err != nil { + return err + } location := d.Get("location").(string) // Create a bucket, setting the labels, location and name. @@ -684,10 +613,6 @@ func resourceStorageBucketCreate(d *schema.ResourceData, meta interface{}) error sb.Rpo = v.(string) } - if v, ok := d.GetOk("soft_delete_policy"); ok { - sb.SoftDeletePolicy = expandBucketSoftDeletePolicy(v.([]interface{})) - } - var res *storage.Bucket err = transport_tpg.Retry(transport_tpg.RetryOptions{ @@ -781,11 +706,6 @@ func resourceStorageBucketUpdate(d *schema.ResourceData, meta interface{}) error if d.HasChange("autoclass") { if v, ok := d.GetOk("autoclass"); ok { sb.Autoclass = expandBucketAutoclass(v) - } else { - sb.Autoclass = &storage.BucketAutoclass{ - Enabled: false, - ForceSendFields: []string{"Enabled"}, - } } } @@ -865,12 +785,6 @@ func resourceStorageBucketUpdate(d *schema.ResourceData, meta interface{}) error } } - if d.HasChange("soft_delete_policy") { - if v, ok := d.GetOk("soft_delete_policy"); ok { - sb.SoftDeletePolicy = expandBucketSoftDeletePolicy(v.([]interface{})) - } - } - res, err := config.NewStorageClient(userAgent).Buckets.Patch(d.Get("name").(string), sb).Do() if err != nil { return err @@ -1030,15 +944,15 @@ func resourceStorageBucketDelete(d *schema.ResourceData, meta interface{}) error } // remove empty bucket - err = retry.Retry(1*time.Minute, func() *retry.RetryError { + err = resource.Retry(1*time.Minute, func() *resource.RetryError { err := config.NewStorageClient(userAgent).Buckets.Delete(bucket).Do() if err == nil { return nil } if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 429 { - return retry.RetryableError(gerr) + return resource.RetryableError(gerr) } - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) }) if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == 409 && strings.Contains(gerr.Message, "not empty") && listError != nil { return fmt.Errorf("could not delete non-empty bucket due to error when listing contents: %v", listError) @@ -1173,15 +1087,9 @@ func flattenBucketCustomPlacementConfig(cfc *storage.BucketCustomPlacementConfig func expandBucketDataLocations(configured interface{}) []string { l := configured.(*schema.Set).List() - // Since we only want uppercase values to prevent unnecessary diffs, we can do a comparison - // to determine whether or not to include the value as part of the request. - - // This extra check comes from the limitations of both DiffStateFunc and StateFunc towards types of Sets,Lists, and Maps. req := make([]string, 0, len(l)) for _, raw := range l { - if raw.(string) == strings.ToUpper(raw.(string)) { - req = append(req, raw.(string)) - } + req = append(req, raw.(string)) } return req } @@ -1259,32 +1167,6 @@ func flattenBucketObjectRetention(bucketObjectRetention *storage.BucketObjectRet return false } -func expandBucketSoftDeletePolicy(configured interface{}) *storage.BucketSoftDeletePolicy { - configuredSoftDeletePolicies := configured.([]interface{}) - if len(configuredSoftDeletePolicies) == 0 { - return nil - } - configuredSoftDeletePolicy := configuredSoftDeletePolicies[0].(map[string]interface{}) - softDeletePolicy := &storage.BucketSoftDeletePolicy{ - RetentionDurationSeconds: int64(configuredSoftDeletePolicy["retention_duration_seconds"].(int)), - } - softDeletePolicy.ForceSendFields = append(softDeletePolicy.ForceSendFields, "RetentionDurationSeconds") - return softDeletePolicy -} - -func flattenBucketSoftDeletePolicy(softDeletePolicy *storage.BucketSoftDeletePolicy) []map[string]interface{} { - policies := make([]map[string]interface{}, 0, 1) - if softDeletePolicy == nil { - return policies - } - policy := map[string]interface{}{ - "retention_duration_seconds": softDeletePolicy.RetentionDurationSeconds, - "effective_time": softDeletePolicy.EffectiveTime, - } - policies = append(policies, policy) - return policies -} - func expandBucketVersioning(configured interface{}) *storage.BucketVersioning { versionings := configured.([]interface{}) if len(versionings) == 0 { @@ -1401,9 +1283,6 @@ func flattenBucketLifecycleRuleCondition(index int, d *schema.ResourceData, cond if v, ok := d.GetOk(fmt.Sprintf("lifecycle_rule.%d.condition", index)); ok { state_condition := v.(*schema.Set).List()[0].(map[string]interface{}) ruleCondition["no_age"] = state_condition["no_age"].(bool) - ruleCondition["send_days_since_noncurrent_time_if_zero"] = state_condition["send_days_since_noncurrent_time_if_zero"].(bool) - ruleCondition["send_days_since_custom_time_if_zero"] = state_condition["send_days_since_custom_time_if_zero"].(bool) - ruleCondition["send_num_newer_versions_if_zero"] = state_condition["send_num_newer_versions_if_zero"].(bool) } return ruleCondition @@ -1596,9 +1475,6 @@ func expandStorageBucketLifecycleRuleCondition(v interface{}) (*storage.BucketLi if v, ok := condition["num_newer_versions"]; ok { transformed.NumNewerVersions = int64(v.(int)) - if u, ok := condition["send_num_newer_versions_if_zero"]; ok && u.(bool) { - transformed.ForceSendFields = append(transformed.ForceSendFields, "NumNewerVersions") - } } if v, ok := condition["custom_time_before"]; ok { @@ -1607,16 +1483,10 @@ func expandStorageBucketLifecycleRuleCondition(v interface{}) (*storage.BucketLi if v, ok := condition["days_since_custom_time"]; ok { transformed.DaysSinceCustomTime = int64(v.(int)) - if u, ok := condition["send_days_since_custom_time_if_zero"]; ok && u.(bool) { - transformed.ForceSendFields = append(transformed.ForceSendFields, "DaysSinceCustomTime") - } } if v, ok := condition["days_since_noncurrent_time"]; ok { transformed.DaysSinceNoncurrentTime = int64(v.(int)) - if u, ok := condition["send_days_since_noncurrent_time_if_zero"]; ok && u.(bool) { - transformed.ForceSendFields = append(transformed.ForceSendFields, "DaysSinceNoncurrentTime") - } } if v, ok := condition["noncurrent_time_before"]; ok { @@ -1690,14 +1560,6 @@ func resourceGCSBucketLifecycleRuleConditionHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } - if v, ok := m["custom_time_before"]; ok { - buf.WriteString(fmt.Sprintf("%s-", v.(string))) - } - - if v, ok := m["noncurrent_time_before"]; ok { - buf.WriteString(fmt.Sprintf("%s-", v.(string))) - } - withStateV, withStateOk := m["with_state"] if withStateOk { switch withStateV.(string) { @@ -1719,18 +1581,6 @@ func resourceGCSBucketLifecycleRuleConditionHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%d-", v.(int))) } - if v, ok := m["send_days_since_noncurrent_time_if_zero"]; ok { - buf.WriteString(fmt.Sprintf("%t-", v.(bool))) - } - - if v, ok := m["send_days_since_custom_time_if_zero"]; ok { - buf.WriteString(fmt.Sprintf("%t-", v.(bool))) - } - - if v, ok := m["send_num_newer_versions_if_zero"]; ok { - buf.WriteString(fmt.Sprintf("%t-", v.(bool))) - } - if v, ok := m["matches_prefix"]; ok { matches_prefixes := v.([]interface{}) for _, matches_prefix := range matches_prefixes { @@ -1811,9 +1661,6 @@ func setStorageBucket(d *schema.ResourceData, config *transport_tpg.Config, res if err := d.Set("url", fmt.Sprintf("gs://%s", bucket)); err != nil { return fmt.Errorf("Error setting url: %s", err) } - if err := d.Set("project_number", res.ProjectNumber); err != nil { - return fmt.Errorf("Error setting project_number: %s", err) - } if err := d.Set("storage_class", res.StorageClass); err != nil { return fmt.Errorf("Error setting storage_class: %s", err) } @@ -1871,9 +1718,6 @@ func setStorageBucket(d *schema.ResourceData, config *transport_tpg.Config, res return fmt.Errorf("Error setting RPO setting : %s", err) } } - if err := d.Set("soft_delete_policy", flattenBucketSoftDeletePolicy(res.SoftDeletePolicy)); err != nil { - return fmt.Errorf("Error setting soft_delete_policy: %s", err) - } if res.IamConfiguration != nil && res.IamConfiguration.UniformBucketLevelAccess != nil { if err := d.Set("uniform_bucket_level_access", res.IamConfiguration.UniformBucketLevelAccess.Enabled); err != nil { return fmt.Errorf("Error setting uniform_bucket_level_access: %s", err) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_access_control.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_access_control.go index fbab617a721..71bbb2df413 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_access_control.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_access_control.go @@ -20,7 +20,6 @@ package storage import ( "fmt" "log" - "net/http" "reflect" "time" @@ -144,7 +143,6 @@ func resourceStorageBucketAccessControlCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -153,7 +151,6 @@ func resourceStorageBucketAccessControlCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating BucketAccessControl: %s", err) @@ -190,14 +187,12 @@ func resourceStorageBucketAccessControlRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageBucketAccessControl %q", d.Id())) @@ -264,7 +259,6 @@ func resourceStorageBucketAccessControlUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating BucketAccessControl %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -279,7 +273,6 @@ func resourceStorageBucketAccessControlUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -319,8 +312,6 @@ func resourceStorageBucketAccessControlDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting BucketAccessControl %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -330,7 +321,6 @@ func resourceStorageBucketAccessControlDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "BucketAccessControl") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_object.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_object.go index de943829d13..3a738a0d9bf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_object.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_bucket_object.go @@ -1,6 +1,5 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -// SPDX-License-Identifier: MPL-2.0 package storage import ( @@ -91,6 +90,7 @@ func ResourceStorageBucketObject() *schema.Resource { "content": { Type: schema.TypeString, Optional: true, + ForceNew: true, ExactlyOneOf: []string{"source"}, Sensitive: true, Computed: true, @@ -122,6 +122,7 @@ func ResourceStorageBucketObject() *schema.Resource { Type: schema.TypeString, // This field is not Computed because it needs to trigger a diff. Optional: true, + ForceNew: true, // Makes the diff message nicer: // detect_md5hash: "1XcnP/iFw/hNrbhXi7QTmQ==" => "different hash" (forces new resource) // Instead of the more confusing: @@ -377,53 +378,45 @@ func resourceStorageBucketObjectUpdate(d *schema.ResourceData, meta interface{}) bucket := d.Get("bucket").(string) name := d.Get("name").(string) - if d.HasChange("content") || d.HasChange("detect_md5hash") { - // The KMS key name are not able to be set on create : - // or you get error: Error uploading object test-maarc: googleapi: Error 400: Malformed Cloud KMS crypto key: projects/myproject/locations/myregion/keyRings/mykeyring/cryptoKeys/mykeyname/cryptoKeyVersions/1, invalid - d.Set("kms_key_name", nil) - return resourceStorageBucketObjectCreate(d, meta) - } else { - - objectsService := storage.NewObjectsService(config.NewStorageClientWithTimeoutOverride(userAgent, d.Timeout(schema.TimeoutUpdate))) - getCall := objectsService.Get(bucket, name) - - res, err := getCall.Do() - if err != nil { - return fmt.Errorf("Error retrieving object during update %s: %s", name, err) - } + objectsService := storage.NewObjectsService(config.NewStorageClientWithTimeoutOverride(userAgent, d.Timeout(schema.TimeoutUpdate))) + getCall := objectsService.Get(bucket, name) - hasRetentionChanges := d.HasChange("retention") - if hasRetentionChanges { - if v, ok := d.GetOk("retention"); ok { - res.Retention = expandObjectRetention(v) - } else { - res.Retention = nil - res.NullFields = append(res.NullFields, "Retention") - } - } + res, err := getCall.Do() + if err != nil { + return fmt.Errorf("Error retrieving object during update %s: %s", name, err) + } - if d.HasChange("event_based_hold") { - v := d.Get("event_based_hold") - res.EventBasedHold = v.(bool) + hasRetentionChanges := d.HasChange("retention") + if hasRetentionChanges { + if v, ok := d.GetOk("retention"); ok { + res.Retention = expandObjectRetention(v) + } else { + res.Retention = nil + res.NullFields = append(res.NullFields, "Retention") } + } - if d.HasChange("temporary_hold") { - v := d.Get("temporary_hold") - res.TemporaryHold = v.(bool) - } + if d.HasChange("event_based_hold") { + v := d.Get("event_based_hold") + res.EventBasedHold = v.(bool) + } - updateCall := objectsService.Update(bucket, name, res) - if hasRetentionChanges { - updateCall.OverrideUnlockedRetention(true) - } - _, err = updateCall.Do() + if d.HasChange("temporary_hold") { + v := d.Get("temporary_hold") + res.TemporaryHold = v.(bool) + } - if err != nil { - return fmt.Errorf("Error updating object %s: %s", name, err) - } + updateCall := objectsService.Update(bucket, name, res) + if hasRetentionChanges { + updateCall.OverrideUnlockedRetention(true) + } + _, err = updateCall.Do() - return nil + if err != nil { + return fmt.Errorf("Error updating object %s: %s", name, err) } + + return nil } func resourceStorageBucketObjectRead(d *schema.ResourceData, meta interface{}) error { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_default_object_access_control.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_default_object_access_control.go index b766bcd253f..ac36c86fa4c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_default_object_access_control.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_default_object_access_control.go @@ -20,7 +20,6 @@ package storage import ( "fmt" "log" - "net/http" "reflect" "time" @@ -177,7 +176,6 @@ func resourceStorageDefaultObjectAccessControlCreate(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -186,7 +184,6 @@ func resourceStorageDefaultObjectAccessControlCreate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating DefaultObjectAccessControl: %s", err) @@ -223,14 +220,12 @@ func resourceStorageDefaultObjectAccessControlRead(d *schema.ResourceData, meta billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageDefaultObjectAccessControl %q", d.Id())) @@ -312,7 +307,6 @@ func resourceStorageDefaultObjectAccessControlUpdate(d *schema.ResourceData, met } log.Printf("[DEBUG] Updating DefaultObjectAccessControl %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -327,7 +321,6 @@ func resourceStorageDefaultObjectAccessControlUpdate(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -367,8 +360,6 @@ func resourceStorageDefaultObjectAccessControlDelete(d *schema.ResourceData, met billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting DefaultObjectAccessControl %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -378,7 +369,6 @@ func resourceStorageDefaultObjectAccessControlDelete(d *schema.ResourceData, met UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "DefaultObjectAccessControl") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_hmac_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_hmac_key.go index 3a528a21862..93956c66560 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_hmac_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_hmac_key.go @@ -20,7 +20,6 @@ package storage import ( "fmt" "log" - "net/http" "reflect" "time" @@ -139,7 +138,6 @@ func resourceStorageHmacKeyCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -148,7 +146,6 @@ func resourceStorageHmacKeyCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating HmacKey: %s", err) @@ -274,14 +271,12 @@ func resourceStorageHmacKeyRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageHmacKey %q", d.Id())) @@ -377,8 +372,6 @@ func resourceStorageHmacKeyUpdate(d *schema.ResourceData, meta interface{}) erro return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -392,7 +385,6 @@ func resourceStorageHmacKeyUpdate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating HmacKey %q: %s", d.Id(), err) @@ -434,7 +426,6 @@ func resourceStorageHmacKeyDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) getUrl, err := tpgresource.ReplaceVars(d, config, "{{StorageBasePath}}projects/{{project}}/hmacKeys/{{access_id}}") if err != nil { return err @@ -484,7 +475,6 @@ func resourceStorageHmacKeyDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "HmacKey") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_managed_folder.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_managed_folder.go deleted file mode 100644 index 86fce4baf82..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_managed_folder.go +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package storage - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - "github.com/hashicorp/terraform-provider-google/google/verify" -) - -func ResourceStorageManagedFolder() *schema.Resource { - return &schema.Resource{ - Create: resourceStorageManagedFolderCreate, - Read: resourceStorageManagedFolderRead, - Delete: resourceStorageManagedFolderDelete, - - Importer: &schema.ResourceImporter{ - State: resourceStorageManagedFolderImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "bucket": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName, - Description: `The name of the bucket that contains the managed folder.`, - }, - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: verify.ValidateRegexp(`/$`), - Description: `The name of the managed folder expressed as a path. Must include -trailing '/'. For example, 'example_dir/example_dir2/'.`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp at which this managed folder was created.`, - }, - "metageneration": { - Type: schema.TypeString, - Computed: true, - Description: `The metadata generation of the managed folder.`, - }, - "update_time": { - Type: schema.TypeString, - Computed: true, - Description: `The timestamp at which this managed folder was most recently updated.`, - }, - "self_link": { - Type: schema.TypeString, - Computed: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceStorageManagedFolderCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - bucketProp, err := expandStorageManagedFolderBucket(d.Get("bucket"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("bucket"); !tpgresource.IsEmptyValue(reflect.ValueOf(bucketProp)) && (ok || !reflect.DeepEqual(v, bucketProp)) { - obj["bucket"] = bucketProp - } - nameProp, err := expandStorageManagedFolderName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - - url, err := tpgresource.ReplaceVars(d, config, "{{StorageBasePath}}b/{{bucket}}/managedFolders") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new ManagedFolder: %#v", obj) - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating ManagedFolder: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "{{bucket}}/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating ManagedFolder %q: %#v", d.Id(), res) - - return resourceStorageManagedFolderRead(d, meta) -} - -func resourceStorageManagedFolderRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{StorageBasePath}}b/{{bucket}}/managedFolders/{{%name}}") - if err != nil { - return err - } - - billingProject := "" - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageManagedFolder %q", d.Id())) - } - - if err := d.Set("create_time", flattenStorageManagedFolderCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedFolder: %s", err) - } - if err := d.Set("update_time", flattenStorageManagedFolderUpdateTime(res["updateTime"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedFolder: %s", err) - } - if err := d.Set("metageneration", flattenStorageManagedFolderMetageneration(res["metageneration"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedFolder: %s", err) - } - if err := d.Set("bucket", flattenStorageManagedFolderBucket(res["bucket"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedFolder: %s", err) - } - if err := d.Set("name", flattenStorageManagedFolderName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading ManagedFolder: %s", err) - } - if err := d.Set("self_link", tpgresource.ConvertSelfLinkToV1(res["selfLink"].(string))); err != nil { - return fmt.Errorf("Error reading ManagedFolder: %s", err) - } - - return nil -} - -func resourceStorageManagedFolderDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - url, err := tpgresource.ReplaceVars(d, config, "{{StorageBasePath}}b/{{bucket}}/managedFolders/{{%name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting ManagedFolder %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "ManagedFolder") - } - - log.Printf("[DEBUG] Finished deleting ManagedFolder %q: %#v", d.Id(), res) - return nil -} - -func resourceStorageManagedFolderImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^(?P[^/]+)/managedFolders/(?P.+)$", - "^(?P[^/]+)/(?P.+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "{{bucket}}/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenStorageManagedFolderCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenStorageManagedFolderUpdateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenStorageManagedFolderMetageneration(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenStorageManagedFolderBucket(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.ConvertSelfLinkToV1(v.(string)) -} - -func flattenStorageManagedFolderName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandStorageManagedFolderBucket(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandStorageManagedFolderName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_object_access_control.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_object_access_control.go index 921adb82f75..12dfd004502 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_object_access_control.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storage/resource_storage_object_access_control.go @@ -20,7 +20,6 @@ package storage import ( "fmt" "log" - "net/http" "reflect" "time" @@ -177,7 +176,6 @@ func resourceStorageObjectAccessControlCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -186,7 +184,6 @@ func resourceStorageObjectAccessControlCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ObjectAccessControl: %s", err) @@ -223,14 +220,12 @@ func resourceStorageObjectAccessControlRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageObjectAccessControl %q", d.Id())) @@ -315,7 +310,6 @@ func resourceStorageObjectAccessControlUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating ObjectAccessControl %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -330,7 +324,6 @@ func resourceStorageObjectAccessControlUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -370,8 +363,6 @@ func resourceStorageObjectAccessControlDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ObjectAccessControl %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -381,7 +372,6 @@ func resourceStorageObjectAccessControlDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ObjectAccessControl") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storageinsights/resource_storage_insights_report_config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storageinsights/resource_storage_insights_report_config.go index 1139177cbed..0260fead9c3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storageinsights/resource_storage_insights_report_config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storageinsights/resource_storage_insights_report_config.go @@ -20,7 +20,6 @@ package storageinsights import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -280,7 +279,6 @@ func resourceStorageInsightsReportConfigCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -289,7 +287,6 @@ func resourceStorageInsightsReportConfigCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ReportConfig: %s", err) @@ -335,14 +332,12 @@ func resourceStorageInsightsReportConfigRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageInsightsReportConfig %q", d.Id())) @@ -418,7 +413,6 @@ func resourceStorageInsightsReportConfigUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating ReportConfig %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("frequency_options") { @@ -460,7 +454,6 @@ func resourceStorageInsightsReportConfigUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -501,8 +494,6 @@ func resourceStorageInsightsReportConfigDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ReportConfig %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -512,7 +503,6 @@ func resourceStorageInsightsReportConfigDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ReportConfig") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_agent_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_agent_pool.go index 8a35965f807..83e89e14744 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_agent_pool.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_agent_pool.go @@ -20,13 +20,12 @@ package storagetransfer import ( "fmt" "log" - "net/http" "reflect" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -36,20 +35,20 @@ import ( // waitForAgentPoolReady waits for an agent pool to leave the // "CREATING" state and become "CREATED", to indicate that it's ready. func waitForAgentPoolReady(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceStorageTransferAgentPoolRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) state := d.Get("state").(string) if state == "CREATING" { - return retry.RetryableError(fmt.Errorf("AgentPool %q has state %q.", name, state)) + return resource.RetryableError(fmt.Errorf("AgentPool %q has state %q.", name, state)) } else if state == "CREATED" { log.Printf("[DEBUG] AgentPool %q has state %q.", name, state) return nil } else { - return retry.NonRetryableError(fmt.Errorf("AgentPool %q has state %q.", name, state)) + return resource.NonRetryableError(fmt.Errorf("AgentPool %q has state %q.", name, state)) } }) } @@ -167,7 +166,6 @@ func resourceStorageTransferAgentPoolCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -176,7 +174,6 @@ func resourceStorageTransferAgentPoolCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating AgentPool: %s", err) @@ -223,14 +220,12 @@ func resourceStorageTransferAgentPoolRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("StorageTransferAgentPool %q", d.Id())) @@ -288,7 +283,6 @@ func resourceStorageTransferAgentPoolUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating AgentPool %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -323,7 +317,6 @@ func resourceStorageTransferAgentPoolUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -364,8 +357,6 @@ func resourceStorageTransferAgentPoolDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting AgentPool %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -375,7 +366,6 @@ func resourceStorageTransferAgentPoolDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "AgentPool") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_job.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_job.go index a4dbcab5e58..38949752b2e 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_job.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/storagetransfer/resource_storage_transfer_job.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-provider-google/google/verify" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "google.golang.org/api/storagetransfer/v1" @@ -804,10 +804,10 @@ func resourceStorageTransferJobDelete(d *schema.ResourceData, meta interface{}) // Update transfer job with status set to DELETE log.Printf("[DEBUG] Setting status to DELETE for: %v\n\n", transferJobName) - err = retry.Retry(1*time.Minute, func() *retry.RetryError { + err = resource.Retry(1*time.Minute, func() *resource.RetryError { _, err := config.NewStorageTransferClient(userAgent).TransferJobs.Patch(transferJobName, updateRequest).Do() if err != nil { - return retry.RetryableError(err) + return resource.RetryableError(err) } return nil @@ -1044,9 +1044,10 @@ func flattenAwsS3Data(awsS3Data *storagetransfer.AwsS3Data, d *schema.ResourceDa "path": awsS3Data.Path, "role_arn": awsS3Data.RoleArn, } - if _, exist := d.GetOkExists("transfer_spec.0.aws_s3_data_source.0.aws_access_key"); exist { + if awsS3Data.AwsAccessKey != nil { data["aws_access_key"] = flattenAwsAccessKeys(d) } + return []map[string]interface{}{data} } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/data_source_tags_tag_keys.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/data_source_tags_tag_keys.go deleted file mode 100644 index a4eec113edd..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/data_source_tags_tag_keys.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package tags - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func DataSourceGoogleTagsTagKeys() *schema.Resource { - return &schema.Resource{ - Read: dataSourceGoogleTagsTagKeysRead, - - Schema: map[string]*schema.Schema{ - "parent": { - Type: schema.TypeString, - Required: true, - }, - "keys": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: tpgresource.DatasourceSchemaFromResourceSchema(ResourceTagsTagKey().Schema), - }, - }, - }, - } -} - -func dataSourceGoogleTagsTagKeysRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - parent := d.Get("parent").(string) - token := "" - - tagKeys := make([]map[string]interface{}, 0) - - for paginate := true; paginate; { - resp, err := config.NewResourceManagerV3Client(userAgent).TagKeys.List().Parent(parent).PageSize(300).PageToken(token).Do() - if err != nil { - return fmt.Errorf("error reading tag key list: %s", err) - } - - for _, tagKey := range resp.TagKeys { - - mappedData := map[string]interface{}{ - "name": tagKey.Name, - "namespaced_name": tagKey.NamespacedName, - "short_name": tagKey.ShortName, - "parent": tagKey.Parent, - "create_time": tagKey.CreateTime, - "update_time": tagKey.UpdateTime, - "description": tagKey.Description, - "purpose": tagKey.Purpose, - "purpose_data": tagKey.PurposeData, - } - tagKeys = append(tagKeys, mappedData) - } - token = resp.NextPageToken - paginate = token != "" - } - - d.SetId(parent) - if err := d.Set("keys", tagKeys); err != nil { - return fmt.Errorf("Error setting tag key name: %s", err) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/data_source_tags_tag_values.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/data_source_tags_tag_values.go deleted file mode 100644 index a0e607a4217..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/data_source_tags_tag_values.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package tags - -import ( - "fmt" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" -) - -func DataSourceGoogleTagsTagValues() *schema.Resource { - return &schema.Resource{ - Read: dataSourceGoogleTagsTagValuesRead, - - Schema: map[string]*schema.Schema{ - "parent": { - Type: schema.TypeString, - Required: true, - }, - "values": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: tpgresource.DatasourceSchemaFromResourceSchema(ResourceTagsTagValue().Schema), - }, - }, - }, - } -} - -func dataSourceGoogleTagsTagValuesRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - parent := d.Get("parent").(string) - token := "" - - tagValues := make([]map[string]interface{}, 0) - - for paginate := true; paginate; { - resp, err := config.NewResourceManagerV3Client(userAgent).TagValues.List().Parent(parent).PageSize(300).PageToken(token).Do() - if err != nil { - return fmt.Errorf("error reading tag value list: %s", err) - } - - for _, tagValue := range resp.TagValues { - mappedData := map[string]interface{}{ - "name": tagValue.Name, - "namespaced_name": tagValue.NamespacedName, - "short_name": tagValue.ShortName, - "parent": tagValue.Parent, - "create_time": tagValue.CreateTime, - "update_time": tagValue.UpdateTime, - "description": tagValue.Description, - } - - tagValues = append(tagValues, mappedData) - } - token = resp.NextPageToken - paginate = token != "" - } - - d.SetId(parent) - - if err := d.Set("values", tagValues); err != nil { - return fmt.Errorf("Error setting tag values: %s", err) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_binding.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_binding.go index c8dbec11419..47ba4914cf4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_binding.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_binding.go @@ -20,7 +20,6 @@ package tags import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -110,7 +109,6 @@ func resourceTagsTagBindingCreate(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -119,7 +117,6 @@ func resourceTagsTagBindingCreate(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TagBinding: %s", err) @@ -190,14 +187,12 @@ func resourceTagsTagBindingRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("TagsTagBinding %q", d.Id())) @@ -256,8 +251,6 @@ func resourceTagsTagBindingDelete(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TagBinding %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -267,7 +260,6 @@ func resourceTagsTagBindingDelete(d *schema.ResourceData, meta interface{}) erro UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TagBinding") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_key.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_key.go index c82deb40282..2cad0fffb80 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_key.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_key.go @@ -20,7 +20,6 @@ package tags import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -179,7 +178,6 @@ func resourceTagsTagKeyCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -188,7 +186,6 @@ func resourceTagsTagKeyCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TagKey: %s", err) @@ -249,14 +246,12 @@ func resourceTagsTagKeyRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("TagsTagKey %q", d.Id())) @@ -320,7 +315,6 @@ func resourceTagsTagKeyUpdate(d *schema.ResourceData, meta interface{}) error { } log.Printf("[DEBUG] Updating TagKey %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -348,7 +342,6 @@ func resourceTagsTagKeyUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -397,8 +390,6 @@ func resourceTagsTagKeyDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TagKey %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -408,7 +399,6 @@ func resourceTagsTagKeyDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TagKey") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_value.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_value.go index f9d40f2aa5e..d22ba87d446 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_value.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tags/resource_tags_tag_value.go @@ -20,7 +20,6 @@ package tags import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -146,7 +145,6 @@ func resourceTagsTagValueCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -155,7 +153,6 @@ func resourceTagsTagValueCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating TagValue: %s", err) @@ -216,14 +213,12 @@ func resourceTagsTagValueRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("TagsTagValue %q", d.Id())) @@ -284,7 +279,6 @@ func resourceTagsTagValueUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating TagValue %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -312,7 +306,6 @@ func resourceTagsTagValueUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -361,8 +354,6 @@ func resourceTagsTagValueDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting TagValue %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -372,7 +363,6 @@ func resourceTagsTagValueDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "TagValue") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tpu/resource_tpu_node.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tpu/resource_tpu_node.go index 089afe4d1e2..8c473544d4c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tpu/resource_tpu_node.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/tpu/resource_tpu_node.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "regexp" "time" @@ -340,7 +339,6 @@ func resourceTPUNodeCreate(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -349,7 +347,6 @@ func resourceTPUNodeCreate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Node: %s", err) @@ -416,14 +413,12 @@ func resourceTPUNodeRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("TPUNode %q", d.Id())) @@ -508,8 +503,6 @@ func resourceTPUNodeUpdate(d *schema.ResourceData, meta interface{}) error { return err } - headers := make(http.Header) - // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { billingProject = bp @@ -523,7 +516,6 @@ func resourceTPUNodeUpdate(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error updating Node %q: %s", d.Id(), err) @@ -571,8 +563,6 @@ func resourceTPUNodeDelete(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Node %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -582,7 +572,6 @@ func resourceTPUNodeDelete(d *schema.ResourceData, meta interface{}) error { UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Node") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_dataset.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_dataset.go index 220b33f2810..bc6ddbb8d02 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_dataset.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_dataset.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -188,7 +187,6 @@ func resourceVertexAIDatasetCreate(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -197,7 +195,6 @@ func resourceVertexAIDatasetCreate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Dataset: %s", err) @@ -264,14 +261,12 @@ func resourceVertexAIDatasetRead(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIDataset %q", d.Id())) @@ -347,7 +342,6 @@ func resourceVertexAIDatasetUpdate(d *schema.ResourceData, meta interface{}) err } log.Printf("[DEBUG] Updating Dataset %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -379,7 +373,6 @@ func resourceVertexAIDatasetUpdate(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -420,8 +413,6 @@ func resourceVertexAIDatasetDelete(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Dataset %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -431,7 +422,6 @@ func resourceVertexAIDatasetDelete(d *schema.ResourceData, meta interface{}) err UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Dataset") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go deleted file mode 100644 index e372e7232ab..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_deployment_resource_pool.go +++ /dev/null @@ -1,672 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package vertexai - -import ( - "fmt" - "log" - "net/http" - "reflect" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func ResourceVertexAIDeploymentResourcePool() *schema.Resource { - return &schema.Resource{ - Create: resourceVertexAIDeploymentResourcePoolCreate, - Read: resourceVertexAIDeploymentResourcePoolRead, - Delete: resourceVertexAIDeploymentResourcePoolDelete, - - Importer: &schema.ResourceImporter{ - State: resourceVertexAIDeploymentResourcePoolImport, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(20 * time.Minute), - Delete: schema.DefaultTimeout(20 * time.Minute), - }, - - CustomizeDiff: customdiff.All( - tpgresource.DefaultProviderProject, - ), - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The resource name of deployment resource pool. The maximum length is 63 characters, and valid characters are '/^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$/'.`, - }, - "dedicated_resources": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `The underlying dedicated resources that the deployment resource pool uses.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "machine_spec": { - Type: schema.TypeList, - Required: true, - ForceNew: true, - Description: `The specification of a single machine used by the prediction`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "accelerator_count": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `The number of accelerators to attach to the machine.`, - }, - "accelerator_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The type of accelerator(s) that may be attached to the machine as per accelerator_count. See possible values [here](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/MachineSpec#AcceleratorType).`, - }, - "machine_type": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The type of the machine. See the [list of machine types supported for prediction](https://cloud.google.com/vertex-ai/docs/predictions/configure-compute#machine-types).`, - }, - }, - }, - }, - "min_replica_count": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: `The minimum number of machine replicas this DeployedModel will be always deployed on. This value must be greater than or equal to 1. If traffic against the DeployedModel increases, it may dynamically be deployed onto more replicas, and as traffic decreases, some of these extra replicas may be freed.`, - }, - "autoscaling_metric_specs": { - Type: schema.TypeList, - Optional: true, - ForceNew: true, - Description: `A list of the metric specifications that overrides a resource utilization metric.`, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "metric_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: `The resource metric name. Supported metrics: For Online Prediction: * 'aiplatform.googleapis.com/prediction/online/accelerator/duty_cycle' * 'aiplatform.googleapis.com/prediction/online/cpu/utilization'`, - }, - "target": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `The target resource utilization in percentage (1% - 100%) for the given metric; once the real usage deviates from the target by a certain percentage, the machine replicas change. The default value is 60 (representing 60%) if not provided.`, - }, - }, - }, - }, - "max_replica_count": { - Type: schema.TypeInt, - Optional: true, - ForceNew: true, - Description: `The maximum number of replicas this DeployedModel may be deployed on when the traffic against it increases. If the requested value is too large, the deployment will error, but if deployment succeeds then the ability to scale the model to that many replicas is guaranteed (barring service outages). If traffic against the DeployedModel increases beyond what its replicas at maximum may handle, a portion of the traffic will be dropped. If this value is not provided, will use min_replica_count as the default value. The value of this field impacts the charge against Vertex CPU and GPU quotas. Specifically, you will be charged for max_replica_count * number of cores in the selected machine type) and (max_replica_count * number of GPUs per replica in the selected machine type).`, - }, - }, - }, - }, - "region": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: `The region of deployment resource pool. eg us-central1`, - }, - "create_time": { - Type: schema.TypeString, - Computed: true, - Description: `A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits.`, - }, - "project": { - Type: schema.TypeString, - Optional: true, - Computed: true, - ForceNew: true, - }, - }, - UseJSONNumber: true, - } -} - -func resourceVertexAIDeploymentResourcePoolCreate(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - obj := make(map[string]interface{}) - nameProp, err := expandVertexAIDeploymentResourcePoolName(d.Get("name"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("name"); !tpgresource.IsEmptyValue(reflect.ValueOf(nameProp)) && (ok || !reflect.DeepEqual(v, nameProp)) { - obj["name"] = nameProp - } - dedicatedResourcesProp, err := expandVertexAIDeploymentResourcePoolDedicatedResources(d.Get("dedicated_resources"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dedicated_resources"); !tpgresource.IsEmptyValue(reflect.ValueOf(dedicatedResourcesProp)) && (ok || !reflect.DeepEqual(v, dedicatedResourcesProp)) { - obj["dedicatedResources"] = dedicatedResourcesProp - } - - obj, err = resourceVertexAIDeploymentResourcePoolEncoder(d, meta, obj) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{VertexAIBasePath}}projects/{{project}}/locations/{{region}}/deploymentResourcePools") - if err != nil { - return err - } - - log.Printf("[DEBUG] Creating new DeploymentResourcePool: %#v", obj) - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for DeploymentResourcePool: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, - }) - if err != nil { - return fmt.Errorf("Error creating DeploymentResourcePool: %s", err) - } - - // Store the ID now - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/deploymentResourcePools/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - // Use the resource in the operation response to populate - // identity fields and d.Id() before read - var opRes map[string]interface{} - err = VertexAIOperationWaitTimeWithResponse( - config, res, &opRes, project, "Creating DeploymentResourcePool", userAgent, - d.Timeout(schema.TimeoutCreate)) - if err != nil { - // The resource didn't actually create - d.SetId("") - - return fmt.Errorf("Error waiting to create DeploymentResourcePool: %s", err) - } - - if err := d.Set("name", flattenVertexAIDeploymentResourcePoolName(opRes["name"], d, config)); err != nil { - return err - } - - // This may have caused the ID to update - update it if so. - id, err = tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/deploymentResourcePools/{{name}}") - if err != nil { - return fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - log.Printf("[DEBUG] Finished creating DeploymentResourcePool %q: %#v", d.Id(), res) - - return resourceVertexAIDeploymentResourcePoolRead(d, meta) -} - -func resourceVertexAIDeploymentResourcePoolRead(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - url, err := tpgresource.ReplaceVars(d, config, "{{VertexAIBasePath}}projects/{{project}}/locations/{{region}}/deploymentResourcePools/{{name}}") - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for DeploymentResourcePool: %s", err) - } - billingProject = project - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIDeploymentResourcePool %q", d.Id())) - } - - if err := d.Set("project", project); err != nil { - return fmt.Errorf("Error reading DeploymentResourcePool: %s", err) - } - - if err := d.Set("name", flattenVertexAIDeploymentResourcePoolName(res["name"], d, config)); err != nil { - return fmt.Errorf("Error reading DeploymentResourcePool: %s", err) - } - if err := d.Set("dedicated_resources", flattenVertexAIDeploymentResourcePoolDedicatedResources(res["dedicatedResources"], d, config)); err != nil { - return fmt.Errorf("Error reading DeploymentResourcePool: %s", err) - } - if err := d.Set("create_time", flattenVertexAIDeploymentResourcePoolCreateTime(res["createTime"], d, config)); err != nil { - return fmt.Errorf("Error reading DeploymentResourcePool: %s", err) - } - - return nil -} - -func resourceVertexAIDeploymentResourcePoolDelete(d *schema.ResourceData, meta interface{}) error { - config := meta.(*transport_tpg.Config) - userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent) - if err != nil { - return err - } - - billingProject := "" - - project, err := tpgresource.GetProject(d, config) - if err != nil { - return fmt.Errorf("Error fetching project for DeploymentResourcePool: %s", err) - } - billingProject = project - - url, err := tpgresource.ReplaceVars(d, config, "{{VertexAIBasePath}}projects/{{project}}/locations/{{region}}/deploymentResourcePools/{{name}}") - if err != nil { - return err - } - - var obj map[string]interface{} - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp - } - - headers := make(http.Header) - - log.Printf("[DEBUG] Deleting DeploymentResourcePool %q", d.Id()) - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, - }) - if err != nil { - return transport_tpg.HandleNotFoundError(err, d, "DeploymentResourcePool") - } - - err = VertexAIOperationWaitTime( - config, res, project, "Deleting DeploymentResourcePool", userAgent, - d.Timeout(schema.TimeoutDelete)) - - if err != nil { - return err - } - - log.Printf("[DEBUG] Finished deleting DeploymentResourcePool %q: %#v", d.Id(), res) - return nil -} - -func resourceVertexAIDeploymentResourcePoolImport(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { - config := meta.(*transport_tpg.Config) - if err := tpgresource.ParseImportId([]string{ - "^projects/(?P[^/]+)/locations/(?P[^/]+)/deploymentResourcePools/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)/(?P[^/]+)$", - "^(?P[^/]+)$", - }, d, config); err != nil { - return nil, err - } - - // Replace import id for the resource id - id, err := tpgresource.ReplaceVars(d, config, "projects/{{project}}/locations/{{region}}/deploymentResourcePools/{{name}}") - if err != nil { - return nil, fmt.Errorf("Error constructing id: %s", err) - } - d.SetId(id) - - return []*schema.ResourceData{d}, nil -} - -func flattenVertexAIDeploymentResourcePoolName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - return tpgresource.NameFromSelfLinkStateFunc(v) -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResources(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["machine_spec"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpec(original["machineSpec"], d, config) - transformed["min_replica_count"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesMinReplicaCount(original["minReplicaCount"], d, config) - transformed["max_replica_count"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesMaxReplicaCount(original["maxReplicaCount"], d, config) - transformed["autoscaling_metric_specs"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecs(original["autoscalingMetricSpecs"], d, config) - return []interface{}{transformed} -} -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpec(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["machine_type"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecMachineType(original["machineType"], d, config) - transformed["accelerator_type"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorType(original["acceleratorType"], d, config) - transformed["accelerator_count"] = - flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorCount(original["acceleratorCount"], d, config) - return []interface{}{transformed} -} -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecMachineType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesMinReplicaCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesMaxReplicaCount(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecs(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return v - } - l := v.([]interface{}) - transformed := make([]interface{}, 0, len(l)) - for _, raw := range l { - original := raw.(map[string]interface{}) - if len(original) < 1 { - // Do not include empty json objects coming back from the api - continue - } - transformed = append(transformed, map[string]interface{}{ - "metric_name": flattenVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsMetricName(original["metricName"], d, config), - "target": flattenVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsTarget(original["target"], d, config), - }) - } - return transformed -} -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsMetricName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsTarget(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - // Handles the string fixed64 format - if strVal, ok := v.(string); ok { - if intVal, err := tpgresource.StringToFixed64(strVal); err == nil { - return intVal - } - } - - // number values are represented as float64 - if floatVal, ok := v.(float64); ok { - intVal := int(floatVal) - return intVal - } - - return v // let terraform core handle it otherwise -} - -func flattenVertexAIDeploymentResourcePoolCreateTime(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func expandVertexAIDeploymentResourcePoolName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResources(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMachineSpec, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpec(original["machine_spec"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMachineSpec); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["machineSpec"] = transformedMachineSpec - } - - transformedMinReplicaCount, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesMinReplicaCount(original["min_replica_count"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMinReplicaCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["minReplicaCount"] = transformedMinReplicaCount - } - - transformedMaxReplicaCount, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesMaxReplicaCount(original["max_replica_count"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMaxReplicaCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["maxReplicaCount"] = transformedMaxReplicaCount - } - - transformedAutoscalingMetricSpecs, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecs(original["autoscaling_metric_specs"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAutoscalingMetricSpecs); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["autoscalingMetricSpecs"] = transformedAutoscalingMetricSpecs - } - - return transformed, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpec(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMachineType, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecMachineType(original["machine_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMachineType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["machineType"] = transformedMachineType - } - - transformedAcceleratorType, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorType(original["accelerator_type"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAcceleratorType); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["acceleratorType"] = transformedAcceleratorType - } - - transformedAcceleratorCount, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorCount(original["accelerator_count"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedAcceleratorCount); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["acceleratorCount"] = transformedAcceleratorCount - } - - return transformed, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecMachineType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesMachineSpecAcceleratorCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesMinReplicaCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesMaxReplicaCount(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecs(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - req := make([]interface{}, 0, len(l)) - for _, raw := range l { - if raw == nil { - continue - } - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedMetricName, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsMetricName(original["metric_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedMetricName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["metricName"] = transformedMetricName - } - - transformedTarget, err := expandVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsTarget(original["target"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedTarget); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["target"] = transformedTarget - } - - req = append(req, transformed) - } - return req, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsMetricName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIDeploymentResourcePoolDedicatedResourcesAutoscalingMetricSpecsTarget(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func resourceVertexAIDeploymentResourcePoolEncoder(d *schema.ResourceData, meta interface{}, obj map[string]interface{}) (map[string]interface{}, error) { - newObj := make(map[string]interface{}) - newObj["deploymentResourcePool"] = obj - nameProp, ok := d.GetOk("name") - if ok && nameProp != nil { - newObj["deploymentResourcePoolId"] = nameProp - } - return newObj, nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_sweeper.go deleted file mode 100644 index 3fe1e13286e..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_deployment_resource_pool_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -// ---------------------------------------------------------------------------- -// -// *** AUTO GENERATED CODE *** Type: MMv1 *** -// -// ---------------------------------------------------------------------------- -// -// This file is automatically generated by Magic Modules and manual -// changes will be clobbered when the file is regenerated. -// -// Please read more about how to change this file in -// .github/CONTRIBUTING.md. -// -// ---------------------------------------------------------------------------- - -package vertexai - -import ( - "context" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("VertexAIDeploymentResourcePool", testSweepVertexAIDeploymentResourcePool) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepVertexAIDeploymentResourcePool(region string) error { - resourceName := "VertexAIDeploymentResourcePool" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": region, - "location": region, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://{{region}}-aiplatform.googleapis.com/v1/projects/{{project}}/locations/{{region}}/deploymentResourcePools", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil - } - - resourceList, ok := res["deploymentResourcePools"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - return nil - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://{{region}}-aiplatform.googleapis.com/v1/projects/{{project}}/locations/{{region}}/deploymentResourcePools/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - return nil - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_endpoint.go index 9fc841080d4..7ac12f8e722 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_endpoint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_endpoint.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -381,7 +380,6 @@ func resourceVertexAIEndpointCreate(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -390,7 +388,6 @@ func resourceVertexAIEndpointCreate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Endpoint: %s", err) @@ -453,14 +450,12 @@ func resourceVertexAIEndpointRead(d *schema.ResourceData, meta interface{}) erro billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIEndpoint %q", d.Id())) @@ -548,7 +543,6 @@ func resourceVertexAIEndpointUpdate(d *schema.ResourceData, meta interface{}) er } log.Printf("[DEBUG] Updating Endpoint %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -584,7 +578,6 @@ func resourceVertexAIEndpointUpdate(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -625,8 +618,6 @@ func resourceVertexAIEndpointDelete(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Endpoint %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -636,7 +627,6 @@ func resourceVertexAIEndpointDelete(d *schema.ResourceData, meta interface{}) er UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Endpoint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group.go index 75303e2abb4..6ade3f89c30 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -81,7 +80,7 @@ func ResourceVertexAIFeatureGroup() *schema.Resource { "entity_id_columns": { Type: schema.TypeList, Optional: true, - Description: `Columns to construct entityId / row keys. If not provided defaults to entityId.`, + Description: `Columns to construct entityId / row keys. Currently only supports 1 entity_id_column. If not provided defaults to entityId.`, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -205,7 +204,6 @@ func resourceVertexAIFeatureGroupCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -214,7 +212,6 @@ func resourceVertexAIFeatureGroupCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FeatureGroup: %s", err) @@ -281,14 +278,12 @@ func resourceVertexAIFeatureGroupRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeatureGroup %q", d.Id())) @@ -373,7 +368,6 @@ func resourceVertexAIFeatureGroupUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating FeatureGroup %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("name") { @@ -385,7 +379,7 @@ func resourceVertexAIFeatureGroupUpdate(d *schema.ResourceData, meta interface{} } if d.HasChange("big_query") { - updateMask = append(updateMask, "bigQuery.entityIdColumns") + updateMask = append(updateMask, "bigQuery") } if d.HasChange("effective_labels") { @@ -413,7 +407,6 @@ func resourceVertexAIFeatureGroupUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -461,8 +454,6 @@ func resourceVertexAIFeatureGroupDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FeatureGroup %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -472,7 +463,6 @@ func resourceVertexAIFeatureGroupDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FeatureGroup") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group_feature.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group_feature.go index 952e9fdb03c..0a7948ef680 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group_feature.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_group_feature.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -173,7 +172,6 @@ func resourceVertexAIFeatureGroupFeatureCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -182,7 +180,6 @@ func resourceVertexAIFeatureGroupFeatureCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FeatureGroupFeature: %s", err) @@ -245,14 +242,12 @@ func resourceVertexAIFeatureGroupFeatureRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeatureGroupFeature %q", d.Id())) @@ -328,7 +323,6 @@ func resourceVertexAIFeatureGroupFeatureUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating FeatureGroupFeature %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -364,7 +358,6 @@ func resourceVertexAIFeatureGroupFeatureUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -412,8 +405,6 @@ func resourceVertexAIFeatureGroupFeatureDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FeatureGroupFeature %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -423,7 +414,6 @@ func resourceVertexAIFeatureGroupFeatureDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FeatureGroupFeature") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store.go index 45700a0a098..0bb2362744f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -96,51 +95,7 @@ func ResourceVertexAIFeatureOnlineStore() *schema.Resource { }, }, }, - ExactlyOneOf: []string{"bigtable", "optimized"}, - }, - "dedicated_serving_endpoint": { - Type: schema.TypeList, - Computed: true, - Optional: true, - Description: `The dedicated serving endpoint for this FeatureOnlineStore, which is different from common vertex service endpoint. Only need to be set when you choose Optimized storage type or enable EmbeddingManagement. Will use public endpoint by default.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "private_service_connect_config": { - Type: schema.TypeList, - Optional: true, - Description: `Private service connect config.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enable_private_service_connect": { - Type: schema.TypeBool, - Required: true, - Description: `If set to true, customers will use private service connection to send request. Otherwise, the connection will set to public endpoint.`, - }, - "project_allowlist": { - Type: schema.TypeList, - Optional: true, - Description: `A list of Projects from which the forwarding rule will target the service attachment.`, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - }, - }, - }, - "public_endpoint_domain_name": { - Type: schema.TypeString, - Computed: true, - Description: `Domain name to use for this FeatureOnlineStore`, - }, - "service_attachment": { - Type: schema.TypeString, - Computed: true, - Description: `Name of the service attachment resource. Applicable only if private service connect is enabled and after FeatureViewSync is created.`, - }, - }, - }, + ExactlyOneOf: []string{"bigtable"}, }, "labels": { Type: schema.TypeMap, @@ -151,17 +106,6 @@ func ResourceVertexAIFeatureOnlineStore() *schema.Resource { Please refer to the field 'effective_labels' for all of the labels present on the resource.`, Elem: &schema.Schema{Type: schema.TypeString}, }, - "optimized": { - Type: schema.TypeList, - Optional: true, - Description: `Settings for the Optimized store that will be created to serve featureValues for all FeatureViews under this FeatureOnlineStore`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{}, - }, - ConflictsWith: []string{}, - ExactlyOneOf: []string{"bigtable", "optimized"}, - }, "region": { Type: schema.TypeString, Computed: true, @@ -233,18 +177,6 @@ func resourceVertexAIFeatureOnlineStoreCreate(d *schema.ResourceData, meta inter } else if v, ok := d.GetOkExists("bigtable"); !tpgresource.IsEmptyValue(reflect.ValueOf(bigtableProp)) && (ok || !reflect.DeepEqual(v, bigtableProp)) { obj["bigtable"] = bigtableProp } - optimizedProp, err := expandVertexAIFeatureOnlineStoreOptimized(d.Get("optimized"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("optimized"); ok || !reflect.DeepEqual(v, optimizedProp) { - obj["optimized"] = optimizedProp - } - dedicatedServingEndpointProp, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpoint(d.Get("dedicated_serving_endpoint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dedicated_serving_endpoint"); !tpgresource.IsEmptyValue(reflect.ValueOf(dedicatedServingEndpointProp)) && (ok || !reflect.DeepEqual(v, dedicatedServingEndpointProp)) { - obj["dedicatedServingEndpoint"] = dedicatedServingEndpointProp - } labelsProp, err := expandVertexAIFeatureOnlineStoreEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -271,7 +203,6 @@ func resourceVertexAIFeatureOnlineStoreCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -280,7 +211,6 @@ func resourceVertexAIFeatureOnlineStoreCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FeatureOnlineStore: %s", err) @@ -343,14 +273,12 @@ func resourceVertexAIFeatureOnlineStoreRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeatureOnlineStore %q", d.Id())) @@ -381,12 +309,6 @@ func resourceVertexAIFeatureOnlineStoreRead(d *schema.ResourceData, meta interfa if err := d.Set("bigtable", flattenVertexAIFeatureOnlineStoreBigtable(res["bigtable"], d, config)); err != nil { return fmt.Errorf("Error reading FeatureOnlineStore: %s", err) } - if err := d.Set("optimized", flattenVertexAIFeatureOnlineStoreOptimized(res["optimized"], d, config)); err != nil { - return fmt.Errorf("Error reading FeatureOnlineStore: %s", err) - } - if err := d.Set("dedicated_serving_endpoint", flattenVertexAIFeatureOnlineStoreDedicatedServingEndpoint(res["dedicatedServingEndpoint"], d, config)); err != nil { - return fmt.Errorf("Error reading FeatureOnlineStore: %s", err) - } if err := d.Set("terraform_labels", flattenVertexAIFeatureOnlineStoreTerraformLabels(res["labels"], d, config)); err != nil { return fmt.Errorf("Error reading FeatureOnlineStore: %s", err) } @@ -419,18 +341,6 @@ func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta inter } else if v, ok := d.GetOkExists("bigtable"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, bigtableProp)) { obj["bigtable"] = bigtableProp } - optimizedProp, err := expandVertexAIFeatureOnlineStoreOptimized(d.Get("optimized"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("optimized"); ok || !reflect.DeepEqual(v, optimizedProp) { - obj["optimized"] = optimizedProp - } - dedicatedServingEndpointProp, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpoint(d.Get("dedicated_serving_endpoint"), d, config) - if err != nil { - return err - } else if v, ok := d.GetOkExists("dedicated_serving_endpoint"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, dedicatedServingEndpointProp)) { - obj["dedicatedServingEndpoint"] = dedicatedServingEndpointProp - } labelsProp, err := expandVertexAIFeatureOnlineStoreEffectiveLabels(d.Get("effective_labels"), d, config) if err != nil { return err @@ -444,21 +354,12 @@ func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating FeatureOnlineStore %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("bigtable") { updateMask = append(updateMask, "bigtable") } - if d.HasChange("optimized") { - updateMask = append(updateMask, "optimized") - } - - if d.HasChange("dedicated_serving_endpoint") { - updateMask = append(updateMask, "dedicatedServingEndpoint") - } - if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } @@ -484,7 +385,6 @@ func resourceVertexAIFeatureOnlineStoreUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -532,8 +432,6 @@ func resourceVertexAIFeatureOnlineStoreDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - if v, ok := d.GetOk("force_destroy"); ok { url, err = transport_tpg.AddQueryParams(url, map[string]string{"force": fmt.Sprintf("%v", v)}) if err != nil { @@ -550,7 +448,6 @@ func resourceVertexAIFeatureOnlineStoreDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FeatureOnlineStore") @@ -702,62 +599,6 @@ func flattenVertexAIFeatureOnlineStoreBigtableAutoScalingCpuUtilizationTarget(v return v // let terraform core handle it otherwise } -func flattenVertexAIFeatureOnlineStoreOptimized(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - transformed := make(map[string]interface{}) - return []interface{}{transformed} -} - -func flattenVertexAIFeatureOnlineStoreDedicatedServingEndpoint(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["public_endpoint_domain_name"] = - flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPublicEndpointDomainName(original["publicEndpointDomainName"], d, config) - transformed["service_attachment"] = - flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointServiceAttachment(original["serviceAttachment"], d, config) - transformed["private_service_connect_config"] = - flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfig(original["privateServiceConnectConfig"], d, config) - return []interface{}{transformed} -} -func flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPublicEndpointDomainName(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointServiceAttachment(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["enable_private_service_connect"] = - flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(original["enablePrivateServiceConnect"], d, config) - transformed["project_allowlist"] = - flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigProjectAllowlist(original["projectAllowlist"], d, config) - return []interface{}{transformed} -} -func flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigProjectAllowlist(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenVertexAIFeatureOnlineStoreTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -841,96 +682,6 @@ func expandVertexAIFeatureOnlineStoreBigtableAutoScalingCpuUtilizationTarget(v i return v, nil } -func expandVertexAIFeatureOnlineStoreOptimized(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 { - return nil, nil - } - - if l[0] == nil { - transformed := make(map[string]interface{}) - return transformed, nil - } - transformed := make(map[string]interface{}) - - return transformed, nil -} - -func expandVertexAIFeatureOnlineStoreDedicatedServingEndpoint(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPublicEndpointDomainName, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPublicEndpointDomainName(original["public_endpoint_domain_name"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPublicEndpointDomainName); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["publicEndpointDomainName"] = transformedPublicEndpointDomainName - } - - transformedServiceAttachment, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointServiceAttachment(original["service_attachment"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedServiceAttachment); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["serviceAttachment"] = transformedServiceAttachment - } - - transformedPrivateServiceConnectConfig, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfig(original["private_service_connect_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPrivateServiceConnectConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["privateServiceConnectConfig"] = transformedPrivateServiceConnectConfig - } - - return transformed, nil -} - -func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPublicEndpointDomainName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointServiceAttachment(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedEnablePrivateServiceConnect, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(original["enable_private_service_connect"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedEnablePrivateServiceConnect); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["enablePrivateServiceConnect"] = transformedEnablePrivateServiceConnect - } - - transformedProjectAllowlist, err := expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigProjectAllowlist(original["project_allowlist"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectAllowlist); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectAllowlist"] = transformedProjectAllowlist - } - - return transformed, nil -} - -func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigEnablePrivateServiceConnect(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVertexAIFeatureOnlineStoreDedicatedServingEndpointPrivateServiceConnectConfigProjectAllowlist(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandVertexAIFeatureOnlineStoreEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go index 7a6cd053689..8b0057c7224 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_feature_online_store_featureview.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -120,11 +119,6 @@ func ResourceVertexAIFeatureOnlineStoreFeatureview() *schema.Resource { }, }, }, - "project_number": { - Type: schema.TypeString, - Optional: true, - Description: `The project number of the parent project of the feature Groups.`, - }, }, }, ConflictsWith: []string{}, @@ -249,7 +243,6 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -258,7 +251,6 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FeatureOnlineStoreFeatureview: %s", err) @@ -321,14 +313,12 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewRead(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeatureOnlineStoreFeatureview %q", d.Id())) @@ -413,7 +403,6 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating FeatureOnlineStoreFeatureview %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("sync_config") { @@ -453,7 +442,6 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -494,8 +482,6 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting FeatureOnlineStoreFeatureview %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -505,7 +491,6 @@ func resourceVertexAIFeatureOnlineStoreFeatureviewDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FeatureOnlineStoreFeatureview") @@ -618,8 +603,6 @@ func flattenVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySource(v interfa transformed := make(map[string]interface{}) transformed["feature_groups"] = flattenVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceFeatureGroups(original["featureGroups"], d, config) - transformed["project_number"] = - flattenVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceProjectNumber(original["projectNumber"], d, config) return []interface{}{transformed} } func flattenVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceFeatureGroups(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -649,10 +632,6 @@ func flattenVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceFeatureGro return v } -func flattenVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceProjectNumber(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return d.Get("feature_registry_source.0.project_number") -} - func flattenVertexAIFeatureOnlineStoreFeatureviewTerraformLabels(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return v @@ -745,13 +724,6 @@ func expandVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySource(v interfac transformed["featureGroups"] = transformedFeatureGroups } - transformedProjectNumber, err := expandVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceProjectNumber(original["project_number"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedProjectNumber); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["projectNumber"] = transformedProjectNumber - } - return transformed, nil } @@ -792,10 +764,6 @@ func expandVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceFeatureGrou return v, nil } -func expandVertexAIFeatureOnlineStoreFeatureviewFeatureRegistrySourceProjectNumber(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandVertexAIFeatureOnlineStoreFeatureviewEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) { if v == nil { return map[string]string{}, nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore.go index cb0209697f3..4bf3f2e4461 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -221,7 +220,6 @@ func resourceVertexAIFeaturestoreCreate(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -230,7 +228,6 @@ func resourceVertexAIFeaturestoreCreate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Featurestore: %s", err) @@ -293,14 +290,12 @@ func resourceVertexAIFeaturestoreRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeaturestore %q", d.Id())) @@ -382,7 +377,6 @@ func resourceVertexAIFeaturestoreUpdate(d *schema.ResourceData, meta interface{} } log.Printf("[DEBUG] Updating Featurestore %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("online_serving_config") { @@ -418,7 +412,6 @@ func resourceVertexAIFeaturestoreUpdate(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -466,8 +459,6 @@ func resourceVertexAIFeaturestoreDelete(d *schema.ResourceData, meta interface{} billingProject = bp } - headers := make(http.Header) - if v, ok := d.GetOk("force_destroy"); ok { url, err = transport_tpg.AddQueryParams(url, map[string]string{"force": fmt.Sprintf("%v", v)}) if err != nil { @@ -484,7 +475,6 @@ func resourceVertexAIFeaturestoreDelete(d *schema.ResourceData, meta interface{} UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Featurestore") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go index 10ed234aedf..bf9e4c5c52d 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -263,7 +262,6 @@ func resourceVertexAIFeaturestoreEntitytypeCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) if v, ok := d.GetOk("featurestore"); ok { re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/([a-zA-Z0-9-]*)") switch { @@ -281,7 +279,6 @@ func resourceVertexAIFeaturestoreEntitytypeCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FeaturestoreEntitytype: %s", err) @@ -338,14 +335,12 @@ func resourceVertexAIFeaturestoreEntitytypeRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeaturestoreEntitytype %q", d.Id())) @@ -416,7 +411,6 @@ func resourceVertexAIFeaturestoreEntitytypeUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating FeaturestoreEntitytype %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -452,7 +446,6 @@ func resourceVertexAIFeaturestoreEntitytypeUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -488,7 +481,6 @@ func resourceVertexAIFeaturestoreEntitytypeDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) if v, ok := d.GetOk("featurestore"); ok { re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/([a-zA-Z0-9-]*)") switch { @@ -508,7 +500,6 @@ func resourceVertexAIFeaturestoreEntitytypeDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FeaturestoreEntitytype") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go index 91c95ceab2f..33e4978b47c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_featurestore_entitytype_feature.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "regexp" "strings" @@ -172,7 +171,6 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureCreate(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) if v, ok := d.GetOk("entitytype"); ok { re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/([a-zA-Z0-9-]*)") switch { @@ -190,7 +188,6 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureCreate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating FeaturestoreEntitytypeFeature: %s", err) @@ -247,14 +244,12 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureRead(d *schema.ResourceData, m billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIFeaturestoreEntitytypeFeature %q", d.Id())) @@ -319,7 +314,6 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureUpdate(d *schema.ResourceData, } log.Printf("[DEBUG] Updating FeaturestoreEntitytypeFeature %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -351,7 +345,6 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureUpdate(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -387,7 +380,6 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureDelete(d *schema.ResourceData, billingProject = bp } - headers := make(http.Header) if v, ok := d.GetOk("entitytype"); ok { re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/([a-zA-Z0-9-]*)") switch { @@ -407,7 +399,6 @@ func resourceVertexAIFeaturestoreEntitytypeFeatureDelete(d *schema.ResourceData, UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "FeaturestoreEntitytypeFeature") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index.go index 674a1587ba3..a02eef56fbf 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -360,7 +359,6 @@ func resourceVertexAIIndexCreate(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -369,7 +367,6 @@ func resourceVertexAIIndexCreate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Index: %s", err) @@ -436,14 +433,12 @@ func resourceVertexAIIndexRead(d *schema.ResourceData, meta interface{}) error { billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIIndex %q", d.Id())) @@ -543,7 +538,6 @@ func resourceVertexAIIndexUpdate(d *schema.ResourceData, meta interface{}) error } log.Printf("[DEBUG] Updating Index %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -554,66 +548,49 @@ func resourceVertexAIIndexUpdate(d *schema.ResourceData, meta interface{}) error updateMask = append(updateMask, "description") } + if d.HasChange("metadata") { + updateMask = append(updateMask, "metadata") + } + if d.HasChange("effective_labels") { updateMask = append(updateMask, "labels") } - - // err == nil indicates that the billing_project value was found - if bp, err := tpgresource.GetBillingProject(d, config); err == nil { - billingProject = bp + // updateMask is a URL parameter but not present in the schema, so ReplaceVars + // won't set it + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) + if err != nil { + return err } + newUpdateMask := []string{} - // if updateMask is empty we are not updating anything so skip the post - if len(updateMask) > 0 { - log.Printf("[DEBUG] Updating first Index with updateMask: %#v", updateMask) - // updateMask is a URL parameter but not present in the schema, so ReplaceVars - // won't set it - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(updateMask, ",")}) - if err != nil { - return err - } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "PATCH", - Project: billingProject, - RawURL: url, - UserAgent: userAgent, - Body: obj, - Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, - }) + if d.HasChange("metadata.0.contents_delta_uri") { + // Use the current value of isCompleteOverwrite when updating contentsDeltaUri + newUpdateMask = append(newUpdateMask, "metadata.contentsDeltaUri") + newUpdateMask = append(newUpdateMask, "metadata.isCompleteOverwrite") + } - if err != nil { - return fmt.Errorf("Error updating first Index %q: %s", d.Id(), err) - } else { - log.Printf("[DEBUG] Finished updating first Index %q: %#v", d.Id(), res) + for _, mask := range updateMask { + // Use granular update masks instead of 'metadata' to avoid the following error: + // 'If `contents_delta_gcs_uri` is set as part of `index.metadata`, then no other Index fields can be also updated as part of the same update call.' + if mask == "metadata" { + continue } + newUpdateMask = append(newUpdateMask, mask) + } - err = VertexAIOperationWaitTime( - config, res, project, "Updating Index", userAgent, - d.Timeout(schema.TimeoutUpdate)) - - if err != nil { - return err - } + // Refreshing updateMask after adding extra schema entries + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")}) + if err != nil { + return err } - secondUpdateMask := []string{} - // 'If `contents_delta_gcs_uri` is set as part of `index.metadata`, - // then no other Index fields can be also updated as part of the same update call.' - // Metadata update need to be done in a separate update call. - if d.HasChange("metadata") { - secondUpdateMask = append(secondUpdateMask, "metadata") + // err == nil indicates that the billing_project value was found + if bp, err := tpgresource.GetBillingProject(d, config); err == nil { + billingProject = bp } - // if secondUpdateMask is empty we are not updating anything so skip the post - if len(secondUpdateMask) > 0 { - log.Printf("[DEBUG] Updating second Index with updateMask: %#v", secondUpdateMask) - // Override updateMask with secondUpdateMask - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(secondUpdateMask, ",")}) - if err != nil { - return err - } + // if updateMask is empty we are not updating anything so skip the post + if len(updateMask) > 0 { res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -622,13 +599,12 @@ func resourceVertexAIIndexUpdate(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { - return fmt.Errorf("Error Updating second Index %q: %s", d.Id(), err) + return fmt.Errorf("Error updating Index %q: %s", d.Id(), err) } else { - log.Printf("[DEBUG] Finished Updating second Index %q: %#v", d.Id(), res) + log.Printf("[DEBUG] Finished updating Index %q: %#v", d.Id(), res) } err = VertexAIOperationWaitTime( @@ -670,8 +646,6 @@ func resourceVertexAIIndexDelete(d *schema.ResourceData, meta interface{}) error billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Index %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -681,7 +655,6 @@ func resourceVertexAIIndexDelete(d *schema.ResourceData, meta interface{}) error UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Index") @@ -828,7 +801,7 @@ func flattenVertexAIIndexMetadataConfigDistanceMeasureType(v interface{}, d *sch } func flattenVertexAIIndexMetadataConfigFeatureNormType(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return d.Get("metadata.0.config.0.feature_norm_type") + return v } func flattenVertexAIIndexMetadataConfigAlgorithmConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index_endpoint.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index_endpoint.go index e7e58d5848f..a83792ddf31 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index_endpoint.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_index_endpoint.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -237,7 +236,6 @@ func resourceVertexAIIndexEndpointCreate(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -246,7 +244,6 @@ func resourceVertexAIIndexEndpointCreate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating IndexEndpoint: %s", err) @@ -313,14 +310,12 @@ func resourceVertexAIIndexEndpointRead(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAIIndexEndpoint %q", d.Id())) @@ -408,7 +403,6 @@ func resourceVertexAIIndexEndpointUpdate(d *schema.ResourceData, meta interface{ } log.Printf("[DEBUG] Updating IndexEndpoint %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -444,7 +438,6 @@ func resourceVertexAIIndexEndpointUpdate(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -485,8 +478,6 @@ func resourceVertexAIIndexEndpointDelete(d *schema.ResourceData, meta interface{ billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting IndexEndpoint %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -496,7 +487,6 @@ func resourceVertexAIIndexEndpointDelete(d *schema.ResourceData, meta interface{ UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "IndexEndpoint") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_tensorboard.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_tensorboard.go index bf8fa57ba54..5192ba2f81f 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_tensorboard.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vertexai/resource_vertex_ai_tensorboard.go @@ -20,7 +20,6 @@ package vertexai import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -201,7 +200,6 @@ func resourceVertexAITensorboardCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -210,7 +208,6 @@ func resourceVertexAITensorboardCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Tensorboard: %s", err) @@ -277,14 +274,12 @@ func resourceVertexAITensorboardRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VertexAITensorboard %q", d.Id())) @@ -372,7 +367,6 @@ func resourceVertexAITensorboardUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Tensorboard %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("display_name") { @@ -408,7 +402,6 @@ func resourceVertexAITensorboardUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -456,8 +449,6 @@ func resourceVertexAITensorboardDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Tensorboard %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -467,7 +458,6 @@ func resourceVertexAITensorboardDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Tensorboard") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster.go index 5f0b81de8c2..608ef03cf67 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -141,7 +140,6 @@ func resourceVmwareengineClusterCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -150,7 +148,6 @@ func resourceVmwareengineClusterCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -198,14 +195,12 @@ func resourceVmwareengineClusterRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -252,7 +247,6 @@ func resourceVmwareengineClusterUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Cluster %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("node_type_configs") { @@ -280,7 +274,6 @@ func resourceVmwareengineClusterUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -324,8 +317,6 @@ func resourceVmwareengineClusterDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Cluster %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -335,7 +326,6 @@ func resourceVmwareengineClusterDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster_sweeper.go index 85d223f3457..264f9ba58c3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_cluster_sweeper.go @@ -1,10 +1,24 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + package vmwareengine import ( "context" - "fmt" "log" "strings" "testing" @@ -39,110 +53,22 @@ func testSweepVmwareengineCluster(region string) error { t := &testing.T{} billingId := envvar.GetTestBillingAccountFromEnv(t) - // List of location values includes: - // * zones used for this resource type's acc tests in the past - // * the 'region' passed to the sweeper - locations := []string{region, "us-central1-a", "us-central1-b", "southamerica-west1-a", "southamerica-west1-b", "me-west1-a", "me-west1-b"} - log.Printf("[INFO][SWEEPER_LOG] Sweeping will include these locations: %v.", locations) - for _, location := range locations { - log.Printf("[INFO][SWEEPER_LOG] Beginning the process of sweeping location '%s'.", location) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": location, - "location": location, - "zone": location, - "billing_account": billingId, - }, - } - - log.Printf("[INFO][SWEEPER_LOG] looking for parent resources in location '%s'.", location) - privateCloudNames, err := listPrivateCloudsInLocation(d, config) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error finding parental resources in location %s: %s", location, err) - continue - } - for _, parent := range privateCloudNames { - - // `parent` will be string of form projects/my-project/locations/us-central1-a/privateClouds/my-cloud - listUrl := fmt.Sprintf("https://vmwareengine.googleapis.com/v1/projects/%s/clusters", parent) - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - continue - } - - resourceList, ok := res["clusters"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - continue - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - continue - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://vmwareengine.googleapis.com/v1/{{parent}}/clusters/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - continue - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - } + // Setup variables to replace in list template + d := &tpgresource.ResourceDataMock{ + FieldsInSchema: map[string]interface{}{ + "project": config.Project, + "region": region, + "location": region, + "zone": "-", + "billing_account": billingId, + }, } - return nil -} -func listPrivateCloudsInLocation(d *tpgresource.ResourceDataMock, config *transport_tpg.Config) ([]string, error) { - listTemplate := strings.Split("https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/privateClouds", "?")[0] + listTemplate := strings.Split("https://vmwareengine.googleapis.com/v1/{{parent}}/clusters", "?")[0] listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - return nil, err + return nil } res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ @@ -154,23 +80,60 @@ func listPrivateCloudsInLocation(d *tpgresource.ResourceDataMock, config *transp }) if err != nil { log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - return nil, err + return nil } - resourceList, ok := res["privateClouds"] + resourceList, ok := res["clusters"] if !ok { log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - return nil, fmt.Errorf("nothing found in response") + return nil } rl := resourceList.([]interface{}) - privateCloudNames := []string{} - for _, r := range rl { - resource := r.(map[string]interface{}) - if name, ok := resource["name"]; ok { - privateCloudNames = append(privateCloudNames, name.(string)) + + log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) + // Keep count of items that aren't sweepable for logging. + nonPrefixCount := 0 + for _, ri := range rl { + obj := ri.(map[string]interface{}) + if obj["name"] == nil { + log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) + return nil } + name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) + // Skip resources that shouldn't be sweeped + if !sweeper.IsSweepableTestResource(name) { + nonPrefixCount++ + continue + } + + deleteTemplate := "https://vmwareengine.googleapis.com/v1/{{parent}}/clusters/{{name}}" + deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) + return nil + } + deleteUrl = deleteUrl + name + + // Don't wait on operations as we may have a lot to delete + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "DELETE", + Project: config.Project, + RawURL: deleteUrl, + UserAgent: config.UserAgent, + }) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) + } else { + log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) + } + } + + if nonPrefixCount > 0 { + log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) } - return privateCloudNames, nil + + return nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go index a78dcb0c9b4..6b4462d1050 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_access_rule.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -241,7 +240,6 @@ func resourceVmwareengineExternalAccessRuleCreate(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -250,7 +248,6 @@ func resourceVmwareengineExternalAccessRuleCreate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating ExternalAccessRule: %s", err) @@ -297,14 +294,12 @@ func resourceVmwareengineExternalAccessRuleRead(d *schema.ResourceData, meta int billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VmwareengineExternalAccessRule %q", d.Id())) @@ -416,7 +411,6 @@ func resourceVmwareengineExternalAccessRuleUpdate(d *schema.ResourceData, meta i } log.Printf("[DEBUG] Updating ExternalAccessRule %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -472,7 +466,6 @@ func resourceVmwareengineExternalAccessRuleUpdate(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -515,8 +508,6 @@ func resourceVmwareengineExternalAccessRuleDelete(d *schema.ResourceData, meta i billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ExternalAccessRule %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -526,7 +517,6 @@ func resourceVmwareengineExternalAccessRuleDelete(d *schema.ResourceData, meta i UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "ExternalAccessRule") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_address.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_address.go index 44135ef9257..7b3b6fa5211 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_address.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_external_address.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -142,7 +141,6 @@ func resourceVmwareengineExternalAddressCreate(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -151,7 +149,6 @@ func resourceVmwareengineExternalAddressCreate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.ExternalIpServiceNotActive}, }) if err != nil { @@ -199,14 +196,12 @@ func resourceVmwareengineExternalAddressRead(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.ExternalIpServiceNotActive}, }) if err != nil { @@ -268,7 +263,6 @@ func resourceVmwareengineExternalAddressUpdate(d *schema.ResourceData, meta inte } log.Printf("[DEBUG] Updating ExternalAddress %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("internal_ip") { @@ -300,7 +294,6 @@ func resourceVmwareengineExternalAddressUpdate(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.ExternalIpServiceNotActive}, }) @@ -344,8 +337,6 @@ func resourceVmwareengineExternalAddressDelete(d *schema.ResourceData, meta inte billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting ExternalAddress %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -355,7 +346,6 @@ func resourceVmwareengineExternalAddressDelete(d *schema.ResourceData, meta inte UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorRetryPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.ExternalIpServiceNotActive}, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network.go index 64a7470b284..ed5b6183dd9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -161,7 +160,6 @@ func resourceVmwareengineNetworkCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -170,7 +168,6 @@ func resourceVmwareengineNetworkCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Network: %s", err) @@ -223,14 +220,12 @@ func resourceVmwareengineNetworkRead(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VmwareengineNetwork %q", d.Id())) @@ -288,7 +283,6 @@ func resourceVmwareengineNetworkUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Network %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -316,7 +310,6 @@ func resourceVmwareengineNetworkUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -364,8 +357,6 @@ func resourceVmwareengineNetworkDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Network %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -375,7 +366,6 @@ func resourceVmwareengineNetworkDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Network") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_peering.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_peering.go index ba3d5582d8d..0b495ddc1b9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_peering.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_peering.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "time" @@ -232,7 +231,6 @@ func resourceVmwareengineNetworkPeeringCreate(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -241,7 +239,6 @@ func resourceVmwareengineNetworkPeeringCreate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkPeering: %s", err) @@ -294,14 +291,12 @@ func resourceVmwareengineNetworkPeeringRead(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VmwareengineNetworkPeering %q", d.Id())) @@ -428,7 +423,6 @@ func resourceVmwareengineNetworkPeeringUpdate(d *schema.ResourceData, meta inter } log.Printf("[DEBUG] Updating NetworkPeering %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -443,7 +437,6 @@ func resourceVmwareengineNetworkPeeringUpdate(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -490,8 +483,6 @@ func resourceVmwareengineNetworkPeeringDelete(d *schema.ResourceData, meta inter billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NetworkPeering %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -501,7 +492,6 @@ func resourceVmwareengineNetworkPeeringDelete(d *schema.ResourceData, meta inter UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NetworkPeering") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_policy.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_policy.go index 6f451328fff..3e0a1fda1f8 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_policy.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_policy.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "time" @@ -224,7 +223,6 @@ func resourceVmwareengineNetworkPolicyCreate(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -233,7 +231,6 @@ func resourceVmwareengineNetworkPolicyCreate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating NetworkPolicy: %s", err) @@ -286,14 +283,12 @@ func resourceVmwareengineNetworkPolicyRead(d *schema.ResourceData, meta interfac billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VmwareengineNetworkPolicy %q", d.Id())) @@ -381,7 +376,6 @@ func resourceVmwareengineNetworkPolicyUpdate(d *schema.ResourceData, meta interf } log.Printf("[DEBUG] Updating NetworkPolicy %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -396,7 +390,6 @@ func resourceVmwareengineNetworkPolicyUpdate(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -443,8 +436,6 @@ func resourceVmwareengineNetworkPolicyDelete(d *schema.ResourceData, meta interf billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting NetworkPolicy %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -454,7 +445,6 @@ func resourceVmwareengineNetworkPolicyDelete(d *schema.ResourceData, meta interf UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "NetworkPolicy") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_sweeper.go index 0b01be30034..2fdd029a475 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_sweeper.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_network_sweeper.go @@ -1,5 +1,20 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 + +// ---------------------------------------------------------------------------- +// +// *** AUTO GENERATED CODE *** Type: MMv1 *** +// +// ---------------------------------------------------------------------------- +// +// This file is automatically generated by Magic Modules and manual +// changes will be clobbered when the file is regenerated. +// +// Please read more about how to change this file in +// .github/CONTRIBUTING.md. +// +// ---------------------------------------------------------------------------- + package vmwareengine import ( @@ -38,96 +53,86 @@ func testSweepVmwareengineNetwork(region string) error { t := &testing.T{} billingId := envvar.GetTestBillingAccountFromEnv(t) - // List of location values includes: - // * global location - // * regions used for this resource type's acc tests in the past - // * the 'region' passed to the sweeper - locations := []string{region, "global", "southamerica-west1", "me-west1"} - log.Printf("[INFO][SWEEPER_LOG] Sweeping will include these locations: %v.", locations) - for _, location := range locations { - log.Printf("[INFO][SWEEPER_LOG] Beginning the process of sweeping location '%s'.", location) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": location, - "location": location, - "zone": "-", - "billing_account": billingId, - }, + // Setup variables to replace in list template + d := &tpgresource.ResourceDataMock{ + FieldsInSchema: map[string]interface{}{ + "project": config.Project, + "region": region, + "location": region, + "zone": "-", + "billing_account": billingId, + }, + } + + listTemplate := strings.Split("https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/vmwareEngineNetworks", "?")[0] + listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) + return nil + } + + res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + Config: config, + Method: "GET", + Project: config.Project, + RawURL: listUrl, + UserAgent: config.UserAgent, + }) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) + return nil + } + + resourceList, ok := res["networks"] + if !ok { + log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") + return nil + } + + rl := resourceList.([]interface{}) + + log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) + // Keep count of items that aren't sweepable for logging. + nonPrefixCount := 0 + for _, ri := range rl { + obj := ri.(map[string]interface{}) + if obj["name"] == nil { + log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) + return nil } - listTemplate := strings.Split("https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/vmwareEngineNetworks", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) + name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) + // Skip resources that shouldn't be sweeped + if !sweeper.IsSweepableTestResource(name) { + nonPrefixCount++ continue } - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ + deleteTemplate := "https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/vmwareEngineNetworks/{{name}}" + deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) + if err != nil { + log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) + return nil + } + deleteUrl = deleteUrl + name + + // Don't wait on operations as we may have a lot to delete + _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, - Method: "GET", + Method: "DELETE", Project: config.Project, - RawURL: listUrl, + RawURL: deleteUrl, UserAgent: config.UserAgent, }) if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - continue - } - - resourceList, ok := res["vmwareEngineNetworks"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - continue - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - continue - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/vmwareEngineNetworks/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - continue - } - deleteUrl = deleteUrl + name - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } + log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) + } else { + log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) } + } - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } + if nonPrefixCount > 0 { + log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) } return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud.go index e64d0ebe1aa..afe01e88e71 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -113,26 +112,6 @@ This cannot be changed once the PrivateCloud is created.`, }, }, }, - "stretched_cluster_config": { - Type: schema.TypeList, - Optional: true, - Description: `The stretched cluster configuration for the private cloud.`, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "preferred_location": { - Type: schema.TypeString, - Optional: true, - Description: `Zone that will remain operational when connection between the two zones is lost.`, - }, - "secondary_location": { - Type: schema.TypeString, - Optional: true, - Description: `Additional zone for a higher level of availability and load balancing.`, - }, - }, - }, - }, }, }, }, @@ -195,9 +174,9 @@ the form: projects/{project_number}/locations/{location}/vmwareEngineNetworks/{v Type: schema.TypeString, Optional: true, ForceNew: true, - ValidateFunc: verify.ValidateEnum([]string{"STANDARD", "TIME_LIMITED", "STRETCHED", ""}), + ValidateFunc: verify.ValidateEnum([]string{"STANDARD", "TIME_LIMITED", ""}), DiffSuppressFunc: vmwareenginePrivateCloudStandardTypeDiffSuppressFunc, - Description: `Initial type of the private cloud. Possible values: ["STANDARD", "TIME_LIMITED", "STRETCHED"]`, + Description: `Initial type of the private cloud. Possible values: ["STANDARD", "TIME_LIMITED"]`, }, "hcx": { Type: schema.TypeList, @@ -362,7 +341,6 @@ func resourceVmwareenginePrivateCloudCreate(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -371,7 +349,6 @@ func resourceVmwareenginePrivateCloudCreate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -425,14 +402,12 @@ func resourceVmwareenginePrivateCloudRead(d *schema.ResourceData, meta interface billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -523,7 +498,6 @@ func resourceVmwareenginePrivateCloudUpdate(d *schema.ResourceData, meta interfa } log.Printf("[DEBUG] Updating PrivateCloud %q: %#v", d.Id(), obj) - headers := make(http.Header) // err == nil indicates that the billing_project value was found if bp, err := tpgresource.GetBillingProject(d, config); err == nil { @@ -538,7 +512,6 @@ func resourceVmwareenginePrivateCloudUpdate(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) @@ -640,8 +613,6 @@ func resourceVmwareenginePrivateCloudDelete(d *schema.ResourceData, meta interfa billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting PrivateCloud %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -651,7 +622,6 @@ func resourceVmwareenginePrivateCloudDelete(d *schema.ResourceData, meta interfa UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, ErrorAbortPredicates: []transport_tpg.RetryErrorPredicateFunc{transport_tpg.Is429QuotaError}, }) if err != nil { @@ -808,8 +778,6 @@ func flattenVmwareenginePrivateCloudManagementCluster(v interface{}, d *schema.R flattenVmwareenginePrivateCloudManagementClusterClusterId(original["clusterId"], d, config) transformed["node_type_configs"] = flattenVmwareenginePrivateCloudManagementClusterNodeTypeConfigs(original["nodeTypeConfigs"], d, config) - transformed["stretched_cluster_config"] = - flattenVmwareenginePrivateCloudManagementClusterStretchedClusterConfig(original["stretchedClusterConfig"], d, config) return []interface{}{transformed} } func flattenVmwareenginePrivateCloudManagementClusterClusterId(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -866,29 +834,6 @@ func flattenVmwareenginePrivateCloudManagementClusterNodeTypeConfigsCustomCoreCo return v // let terraform core handle it otherwise } -func flattenVmwareenginePrivateCloudManagementClusterStretchedClusterConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - if v == nil { - return nil - } - original := v.(map[string]interface{}) - if len(original) == 0 { - return nil - } - transformed := make(map[string]interface{}) - transformed["preferred_location"] = - flattenVmwareenginePrivateCloudManagementClusterStretchedClusterConfigPreferredLocation(original["preferredLocation"], d, config) - transformed["secondary_location"] = - flattenVmwareenginePrivateCloudManagementClusterStretchedClusterConfigSecondaryLocation(original["secondaryLocation"], d, config) - return []interface{}{transformed} -} -func flattenVmwareenginePrivateCloudManagementClusterStretchedClusterConfigPreferredLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - -func flattenVmwareenginePrivateCloudManagementClusterStretchedClusterConfigSecondaryLocation(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { - return v -} - func flattenVmwareenginePrivateCloudHcx(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { if v == nil { return nil @@ -1088,13 +1033,6 @@ func expandVmwareenginePrivateCloudManagementCluster(v interface{}, d tpgresourc transformed["nodeTypeConfigs"] = transformedNodeTypeConfigs } - transformedStretchedClusterConfig, err := expandVmwareenginePrivateCloudManagementClusterStretchedClusterConfig(original["stretched_cluster_config"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedStretchedClusterConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["stretchedClusterConfig"] = transformedStretchedClusterConfig - } - return transformed, nil } @@ -1142,40 +1080,6 @@ func expandVmwareenginePrivateCloudManagementClusterNodeTypeConfigsCustomCoreCou return v, nil } -func expandVmwareenginePrivateCloudManagementClusterStretchedClusterConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - l := v.([]interface{}) - if len(l) == 0 || l[0] == nil { - return nil, nil - } - raw := l[0] - original := raw.(map[string]interface{}) - transformed := make(map[string]interface{}) - - transformedPreferredLocation, err := expandVmwareenginePrivateCloudManagementClusterStretchedClusterConfigPreferredLocation(original["preferred_location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedPreferredLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["preferredLocation"] = transformedPreferredLocation - } - - transformedSecondaryLocation, err := expandVmwareenginePrivateCloudManagementClusterStretchedClusterConfigSecondaryLocation(original["secondary_location"], d, config) - if err != nil { - return nil, err - } else if val := reflect.ValueOf(transformedSecondaryLocation); val.IsValid() && !tpgresource.IsEmptyValue(val) { - transformed["secondaryLocation"] = transformedSecondaryLocation - } - - return transformed, nil -} - -func expandVmwareenginePrivateCloudManagementClusterStretchedClusterConfigPreferredLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - -func expandVmwareenginePrivateCloudManagementClusterStretchedClusterConfigSecondaryLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil -} - func expandVmwareenginePrivateCloudType(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud_sweeper.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud_sweeper.go deleted file mode 100644 index ee26c9ac01f..00000000000 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_private_cloud_sweeper.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 -package vmwareengine - -import ( - "context" - "fmt" - "log" - "strings" - "testing" - - "github.com/hashicorp/terraform-provider-google/google/envvar" - "github.com/hashicorp/terraform-provider-google/google/sweeper" - "github.com/hashicorp/terraform-provider-google/google/tpgresource" - transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" -) - -func init() { - sweeper.AddTestSweepers("VmwareenginePrivateCloud", testSweepVmwareenginePrivateCloud) -} - -// At the time of writing, the CI only passes us-central1 as the region -func testSweepVmwareenginePrivateCloud(region string) error { - resourceName := "VmwareenginePrivateCloud" - log.Printf("[INFO][SWEEPER_LOG] Starting sweeper for %s", resourceName) - - config, err := sweeper.SharedConfigForRegion(region) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error getting shared config for region: %s", err) - return err - } - - err = config.LoadAndValidate(context.Background()) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error loading: %s", err) - return err - } - - t := &testing.T{} - billingId := envvar.GetTestBillingAccountFromEnv(t) - - // List of location values includes: - // * zones used for this resource type's acc tests in the past - // * the 'region' passed to the sweeper - locations := []string{region, "southamerica-west1-a", "me-west1-a"} - log.Printf("[INFO][SWEEPER_LOG] Sweeping will include these locations: %v.", locations) - for _, location := range locations { - log.Printf("[INFO][SWEEPER_LOG] Beginning the process of sweeping location '%s'.", location) - - // Setup variables to replace in list template - d := &tpgresource.ResourceDataMock{ - FieldsInSchema: map[string]interface{}{ - "project": config.Project, - "region": location, - "location": location, - "zone": "-", - "billing_account": billingId, - }, - } - - listTemplate := strings.Split("https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/privateClouds", "?")[0] - listUrl, err := tpgresource.ReplaceVars(d, config, listTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) - continue - } - - res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "GET", - Project: config.Project, - RawURL: listUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error in response from request %s: %s", listUrl, err) - continue - } - - resourceList, ok := res["privateClouds"] - if !ok { - log.Printf("[INFO][SWEEPER_LOG] Nothing found in response.") - continue - } - - rl := resourceList.([]interface{}) - - log.Printf("[INFO][SWEEPER_LOG] Found %d items in %s list response.", len(rl), resourceName) - // Keep count of items that aren't sweepable for logging. - nonPrefixCount := 0 - for _, ri := range rl { - obj := ri.(map[string]interface{}) - if obj["name"] == nil { - log.Printf("[INFO][SWEEPER_LOG] %s resource name was nil", resourceName) - continue - } - - name := tpgresource.GetResourceNameFromSelfLink(obj["name"].(string)) - // Skip resources that shouldn't be sweeped - if !sweeper.IsSweepableTestResource(name) { - nonPrefixCount++ - continue - } - - deleteTemplate := "https://vmwareengine.googleapis.com/v1/projects/{{project}}/locations/{{location}}/privateClouds/{{name}}" - deleteUrl, err := tpgresource.ReplaceVars(d, config, deleteTemplate) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) - continue - } - deleteUrl = deleteUrl + name - - // We force delete the Private Cloud and ensure there's no delay in deletion - force := true - delayHours := 0 - deleteUrl = deleteUrl + fmt.Sprintf("?force=%t&delayHours=%d", force, delayHours) - - // Don't wait on operations as we may have a lot to delete - _, err = transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "DELETE", - Project: config.Project, - RawURL: deleteUrl, - UserAgent: config.UserAgent, - }) - if err != nil { - log.Printf("[INFO][SWEEPER_LOG] Error deleting for url %s : %s", deleteUrl, err) - } else { - log.Printf("[INFO][SWEEPER_LOG] Sent delete request for %s resource: %s", resourceName, name) - } - } - - if nonPrefixCount > 0 { - log.Printf("[INFO][SWEEPER_LOG] %d items were non-sweepable and skipped.", nonPrefixCount) - } - } - - return nil -} diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_subnet.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_subnet.go index 965c8696fc5..60426367c90 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_subnet.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vmwareengine/resource_vmwareengine_subnet.go @@ -20,7 +20,6 @@ package vmwareengine import ( "fmt" "log" - "net/http" "reflect" "strings" "time" @@ -172,7 +171,6 @@ func resourceVmwareengineSubnetCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "PATCH", @@ -181,7 +179,6 @@ func resourceVmwareengineSubnetCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Subnet: %s", err) @@ -228,14 +225,12 @@ func resourceVmwareengineSubnetRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VmwareengineSubnet %q", d.Id())) @@ -302,7 +297,6 @@ func resourceVmwareengineSubnetUpdate(d *schema.ResourceData, meta interface{}) } log.Printf("[DEBUG] Updating Subnet %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("ip_cidr_range") { @@ -330,7 +324,6 @@ func resourceVmwareengineSubnetUpdate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vpcaccess/resource_vpc_access_connector.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vpcaccess/resource_vpc_access_connector.go index 9d3879fb7b9..33b23a940d3 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vpcaccess/resource_vpc_access_connector.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/vpcaccess/resource_vpc_access_connector.go @@ -20,7 +20,6 @@ package vpcaccess import ( "fmt" "log" - "net/http" "reflect" "time" @@ -73,41 +72,34 @@ func ResourceVPCAccessConnector() *schema.Resource { Default: "e2-micro", }, "max_instances": { - Type: schema.TypeInt, - Computed: true, - Optional: true, - ForceNew: true, - Description: `Maximum value of instances in autoscaling group underlying the connector. Value must be between 3 and 10, inclusive. Must be -higher than the value specified by min_instances.`, + Type: schema.TypeInt, + Computed: true, + Optional: true, + ForceNew: true, + Description: `Maximum value of instances in autoscaling group underlying the connector.`, }, "max_throughput": { Type: schema.TypeInt, Optional: true, ForceNew: true, ValidateFunc: validation.IntBetween(200, 1000), - Description: `Maximum throughput of the connector in Mbps, must be greater than 'min_throughput'. Default is 300. Refers to the expected throughput -when using an e2-micro machine type. Value must be a multiple of 100 from 300 through 1000. Must be higher than the value specified by -min_throughput. If both max_throughput and max_instances are provided, max_instances takes precedence over max_throughput. The use of -max_throughput is discouraged in favor of max_instances.`, - Default: 300, + Description: `Maximum throughput of the connector in Mbps, must be greater than 'min_throughput'. Default is 300.`, + Default: 300, }, "min_instances": { - Type: schema.TypeInt, - Computed: true, - Optional: true, - ForceNew: true, - Description: `Minimum value of instances in autoscaling group underlying the connector. Value must be between 2 and 9, inclusive. Must be -lower than the value specified by max_instances.`, + Type: schema.TypeInt, + Computed: true, + Optional: true, + ForceNew: true, + Description: `Minimum value of instances in autoscaling group underlying the connector.`, }, "min_throughput": { Type: schema.TypeInt, Optional: true, ForceNew: true, ValidateFunc: validation.IntBetween(200, 1000), - Description: `Minimum throughput of the connector in Mbps. Default and min is 200. Refers to the expected throughput when using an e2-micro machine type. -Value must be a multiple of 100 from 200 through 900. Must be lower than the value specified by max_throughput. If both min_throughput and -min_instances are provided, min_instances takes precedence over min_throughput. The use of min_throughput is discouraged in favor of min_instances.`, - Default: 200, + Description: `Minimum throughput of the connector in Mbps. Default and min is 200.`, + Default: 200, }, "network": { Type: schema.TypeString, @@ -267,7 +259,6 @@ func resourceVPCAccessConnectorCreate(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -276,7 +267,6 @@ func resourceVPCAccessConnectorCreate(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Connector: %s", err) @@ -356,14 +346,12 @@ func resourceVPCAccessConnectorRead(d *schema.ResourceData, meta interface{}) er billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("VPCAccessConnector %q", d.Id())) @@ -449,8 +437,6 @@ func resourceVPCAccessConnectorDelete(d *schema.ResourceData, meta interface{}) billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Connector %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -460,7 +446,6 @@ func resourceVPCAccessConnectorDelete(d *schema.ResourceData, meta interface{}) UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Connector") diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workbench/resource_workbench_instance.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workbench/resource_workbench_instance.go index 67dd0156921..43ad60e8044 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workbench/resource_workbench_instance.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workbench/resource_workbench_instance.go @@ -20,14 +20,13 @@ package workbench import ( "fmt" "log" - "net/http" "reflect" "sort" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -60,11 +59,13 @@ func WorkbenchInstanceLabelsDiffSuppress(k, old, new string, d *schema.ResourceD } var WorkbenchInstanceProvidedMetadata = []string{ + "disable-swap-binaries", + "enable-guest-attributes", + "proxy-backend-id", + "proxy-registration-url", "agent-health-check-interval-seconds", "agent-health-check-path", "container", - "custom-container-image", - "custom-container-payload", "data-disk-uri", "dataproc-allow-custom-clusters", "dataproc-cluster-name", @@ -85,19 +86,16 @@ var WorkbenchInstanceProvidedMetadata = []string{ "install-monitoring-agent", "install-nvidia-driver", "installed-extensions", - "last_updated_diagnostics", "notebooks-api", "notebooks-api-version", "notebooks-examples-location", "notebooks-location", - "proxy-backend-id", - "proxy-byoid-url", + "nvidia-driver-gcs-path", "proxy-mode", "proxy-status", "proxy-url", "proxy-user-mail", "report-container-health", - "report-event-url", "report-notebook-metrics", "report-system-health", "report-system-status", @@ -106,13 +104,8 @@ var WorkbenchInstanceProvidedMetadata = []string{ "shutdown-script", "title", "use-collaborative", - "user-data", "version", - - "disable-swap-binaries", - "enable-guest-attributes", "enable-oslogin", - "proxy-registration-url", } func WorkbenchInstanceMetadataDiffSuppress(k, old, new string, d *schema.ResourceData) bool { @@ -161,21 +154,11 @@ func WorkbenchInstanceTagsDiffSuppress(_, _, _ string, d *schema.ResourceData) b return false } -func WorkbenchInstanceAcceleratorDiffSuppress(_, _, _ string, d *schema.ResourceData) bool { - old, new := d.GetChange("gce_setup.0.accelerator_configs") - oldInterface := old.([]interface{}) - newInterface := new.([]interface{}) - if len(oldInterface) == 0 && len(newInterface) == 1 && newInterface[0] == nil { - return true - } - return false -} - // waitForWorkbenchInstanceActive waits for an workbench instance to become "ACTIVE" func waitForWorkbenchInstanceActive(d *schema.ResourceData, config *transport_tpg.Config, timeout time.Duration) error { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { if err := resourceWorkbenchInstanceRead(d, config); err != nil { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } name := d.Get("name").(string) @@ -184,7 +167,7 @@ func waitForWorkbenchInstanceActive(d *schema.ResourceData, config *transport_tp log.Printf("[DEBUG] Workbench Instance %q has state %q.", name, state) return nil } else { - return retry.RetryableError(fmt.Errorf("Workbench Instance %q has state %q. Waiting for ACTIVE state", name, state)) + return resource.RetryableError(fmt.Errorf("Workbench Instance %q has state %q. Waiting for ACTIVE state", name, state)) } }) @@ -227,50 +210,6 @@ func waitForWorkbenchOperation(config *transport_tpg.Config, d *schema.ResourceD return nil } -func resizeWorkbenchInstanceDisk(config *transport_tpg.Config, d *schema.ResourceData, project string, userAgent string, isBoot bool) error { - diskObj := make(map[string]interface{}) - var sizeString string - var diskKey string - if isBoot { - sizeString = "gce_setup.0.boot_disk.0.disk_size_gb" - diskKey = "bootDisk" - } else { - sizeString = "gce_setup.0.data_disks.0.disk_size_gb" - diskKey = "dataDisk" - } - disk := make(map[string]interface{}) - disk["diskSizeGb"] = d.Get(sizeString) - diskObj[diskKey] = disk - - resizeUrl, err := tpgresource.ReplaceVars(d, config, "{{WorkbenchBasePath}}projects/{{project}}/locations/{{location}}/instances/{{name}}:resizeDisk") - if err != nil { - return err - } - - dRes, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ - Config: config, - Method: "POST", - RawURL: resizeUrl, - UserAgent: userAgent, - Body: diskObj, - Timeout: d.Timeout(schema.TimeoutUpdate), - }) - - if err != nil { - return fmt.Errorf("Error resizing disk: %s", err) - } - - var opRes map[string]interface{} - err = WorkbenchOperationWaitTimeWithResponse( - config, dRes, &opRes, project, "Resizing disk", userAgent, - d.Timeout(schema.TimeoutUpdate)) - if err != nil { - return fmt.Errorf("Error resizing disk: %s", err) - } - - return nil -} - func ResourceWorkbenchInstance() *schema.Resource { return &schema.Resource{ Create: resourceWorkbenchInstanceCreate, @@ -321,9 +260,8 @@ func ResourceWorkbenchInstance() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "accelerator_configs": { - Type: schema.TypeList, - Optional: true, - DiffSuppressFunc: WorkbenchInstanceAcceleratorDiffSuppress, + Type: schema.TypeList, + Optional: true, Description: `The hardware accelerators used on this instance. If you use accelerators, make sure that your configuration has [enough vCPUs and memory to support the 'machine_type' you have selected](https://cloud.google.com/compute/docs/gpus/#gpus-list). Currently supports only one accelerator configuration.`, @@ -347,6 +285,7 @@ Currently supports only one accelerator configuration.`, Type: schema.TypeList, Computed: true, Optional: true, + ForceNew: true, Description: `The definition of a boot disk.`, MaxItems: 1, Elem: &schema.Resource{ @@ -364,6 +303,7 @@ data disks, defaults to GMEK. Possible values: ["GMEK", "CMEK"]`, Type: schema.TypeString, Computed: true, Optional: true, + ForceNew: true, Description: `Optional. The size of the boot disk in GB attached to this instance, up to a maximum of 64000 GB (64 TB). If not specified, this defaults to the recommended value of 150GB.`, @@ -414,6 +354,7 @@ For example: gcr.io/{project_id}/{imageName}`, Type: schema.TypeList, Computed: true, Optional: true, + ForceNew: true, Description: `Data disks attached to the VM instance. Currently supports only one data disk.`, MaxItems: 1, Elem: &schema.Resource{ @@ -431,6 +372,7 @@ and data disks, defaults to GMEK. Possible values: ["GMEK", "CMEK"]`, Type: schema.TypeString, Computed: true, Optional: true, + ForceNew: true, Description: `Optional. The size of the disk in GB attached to this VM instance, up to a maximum of 64000 GB (64 TB). If not specified, this defaults to 100.`, @@ -840,7 +782,6 @@ func resourceWorkbenchInstanceCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -849,7 +790,6 @@ func resourceWorkbenchInstanceCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Instance: %s", err) @@ -926,14 +866,12 @@ func resourceWorkbenchInstanceRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("WorkbenchInstance %q", d.Id())) @@ -1027,7 +965,6 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Instance %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("gce_setup") { @@ -1043,44 +980,8 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e if err != nil { return err } - // Build custom mask since the notebooks API does not support gce_setup as a valid mask - stopInstance := false - newUpdateMask := []string{} - if d.HasChange("gce_setup.0.machine_type") { - newUpdateMask = append(newUpdateMask, "gce_setup.machine_type") - stopInstance = true - } - if d.HasChange("gce_setup.0.accelerator_configs") { - newUpdateMask = append(newUpdateMask, "gce_setup.accelerator_configs") - stopInstance = true - } - if d.HasChange("gce_setup.0.shielded_instance_config.0.enable_secure_boot") { - newUpdateMask = append(newUpdateMask, "gce_setup.shielded_instance_config.enable_secure_boot") - stopInstance = true - } - if d.HasChange("gce_setup.0.shielded_instance_config.0.enable_vtpm") { - newUpdateMask = append(newUpdateMask, "gce_setup.shielded_instance_config.enable_vtpm") - stopInstance = true - } - if d.HasChange("gce_setup.0.shielded_instance_config.0.enable_integrity_monitoring") { - newUpdateMask = append(newUpdateMask, "gce_setup.shielded_instance_config.enable_integrity_monitoring") - stopInstance = true - } - if d.HasChange("gce_setup.0.metadata") { - newUpdateMask = append(newUpdateMask, "gceSetup.metadata") - } - if d.HasChange("effective_labels") { - newUpdateMask = append(newUpdateMask, "labels") - } - updateMask = newUpdateMask - // Overwrite the previously set mask. - url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")}) - if err != nil { - return err - } - name := d.Get("name").(string) - if stopInstance { + if d.HasChange("gce_setup.0.machine_type") || d.HasChange("gce_setup.0.accelerator_configs") || d.HasChange("gce_setup.0.shielded_instance_config") { state := d.Get("state").(string) if state != "STOPPED" { @@ -1101,11 +1002,28 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e log.Printf("[DEBUG] Workbench Instance %q need not be stopped for the update.", name) } - if d.HasChange("gce_setup.0.boot_disk.0.disk_size_gb") { - resizeWorkbenchInstanceDisk(config, d, project, userAgent, true) + // Build custom mask since the notebooks API does not support gce_setup as a valid mask + newUpdateMask := []string{} + if d.HasChange("gce_setup.0.machine_type") { + newUpdateMask = append(newUpdateMask, "gce_setup.machine_type") } - if d.HasChange("gce_setup.0.data_disks.0.disk_size_gb") { - resizeWorkbenchInstanceDisk(config, d, project, userAgent, false) + if d.HasChange("gce_setup.0.accelerator_configs") { + newUpdateMask = append(newUpdateMask, "gce_setup.accelerator_configs") + } + if d.HasChange("gce_setup.0.shielded_instance_config") { + newUpdateMask = append(newUpdateMask, "gce_setup.shielded_instance_config") + } + if d.HasChange("gce_setup.0.metadata") { + newUpdateMask = append(newUpdateMask, "gceSetup.metadata") + } + if d.HasChange("effective_labels") { + newUpdateMask = append(newUpdateMask, "labels") + } + + // Overwrite the previously set mask. + url, err = transport_tpg.AddQueryParams(url, map[string]string{"updateMask": strings.Join(newUpdateMask, ",")}) + if err != nil { + return err } // err == nil indicates that the billing_project value was found @@ -1123,7 +1041,6 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -1144,7 +1061,7 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e state := d.Get("state").(string) desired_state := d.Get("desired_state").(string) - if state != desired_state || stopInstance { + if state != desired_state { verb := "start" if desired_state == "STOPPED" { verb = "stop" @@ -1158,13 +1075,6 @@ func resourceWorkbenchInstanceUpdate(d *schema.ResourceData, meta interface{}) e return fmt.Errorf("Error waiting to modify Workbench Instance state: %s", err) } - if verb == "start" { - if err := waitForWorkbenchInstanceActive(d, config, d.Timeout(schema.TimeoutUpdate)-time.Minute); err != nil { - return fmt.Errorf("Workbench instance %q did not reach ACTIVE state: %q", d.Get("name").(string), err) - } - - } - } else { log.Printf("[DEBUG] Workbench Instance %q has state %q.", name, state) } @@ -1198,8 +1108,6 @@ func resourceWorkbenchInstanceDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Instance %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -1209,7 +1117,6 @@ func resourceWorkbenchInstanceDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Instance") @@ -2121,7 +2028,16 @@ func expandWorkbenchInstanceGceSetupNetworkInterfaces(v interface{}, d tpgresour } func expandWorkbenchInstanceGceSetupNetworkInterfacesNetwork(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { - return v, nil + if v == nil || v.(string) == "" { + return "", nil + } else if strings.HasPrefix(v.(string), "https://") { + return v, nil + } + url, err := tpgresource.ReplaceVars(d, config, "{{ComputeBasePath}}"+v.(string)) + if err != nil { + return "", err + } + return tpgresource.ConvertSelfLinkToV1(url), nil } func expandWorkbenchInstanceGceSetupNetworkInterfacesSubnet(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workflows/resource_workflows_workflow.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workflows/resource_workflows_workflow.go index cb80bd1f16d..c88185860a4 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workflows/resource_workflows_workflow.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/services/workflows/resource_workflows_workflow.go @@ -21,13 +21,12 @@ import ( "context" "fmt" "log" - "net/http" "reflect" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-google/google/tpgresource" @@ -263,7 +262,6 @@ func resourceWorkflowsWorkflowCreate(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "POST", @@ -272,7 +270,6 @@ func resourceWorkflowsWorkflowCreate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutCreate), - Headers: headers, }) if err != nil { return fmt.Errorf("Error creating Workflow: %s", err) @@ -339,14 +336,12 @@ func resourceWorkflowsWorkflowRead(d *schema.ResourceData, meta interface{}) err billingProject = bp } - headers := make(http.Header) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, Method: "GET", Project: billingProject, RawURL: url, UserAgent: userAgent, - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, fmt.Sprintf("WorkflowsWorkflow %q", d.Id())) @@ -472,7 +467,6 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e } log.Printf("[DEBUG] Updating Workflow %q: %#v", d.Id(), obj) - headers := make(http.Header) updateMask := []string{} if d.HasChange("description") { @@ -524,7 +518,6 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutUpdate), - Headers: headers, }) if err != nil { @@ -572,8 +565,6 @@ func resourceWorkflowsWorkflowDelete(d *schema.ResourceData, meta interface{}) e billingProject = bp } - headers := make(http.Header) - log.Printf("[DEBUG] Deleting Workflow %q", d.Id()) res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{ Config: config, @@ -583,7 +574,6 @@ func resourceWorkflowsWorkflowDelete(d *schema.ResourceData, meta interface{}) e UserAgent: userAgent, Body: obj, Timeout: d.Timeout(schema.TimeoutDelete), - Headers: headers, }) if err != nil { return transport_tpg.HandleNotFoundError(err, d, "Workflow") @@ -733,9 +723,9 @@ func resourceWorkflowsWorkflowEncoder(d *schema.ResourceData, meta interface{}, if v, ok := d.GetOk("name"); ok { ResName = v.(string) } else if v, ok := d.GetOk("name_prefix"); ok { - ResName = id.PrefixedUniqueId(v.(string)) + ResName = resource.PrefixedUniqueId(v.(string)) } else { - ResName = id.UniqueId() + ResName = resource.UniqueId() } if err := d.Set("name", ResName); err != nil { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/annotations.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/annotations.go index fe1330f3b08..ec286a7470c 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/annotations.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/annotations.go @@ -19,15 +19,6 @@ func SetAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta interfac return fmt.Errorf("`effective_annotations` field is not present in the resource schema.") } - // If "annotations" field is computed, set "effective_annotations" to computed. - // https://github.com/hashicorp/terraform-provider-google/issues/16217 - if !d.GetRawPlan().GetAttr("annotations").IsWhollyKnown() { - if err := d.SetNewComputed("effective_annotations"); err != nil { - return fmt.Errorf("error setting effective_annotations to computed: %w", err) - } - return nil - } - o, n := d.GetChange("annotations") effectiveAnnotations := d.Get("effective_annotations").(map[string]interface{}) @@ -54,17 +45,6 @@ func SetMetadataAnnotationsDiff(_ context.Context, d *schema.ResourceDiff, meta return nil } - // Fix the bug that the computed and nested "annotations" field disappears from the terraform plan. - // https://github.com/hashicorp/terraform-provider-google/issues/17756 - // The bug is introduced by SetNew on "metadata" field with the object including "effective_annotations". - // "effective_annotations" cannot be set directly due to a bug that SetNew doesn't work on nested fields - // in terraform sdk. - // https://github.com/hashicorp/terraform-plugin-sdk/issues/459 - values := d.GetRawPlan().GetAttr("metadata").AsValueSlice() - if len(values) > 0 && !values[0].GetAttr("annotations").IsWhollyKnown() { - return nil - } - raw := d.Get("metadata.0.annotations") if raw == nil { return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_diff_suppress.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_diff_suppress.go index fad0451cdd8..c279eefe9de 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_diff_suppress.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_diff_suppress.go @@ -5,14 +5,52 @@ package tpgresource import ( + "bytes" + "crypto/sha256" + "encoding/hex" + "log" + "net" "reflect" "regexp" + "strconv" "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +func OptionalPrefixSuppress(prefix string) schema.SchemaDiffSuppressFunc { + return func(k, old, new string, d *schema.ResourceData) bool { + return prefix+old == new || prefix+new == old + } +} + +func IgnoreMissingKeyInMap(key string) schema.SchemaDiffSuppressFunc { + return func(k, old, new string, d *schema.ResourceData) bool { + log.Printf("[DEBUG] - suppressing diff %q with old %q, new %q", k, old, new) + if strings.HasSuffix(k, ".%") { + oldNum, err := strconv.Atoi(old) + if err != nil { + log.Printf("[ERROR] could not parse %q as number, no longer attempting diff suppress", old) + return false + } + newNum, err := strconv.Atoi(new) + if err != nil { + log.Printf("[ERROR] could not parse %q as number, no longer attempting diff suppress", new) + return false + } + return oldNum+1 == newNum + } else if strings.HasSuffix(k, "."+key) { + return old == "" + } + return false + } +} + +func OptionalSurroundingSpacesSuppress(k, old, new string, d *schema.ResourceData) bool { + return strings.TrimSpace(old) == strings.TrimSpace(new) +} + func EmptyOrDefaultStringSuppress(defaultVal string) schema.SchemaDiffSuppressFunc { return func(k, old, new string, d *schema.ResourceData) bool { return (old == "" && new == defaultVal) || (new == "" && old == defaultVal) @@ -24,10 +62,56 @@ func EmptyOrFalseSuppressBoolean(k, old, new string, d *schema.ResourceData) boo return (o == nil && !n.(bool)) } +func IpCidrRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + // The range may be a: + // A) single IP address (e.g. 10.2.3.4) + // B) CIDR format string (e.g. 10.1.2.0/24) + // C) netmask (e.g. /24) + // + // For A) and B), no diff to suppress, they have to match completely. + // For C), The API picks a network IP address and this creates a diff of the form: + // network_interface.0.alias_ip_range.0.ip_cidr_range: "10.128.1.0/24" => "/24" + // We should only compare the mask portion for this case. + if len(new) > 0 && new[0] == '/' { + oldNetmaskStartPos := strings.LastIndex(old, "/") + + if oldNetmaskStartPos != -1 { + oldNetmask := old[strings.LastIndex(old, "/"):] + if oldNetmask == new { + return true + } + } + } + + return false +} + +// Sha256DiffSuppress +// if old is the hex-encoded sha256 sum of new, treat them as equal +func Sha256DiffSuppress(_, old, new string, _ *schema.ResourceData) bool { + return hex.EncodeToString(sha256.New().Sum([]byte(old))) == new +} + func CaseDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { return strings.ToUpper(old) == strings.ToUpper(new) } +// Port range '80' and '80-80' is equivalent. +// `old` is read from the server and always has the full range format (e.g. '80-80', '1024-2048'). +// `new` can be either a single port or a port range. +func PortRangeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + return old == new+"-"+new +} + +// Single-digit hour is equivalent to hour with leading zero e.g. suppress diff 1:00 => 01:00. +// Assume either value could be in either format. +func Rfc3339TimeDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + if (len(old) == 4 && "0"+old == new) || (len(new) == 4 && "0"+new == old) { + return true + } + return false +} + func EmptyOrUnsetBlockDiffSuppress(k, old, new string, d *schema.ResourceData) bool { o, n := d.GetChange(strings.TrimSuffix(k, ".#")) return EmptyOrUnsetBlockDiffSuppressLogic(k, old, new, o, n) @@ -61,6 +145,25 @@ func EmptyOrUnsetBlockDiffSuppressLogic(k, old, new string, o, n interface{}) bo return true } +// Suppress diffs for values that are equivalent except for their use of the words "location" +// compared to "region" or "zone" +func LocationDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + return LocationDiffSuppressHelper(old, new) || LocationDiffSuppressHelper(new, old) +} + +func LocationDiffSuppressHelper(a, b string) bool { + return strings.Replace(a, "/locations/", "/regions/", 1) == b || + strings.Replace(a, "/locations/", "/zones/", 1) == b +} + +// For managed SSL certs, if new is an absolute FQDN (trailing '.') but old isn't, treat them as equals. +func AbsoluteDomainSuppress(k, old, new string, _ *schema.ResourceData) bool { + if strings.HasPrefix(k, "managed.0.domains.") { + return old == strings.TrimRight(new, ".") || new == strings.TrimRight(old, ".") + } + return false +} + func TimestampDiffSuppress(format string) schema.SchemaDiffSuppressFunc { return func(_, old, new string, _ *schema.ResourceData) bool { oldT, err := time.Parse(format, old) @@ -77,6 +180,50 @@ func TimestampDiffSuppress(format string) schema.SchemaDiffSuppressFunc { } } +// Suppresses diff for IPv4 and IPv6 different formats. +// It also suppresses diffs if an IP is changing to a reference. +func InternalIpDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { + addr_equality := false + netmask_equality := false + + addr_netmask_old := strings.Split(old, "/") + addr_netmask_new := strings.Split(new, "/") + + // Check if old or new are IPs (with or without netmask) + var addr_old net.IP + if net.ParseIP(addr_netmask_old[0]) == nil { + addr_old = net.ParseIP(old) + } else { + addr_old = net.ParseIP(addr_netmask_old[0]) + } + var addr_new net.IP + if net.ParseIP(addr_netmask_new[0]) == nil { + addr_new = net.ParseIP(new) + } else { + addr_new = net.ParseIP(addr_netmask_new[0]) + } + + if addr_old != nil { + if addr_new == nil { + // old is an IP and new is a reference + addr_equality = true + } else { + // old and new are IP addresses + addr_equality = bytes.Equal(addr_old, addr_new) + } + } + + // If old and new both have a netmask compare them, otherwise suppress + // This is not technically correct but prevents the permadiff described in https://github.com/hashicorp/terraform-provider-google/issues/16400 + if (len(addr_netmask_old)) == 2 && (len(addr_netmask_new) == 2) { + netmask_equality = addr_netmask_old[1] == addr_netmask_new[1] + } else { + netmask_equality = true + } + + return addr_equality && netmask_equality +} + // Suppress diffs for duration format. ex "60.0s" and "60s" same // https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#duration func DurationDiffSuppress(k, old, new string, d *schema.ResourceData) bool { @@ -91,6 +238,43 @@ func DurationDiffSuppress(k, old, new string, d *schema.ResourceData) bool { return oDuration == nDuration } +// Use this method when the field accepts either an IP address or a +// self_link referencing a resource (such as google_compute_route's +// next_hop_ilb) +func CompareIpAddressOrSelfLinkOrResourceName(_, old, new string, _ *schema.ResourceData) bool { + // if we can parse `new` as an IP address, then compare as strings + if net.ParseIP(new) != nil { + return new == old + } + + // otherwise compare as self links + return CompareSelfLinkOrResourceName("", old, new, nil) +} + +// Use this method when subnet is optioanl and auto_create_subnetworks = true +// API sometimes choose a subnet so the diff needs to be ignored +func CompareOptionalSubnet(_, old, new string, _ *schema.ResourceData) bool { + if IsEmptyValue(reflect.ValueOf(new)) { + return true + } + // otherwise compare as self links + return CompareSelfLinkOrResourceName("", old, new, nil) +} + +// Suppress diffs in below cases +// "https://hello-rehvs75zla-uc.a.run.app/" -> "https://hello-rehvs75zla-uc.a.run.app" +// "https://hello-rehvs75zla-uc.a.run.app" -> "https://hello-rehvs75zla-uc.a.run.app/" +func LastSlashDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { + if last := len(new) - 1; last >= 0 && new[last] == '/' { + new = new[:last] + } + + if last := len(old) - 1; last >= 0 && old[last] == '/' { + old = old[:last] + } + return new == old +} + // Suppress diffs when the value read from api // has the project number instead of the project name func ProjectNumberDiffSuppress(_, old, new string, _ *schema.ResourceData) bool { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_operation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_operation.go index 31dbb1f8dd9..1e169425f40 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_operation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/common_operation.go @@ -7,7 +7,7 @@ import ( "log" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport" cloudresourcemanager "google.golang.org/api/cloudresourcemanager/v1" ) @@ -109,7 +109,7 @@ func OperationDone(w Waiter) bool { return false } -func CommonRefreshFunc(w Waiter) retry.StateRefreshFunc { +func CommonRefreshFunc(w Waiter) resource.StateRefreshFunc { return func() (interface{}, string, error) { op, err := w.QueryOp() if err != nil { @@ -143,7 +143,7 @@ func OperationWait(w Waiter, activity string, timeout time.Duration, pollInterva return w.Error() } - c := &retry.StateChangeConf{ + c := &resource.StateChangeConf{ Pending: w.PendingStates(), Target: w.TargetStates(), Refresh: CommonRefreshFunc(w), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/labels.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/labels.go index b64bc794753..86fa89e04e9 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/labels.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/labels.go @@ -71,19 +71,6 @@ func SetLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta interface{}) return fmt.Errorf("`effective_labels` field is not present in the resource schema.") } - // If "labels" field is computed, set "terraform_labels" and "effective_labels" to computed. - // https://github.com/hashicorp/terraform-provider-google/issues/16217 - if !d.GetRawPlan().GetAttr("labels").IsWhollyKnown() { - if err := d.SetNewComputed("terraform_labels"); err != nil { - return fmt.Errorf("error setting terraform_labels to computed: %w", err) - } - - if err := d.SetNewComputed("effective_labels"); err != nil { - return fmt.Errorf("error setting effective_labels to computed: %w", err) - } - return nil - } - config := meta.(*transport_tpg.Config) // Merge provider default labels with the user defined labels in the resource to get terraform managed labels @@ -139,17 +126,6 @@ func SetMetadataLabelsDiff(_ context.Context, d *schema.ResourceDiff, meta inter return nil } - // Fix the bug that the computed and nested "labels" field disappears from the terraform plan. - // https://github.com/hashicorp/terraform-provider-google/issues/17756 - // The bug is introduced by SetNew on "metadata" field with the object including terraform_labels and effective_labels. - // "terraform_labels" and "effective_labels" cannot be set directly due to a bug that SetNew doesn't work on nested fields - // in terraform sdk. - // https://github.com/hashicorp/terraform-plugin-sdk/issues/459 - values := d.GetRawPlan().GetAttr("metadata").AsValueSlice() - if len(values) > 0 && !values[0].GetAttr("labels").IsWhollyKnown() { - return nil - } - raw := d.Get("metadata.0.labels") if raw == nil { return nil diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/utils.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/utils.go index ab376408eb9..2517af74872 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/utils.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/tpgresource/utils.go @@ -26,7 +26,6 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "golang.org/x/exp/maps" "google.golang.org/api/googleapi" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -60,14 +59,15 @@ type TerraformResourceDiff interface { // Contains functions that don't really belong anywhere else. // GetRegionFromZone returns the region from a zone for Google cloud. -// This is by removing the characters after the last '-'. +// This is by removing the last two chars from the zone name to leave the region +// If there aren't enough characters in the input string, an empty string is returned // e.g. southamerica-west1-a => southamerica-west1 func GetRegionFromZone(zone string) string { - zoneParts := strings.Split(zone, "-") - if len(zoneParts) < 3 { - return "" + if zone != "" && len(zone) > 2 { + region := zone[:len(zone)-2] + return region } - return strings.Join(zoneParts[:len(zoneParts)-1], "-") + return "" } // Infers the region based on the following (in order of priority): @@ -239,88 +239,6 @@ func ExpandStringMap(d TerraformResourceData, key string) map[string]string { return ConvertStringMap(v.(map[string]interface{})) } -// SortStringsByConfigOrder takes a slice of map[string]interface{} from a TF config -// and API data, and returns a new slice containing the API data, reorderd to match -// the TF config as closely as possible (with new items at the end of the list.) -func SortStringsByConfigOrder(configData, apiData []string) ([]string, error) { - configOrder := map[string]int{} - for index, item := range configData { - _, ok := configOrder[item] - if ok { - return nil, fmt.Errorf("configData element at %d has duplicate value `%s`", index, item) - } - configOrder[item] = index - } - - apiSeen := map[string]struct{}{} - byConfigIndex := map[int]string{} - newElements := []string{} - for index, item := range apiData { - _, ok := apiSeen[item] - if ok { - return nil, fmt.Errorf("apiData element at %d has duplicate value `%s`", index, item) - } - apiSeen[item] = struct{}{} - configIndex, found := configOrder[item] - if found { - byConfigIndex[configIndex] = item - } else { - newElements = append(newElements, item) - } - } - - // Sort set config indexes and convert to a slice of strings. This removes items present in the config - // but not present in the API response. - configIndexes := maps.Keys(byConfigIndex) - sort.Ints(configIndexes) - result := []string{} - for _, index := range configIndexes { - result = append(result, byConfigIndex[index]) - } - - // Add new elements to the end of the list, sorted alphabetically. - sort.Strings(newElements) - result = append(result, newElements...) - - return result, nil -} - -// SortMapsByConfigOrder takes a slice of map[string]interface{} from a TF config -// and API data, and returns a new slice containing the API data, reorderd to match -// the TF config as closely as possible (with new items at the end of the list.) -// idKey is be used to extract a string key from the values in the slice. -func SortMapsByConfigOrder(configData, apiData []map[string]interface{}, idKey string) ([]map[string]interface{}, error) { - configIds := make([]string, len(configData)) - for i, item := range configData { - id, ok := item[idKey].(string) - if !ok { - return nil, fmt.Errorf("configData element at %d does not contain string value in key `%s`", i, idKey) - } - configIds[i] = id - } - - apiIds := make([]string, len(apiData)) - apiMap := map[string]map[string]interface{}{} - for i, item := range apiData { - id, ok := item[idKey].(string) - if !ok { - return nil, fmt.Errorf("apiData element at %d does not contain string value in key `%s`", i, idKey) - } - apiIds[i] = id - apiMap[id] = item - } - - sortedIds, err := SortStringsByConfigOrder(configIds, apiIds) - if err != nil { - return nil, err - } - result := []map[string]interface{}{} - for _, id := range sortedIds { - result = append(result, apiMap[id]) - } - return result, nil -} - func ConvertStringMap(v map[string]interface{}) map[string]string { m := make(map[string]string) for k, val := range v { @@ -616,6 +534,31 @@ func Fake404(reasonResourceType, resourceName string) *googleapi.Error { } } +// validate name of the gcs bucket. Guidelines are located at https://cloud.google.com/storage/docs/naming-buckets +// this does not attempt to check for IP addresses or close misspellings of "google" +func CheckGCSName(name string) error { + if strings.HasPrefix(name, "goog") { + return fmt.Errorf("error: bucket name %s cannot start with %q", name, "goog") + } + + if strings.Contains(name, "google") { + return fmt.Errorf("error: bucket name %s cannot contain %q", name, "google") + } + + valid, _ := regexp.MatchString("^[a-z0-9][a-z0-9_.-]{1,220}[a-z0-9]$", name) + if !valid { + return fmt.Errorf("error: bucket name validation failed %v. See https://cloud.google.com/storage/docs/naming-buckets", name) + } + + for _, str := range strings.Split(name, ".") { + valid, _ := regexp.MatchString("^[a-z0-9_-]{1,63}$", str) + if !valid { + return fmt.Errorf("error: bucket name validation failed %v", str) + } + } + return nil +} + // CheckGoogleIamPolicy makes assertions about the contents of a google_iam_policy data source's policy_data attribute func CheckGoogleIamPolicy(value string) error { if strings.Contains(value, "\"description\":\"\"") { diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/common_polling.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/common_polling.go index 4d00f2e0c04..45d159f6652 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/common_polling.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/common_polling.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) type ( @@ -18,16 +18,16 @@ type ( // Function to check the response from polling once PollCheckResponseFunc func(resp map[string]interface{}, respErr error) PollResult - PollResult *retry.RetryError + PollResult *resource.RetryError ) // Helper functions to construct result of single pollRead as return result for a PollCheckResponseFunc func ErrorPollResult(err error) PollResult { - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) } func PendingStatusPollResult(status string) PollResult { - return retry.RetryableError(fmt.Errorf("got pending status %q", status)) + return resource.RetryableError(fmt.Errorf("got pending status %q", status)) } func SuccessPollResult() PollResult { @@ -39,12 +39,12 @@ func PollingWaitTime(pollF PollReadFunc, checkResponse PollCheckResponseFunc, ac log.Printf("[DEBUG] %s: Polling until expected state is read", activity) log.Printf("[DEBUG] Target occurrences: %d", targetOccurrences) if targetOccurrences == 1 { - return retry.Retry(timeout, func() *retry.RetryError { + return resource.Retry(timeout, func() *resource.RetryError { readResp, readErr := pollF() return checkResponse(readResp, readErr) }) } - return RetryWithTargetOccurrences(timeout, targetOccurrences, func() *retry.RetryError { + return RetryWithTargetOccurrences(timeout, targetOccurrences, func() *resource.RetryError { readResp, readErr := pollF() return checkResponse(readResp, readErr) }) @@ -54,13 +54,13 @@ func PollingWaitTime(pollF PollReadFunc, checkResponse PollCheckResponseFunc, ac // a function until it returns the specified amount of target occurrences continuously. // Adapted from the Retry function in the go SDK. func RetryWithTargetOccurrences(timeout time.Duration, targetOccurrences int, - f retry.RetryFunc) error { + f resource.RetryFunc) error { // These are used to pull the error out of the function; need a mutex to // avoid a data race. var resultErr error var resultErrMu sync.Mutex - c := &retry.StateChangeConf{ + c := &resource.StateChangeConf{ Pending: []string{"retryableerror"}, Target: []string{"success"}, Timeout: timeout, diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/config.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/config.go index c6423664439..709003b16cc 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/config.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/config.go @@ -176,7 +176,7 @@ type Config struct { DefaultLabels map[string]string AddTerraformAttributionLabel bool TerraformAttributionLabelAdditionStrategy string - // PollInterval is passed to retry.StateChangeConf in common_operation.go + // PollInterval is passed to resource.StateChangeConf in common_operation.go // It controls the interval at which we poll for successful operations PollInterval time.Duration @@ -222,7 +222,6 @@ type Config struct { CloudRunV2BasePath string CloudSchedulerBasePath string CloudTasksBasePath string - ComposerBasePath string ComputeBasePath string ContainerAnalysisBasePath string ContainerAttachedBasePath string @@ -261,7 +260,6 @@ type Config struct { IapBasePath string IdentityPlatformBasePath string IntegrationConnectorsBasePath string - IntegrationsBasePath string KMSBasePath string LoggingBasePath string LookerBasePath string @@ -287,11 +285,8 @@ type Config struct { SecretManagerBasePath string SecureSourceManagerBasePath string SecurityCenterBasePath string - SecurityCenterManagementBasePath string - SecurityCenterV2BasePath string SecuritypostureBasePath string ServiceManagementBasePath string - ServiceNetworkingBasePath string ServiceUsageBasePath string SourceRepoBasePath string SpannerBasePath string @@ -308,12 +303,14 @@ type Config struct { WorkflowsBasePath string CloudBillingBasePath string + ComposerBasePath string ContainerBasePath string DataflowBasePath string IamCredentialsBasePath string ResourceManagerV3BasePath string IAMBasePath string CloudIoTBasePath string + ServiceNetworkingBasePath string BigtableAdminBasePath string TagsLocationBasePath string @@ -360,7 +357,6 @@ const CloudRunBasePathKey = "CloudRun" const CloudRunV2BasePathKey = "CloudRunV2" const CloudSchedulerBasePathKey = "CloudScheduler" const CloudTasksBasePathKey = "CloudTasks" -const ComposerBasePathKey = "Composer" const ComputeBasePathKey = "Compute" const ContainerAnalysisBasePathKey = "ContainerAnalysis" const ContainerAttachedBasePathKey = "ContainerAttached" @@ -399,7 +395,6 @@ const IAMWorkforcePoolBasePathKey = "IAMWorkforcePool" const IapBasePathKey = "Iap" const IdentityPlatformBasePathKey = "IdentityPlatform" const IntegrationConnectorsBasePathKey = "IntegrationConnectors" -const IntegrationsBasePathKey = "Integrations" const KMSBasePathKey = "KMS" const LoggingBasePathKey = "Logging" const LookerBasePathKey = "Looker" @@ -425,11 +420,8 @@ const ResourceManagerBasePathKey = "ResourceManager" const SecretManagerBasePathKey = "SecretManager" const SecureSourceManagerBasePathKey = "SecureSourceManager" const SecurityCenterBasePathKey = "SecurityCenter" -const SecurityCenterManagementBasePathKey = "SecurityCenterManagement" -const SecurityCenterV2BasePathKey = "SecurityCenterV2" const SecuritypostureBasePathKey = "Securityposture" const ServiceManagementBasePathKey = "ServiceManagement" -const ServiceNetworkingBasePathKey = "ServiceNetworking" const ServiceUsageBasePathKey = "ServiceUsage" const SourceRepoBasePathKey = "SourceRepo" const SpannerBasePathKey = "Spanner" @@ -445,11 +437,13 @@ const VPCAccessBasePathKey = "VPCAccess" const WorkbenchBasePathKey = "Workbench" const WorkflowsBasePathKey = "Workflows" const CloudBillingBasePathKey = "CloudBilling" +const ComposerBasePathKey = "Composer" const ContainerBasePathKey = "Container" const DataflowBasePathKey = "Dataflow" const IAMBasePathKey = "IAM" const IamCredentialsBasePathKey = "IamCredentials" const ResourceManagerV3BasePathKey = "ResourceManagerV3" +const ServiceNetworkingBasePathKey = "ServiceNetworking" const BigtableAdminBasePathKey = "BigtableAdmin" const ContainerAwsBasePathKey = "ContainerAws" const ContainerAzureBasePathKey = "ContainerAzure" @@ -492,7 +486,6 @@ var DefaultBasePaths = map[string]string{ CloudRunV2BasePathKey: "https://run.googleapis.com/v2/", CloudSchedulerBasePathKey: "https://cloudscheduler.googleapis.com/v1/", CloudTasksBasePathKey: "https://cloudtasks.googleapis.com/v2/", - ComposerBasePathKey: "https://composer.googleapis.com/v1/", ComputeBasePathKey: "https://compute.googleapis.com/compute/v1/", ContainerAnalysisBasePathKey: "https://containeranalysis.googleapis.com/v1/", ContainerAttachedBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", @@ -531,7 +524,6 @@ var DefaultBasePaths = map[string]string{ IapBasePathKey: "https://iap.googleapis.com/v1/", IdentityPlatformBasePathKey: "https://identitytoolkit.googleapis.com/v2/", IntegrationConnectorsBasePathKey: "https://connectors.googleapis.com/v1/", - IntegrationsBasePathKey: "https://integrations.googleapis.com/v1/", KMSBasePathKey: "https://cloudkms.googleapis.com/v1/", LoggingBasePathKey: "https://logging.googleapis.com/v2/", LookerBasePathKey: "https://looker.googleapis.com/v1/", @@ -557,11 +549,8 @@ var DefaultBasePaths = map[string]string{ SecretManagerBasePathKey: "https://secretmanager.googleapis.com/v1/", SecureSourceManagerBasePathKey: "https://securesourcemanager.googleapis.com/v1/", SecurityCenterBasePathKey: "https://securitycenter.googleapis.com/v1/", - SecurityCenterManagementBasePathKey: "https://securitycentermanagement.googleapis.com/v1/", - SecurityCenterV2BasePathKey: "https://securitycenter.googleapis.com/v2/", SecuritypostureBasePathKey: "https://securityposture.googleapis.com/v1/", ServiceManagementBasePathKey: "https://servicemanagement.googleapis.com/v1/", - ServiceNetworkingBasePathKey: "https://servicenetworking.googleapis.com/v1/", ServiceUsageBasePathKey: "https://serviceusage.googleapis.com/v1/", SourceRepoBasePathKey: "https://sourcerepo.googleapis.com/v1/", SpannerBasePathKey: "https://spanner.googleapis.com/v1/", @@ -577,11 +566,13 @@ var DefaultBasePaths = map[string]string{ WorkbenchBasePathKey: "https://notebooks.googleapis.com/v2/", WorkflowsBasePathKey: "https://workflows.googleapis.com/v1/", CloudBillingBasePathKey: "https://cloudbilling.googleapis.com/v1/", + ComposerBasePathKey: "https://composer.googleapis.com/v1/", ContainerBasePathKey: "https://container.googleapis.com/v1/", DataflowBasePathKey: "https://dataflow.googleapis.com/v1b3/", IAMBasePathKey: "https://iam.googleapis.com/v1/", IamCredentialsBasePathKey: "https://iamcredentials.googleapis.com/v1/", ResourceManagerV3BasePathKey: "https://cloudresourcemanager.googleapis.com/v3/", + ServiceNetworkingBasePathKey: "https://servicenetworking.googleapis.com/v1/", BigtableAdminBasePathKey: "https://bigtableadmin.googleapis.com/v2/", ContainerAwsBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", ContainerAzureBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/", @@ -835,11 +826,6 @@ func SetEndpointDefaults(d *schema.ResourceData) error { "GOOGLE_CLOUD_TASKS_CUSTOM_ENDPOINT", }, DefaultBasePaths[CloudTasksBasePathKey])) } - if d.Get("composer_custom_endpoint") == "" { - d.Set("composer_custom_endpoint", MultiEnvDefault([]string{ - "GOOGLE_COMPOSER_CUSTOM_ENDPOINT", - }, DefaultBasePaths[ComposerBasePathKey])) - } if d.Get("compute_custom_endpoint") == "" { d.Set("compute_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_COMPUTE_CUSTOM_ENDPOINT", @@ -1030,11 +1016,6 @@ func SetEndpointDefaults(d *schema.ResourceData) error { "GOOGLE_INTEGRATION_CONNECTORS_CUSTOM_ENDPOINT", }, DefaultBasePaths[IntegrationConnectorsBasePathKey])) } - if d.Get("integrations_custom_endpoint") == "" { - d.Set("integrations_custom_endpoint", MultiEnvDefault([]string{ - "GOOGLE_INTEGRATIONS_CUSTOM_ENDPOINT", - }, DefaultBasePaths[IntegrationsBasePathKey])) - } if d.Get("kms_custom_endpoint") == "" { d.Set("kms_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_KMS_CUSTOM_ENDPOINT", @@ -1160,16 +1141,6 @@ func SetEndpointDefaults(d *schema.ResourceData) error { "GOOGLE_SECURITY_CENTER_CUSTOM_ENDPOINT", }, DefaultBasePaths[SecurityCenterBasePathKey])) } - if d.Get("security_center_management_custom_endpoint") == "" { - d.Set("security_center_management_custom_endpoint", MultiEnvDefault([]string{ - "GOOGLE_SECURITY_CENTER_MANAGEMENT_CUSTOM_ENDPOINT", - }, DefaultBasePaths[SecurityCenterManagementBasePathKey])) - } - if d.Get("security_center_v2_custom_endpoint") == "" { - d.Set("security_center_v2_custom_endpoint", MultiEnvDefault([]string{ - "GOOGLE_SECURITY_CENTER_V2_CUSTOM_ENDPOINT", - }, DefaultBasePaths[SecurityCenterV2BasePathKey])) - } if d.Get("securityposture_custom_endpoint") == "" { d.Set("securityposture_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_SECURITYPOSTURE_CUSTOM_ENDPOINT", @@ -1180,11 +1151,6 @@ func SetEndpointDefaults(d *schema.ResourceData) error { "GOOGLE_SERVICE_MANAGEMENT_CUSTOM_ENDPOINT", }, DefaultBasePaths[ServiceManagementBasePathKey])) } - if d.Get("service_networking_custom_endpoint") == "" { - d.Set("service_networking_custom_endpoint", MultiEnvDefault([]string{ - "GOOGLE_SERVICE_NETWORKING_CUSTOM_ENDPOINT", - }, DefaultBasePaths[ServiceNetworkingBasePathKey])) - } if d.Get("service_usage_custom_endpoint") == "" { d.Set("service_usage_custom_endpoint", MultiEnvDefault([]string{ "GOOGLE_SERVICE_USAGE_CUSTOM_ENDPOINT", @@ -2016,7 +1982,6 @@ type StaticTokenSource struct { // If initialCredentialsOnly is true, don't follow the impersonation settings and return the initial set of creds // instead. func (c *Config) GetCredentials(clientScopes []string, initialCredentialsOnly bool) (googleoauth.Credentials, error) { - // UniverseDomain is assumed to be the previously set provider-configured value for access tokens if c.AccessToken != "" { contents, _, err := verify.PathOrContents(c.AccessToken) if err != nil { @@ -2040,25 +2005,12 @@ func (c *Config) GetCredentials(clientScopes []string, initialCredentialsOnly bo }, nil } - // UniverseDomain is set by the credential file's "universe_domain" field if c.Credentials != "" { contents, _, err := verify.PathOrContents(c.Credentials) if err != nil { return googleoauth.Credentials{}, fmt.Errorf("error loading credentials: %s", err) } - var content map[string]any - if err := json.Unmarshal([]byte(contents), &content); err != nil { - return googleoauth.Credentials{}, fmt.Errorf("error unmarshaling credentials: %s", err) - } - - if content["universe_domain"] != nil { - c.UniverseDomain = content["universe_domain"].(string) - } else { - // Unset UniverseDomain if not found in credentials file - c.UniverseDomain = "" - } - if c.ImpersonateServiceAccount != "" && !initialCredentialsOnly { opts := []option.ClientOption{option.WithCredentialsJSON([]byte(contents)), option.ImpersonateCredentials(c.ImpersonateServiceAccount, c.ImpersonateServiceAccountDelegates...), option.WithScopes(clientScopes...)} creds, err := transport.Creds(context.TODO(), opts...) @@ -2088,50 +2040,31 @@ func (c *Config) GetCredentials(clientScopes []string, initialCredentialsOnly bo } } - var creds *googleoauth.Credentials - var err error if c.ImpersonateServiceAccount != "" && !initialCredentialsOnly { opts := option.ImpersonateCredentials(c.ImpersonateServiceAccount, c.ImpersonateServiceAccountDelegates...) - creds, err = transport.Creds(context.TODO(), opts, option.WithScopes(clientScopes...)) + creds, err := transport.Creds(context.TODO(), opts, option.WithScopes(clientScopes...)) if err != nil { return googleoauth.Credentials{}, err } - } else { - log.Printf("[INFO] Authenticating using DefaultClient...") - log.Printf("[INFO] -- Scopes: %s", clientScopes) - if c.UniverseDomain != "" && c.UniverseDomain != "googleapis.com" { - log.Printf("[INFO] -- Sending JwtWithScope option") - creds, err = transport.Creds(context.Background(), option.WithScopes(clientScopes...), internaloption.EnableJwtWithScope()) - if err != nil { - return googleoauth.Credentials{}, fmt.Errorf("Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block. No credentials loaded. To use your gcloud credentials, run 'gcloud auth application-default login'. Original error: %w", err) - } - } else { - creds, err = transport.Creds(context.Background(), option.WithScopes(clientScopes...)) - if err != nil { - return googleoauth.Credentials{}, fmt.Errorf("Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block. No credentials loaded. To use your gcloud credentials, run 'gcloud auth application-default login'. Original error: %w", err) - } - } + return *creds, nil } - if creds.JSON != nil { - var content map[string]any - if err := json.Unmarshal([]byte(creds.JSON), &content); err != nil { - log.Printf("[WARN] error unmarshaling credentials, skipping Universe Domain detection") - c.UniverseDomain = "" - } else if content["universe_domain"] != nil { - c.UniverseDomain = content["universe_domain"].(string) - } else { - // Unset UniverseDomain if not found in ADC credentials file - c.UniverseDomain = "" - } - } else { - // creds.GetUniverseDomain may retrieve a domain from the metadata server - ud, err := creds.GetUniverseDomain() + log.Printf("[INFO] Authenticating using DefaultClient...") + log.Printf("[INFO] -- Scopes: %s", clientScopes) + + if c.UniverseDomain != "" && c.UniverseDomain != "googleapis.com" { + log.Printf("[INFO] -- Sending JwtWithScope option") + creds, err := transport.Creds(context.Background(), option.WithScopes(clientScopes...), internaloption.EnableJwtWithScope()) if err != nil { - log.Printf("[WARN] Error retrieving universe domain: %s", err) + return googleoauth.Credentials{}, fmt.Errorf("Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block. No credentials loaded. To use your gcloud credentials, run 'gcloud auth application-default login'. Original error: %w", err) } - c.UniverseDomain = ud + return *creds, nil + } + + creds, err := transport.Creds(context.Background(), option.WithScopes(clientScopes...)) + if err != nil { + return googleoauth.Credentials{}, fmt.Errorf("Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block. No credentials loaded. To use your gcloud credentials, run 'gcloud auth application-default login'. Original error: %w", err) } return *creds, nil @@ -2183,7 +2116,6 @@ func ConfigureBasePaths(c *Config) { c.CloudRunV2BasePath = DefaultBasePaths[CloudRunV2BasePathKey] c.CloudSchedulerBasePath = DefaultBasePaths[CloudSchedulerBasePathKey] c.CloudTasksBasePath = DefaultBasePaths[CloudTasksBasePathKey] - c.ComposerBasePath = DefaultBasePaths[ComposerBasePathKey] c.ComputeBasePath = DefaultBasePaths[ComputeBasePathKey] c.ContainerAnalysisBasePath = DefaultBasePaths[ContainerAnalysisBasePathKey] c.ContainerAttachedBasePath = DefaultBasePaths[ContainerAttachedBasePathKey] @@ -2222,7 +2154,6 @@ func ConfigureBasePaths(c *Config) { c.IapBasePath = DefaultBasePaths[IapBasePathKey] c.IdentityPlatformBasePath = DefaultBasePaths[IdentityPlatformBasePathKey] c.IntegrationConnectorsBasePath = DefaultBasePaths[IntegrationConnectorsBasePathKey] - c.IntegrationsBasePath = DefaultBasePaths[IntegrationsBasePathKey] c.KMSBasePath = DefaultBasePaths[KMSBasePathKey] c.LoggingBasePath = DefaultBasePaths[LoggingBasePathKey] c.LookerBasePath = DefaultBasePaths[LookerBasePathKey] @@ -2248,11 +2179,8 @@ func ConfigureBasePaths(c *Config) { c.SecretManagerBasePath = DefaultBasePaths[SecretManagerBasePathKey] c.SecureSourceManagerBasePath = DefaultBasePaths[SecureSourceManagerBasePathKey] c.SecurityCenterBasePath = DefaultBasePaths[SecurityCenterBasePathKey] - c.SecurityCenterManagementBasePath = DefaultBasePaths[SecurityCenterManagementBasePathKey] - c.SecurityCenterV2BasePath = DefaultBasePaths[SecurityCenterV2BasePathKey] c.SecuritypostureBasePath = DefaultBasePaths[SecuritypostureBasePathKey] c.ServiceManagementBasePath = DefaultBasePaths[ServiceManagementBasePathKey] - c.ServiceNetworkingBasePath = DefaultBasePaths[ServiceNetworkingBasePathKey] c.ServiceUsageBasePath = DefaultBasePaths[ServiceUsageBasePathKey] c.SourceRepoBasePath = DefaultBasePaths[SourceRepoBasePathKey] c.SpannerBasePath = DefaultBasePaths[SpannerBasePathKey] @@ -2277,6 +2205,7 @@ func ConfigureBasePaths(c *Config) { c.IamCredentialsBasePath = DefaultBasePaths[IamCredentialsBasePathKey] c.ResourceManagerV3BasePath = DefaultBasePaths[ResourceManagerV3BasePathKey] c.IAMBasePath = DefaultBasePaths[IAMBasePathKey] + c.ServiceNetworkingBasePath = DefaultBasePaths[ServiceNetworkingBasePathKey] c.BigQueryBasePath = DefaultBasePaths[BigQueryBasePathKey] c.BigtableAdminBasePath = DefaultBasePaths[BigtableAdminBasePathKey] c.TagsLocationBasePath = DefaultBasePaths[TagsLocationBasePathKey] diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/error_retry_predicates.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/error_retry_predicates.go index b43ef816e15..32c85d55ec0 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/error_retry_predicates.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/error_retry_predicates.go @@ -455,31 +455,6 @@ func Is429QuotaError(err error) (bool, string) { return false, "" } -// Do retry if operation returns a 429 and the reason is RATE_LIMIT_EXCEEDED -func Is429RetryableQuotaError(err error) (bool, string) { - if gerr, ok := err.(*googleapi.Error); ok { - if gerr.Code == 429 { - // Quota error isn't necessarily retryable if it's a resource instance limit; check details - isRateLimitExceeded := false - for _, d := range gerr.Details { - data := d.(map[string]interface{}) - dType, ok := data["@type"] - // Find google.rpc.ErrorInfo in Details - if ok && strings.Contains(dType.(string), "ErrorInfo") { - if v, ok := data["reason"]; ok { - if v.(string) == "RATE_LIMIT_EXCEEDED" { - isRateLimitExceeded = true - break - } - } - } - } - return isRateLimitExceeded, "429s are retryable for this resource, but only if the reason is RATE_LIMIT_EXCEEDED" - } - } - return false, "" -} - // Retry if App Engine operation returns a 409 with a specific message for // concurrent operations, or a 404 indicating p4sa has not yet propagated. func IsAppEngineRetryableError(err error) (bool, string) { @@ -494,21 +469,6 @@ func IsAppEngineRetryableError(err error) (bool, string) { return false, "" } -// Retry if Orgpolicy operation returns a 403 with a specific message -// indicating the parent resource does not exist. -func IsOrgpolicyRetryableError(err error) (bool, string) { - if gerr, ok := err.(*googleapi.Error); ok { - if gerr.Code != 403 { - return false, "" - } - pattern := regexp.MustCompile("Permission 'orgpolicy\\.policy\\.[a-z]*' denied on resource '//[a-z]*\\.googleapis\\.com/(projects|folders)/[a-z0-9-]*/policies/[a-zA-Z.]*' \\(or it may not exist\\)\\.") - if pattern.MatchString(gerr.Body) { - return true, "Waiting for parent resource to be ready" - } - } - return false, "" -} - // Bigtable uses gRPC and thus does not return errors of type *googleapi.Error. // Instead the errors returned are *status.Error. See the types of codes returned // here (https://pkg.go.dev/google.golang.org/grpc/codes#Code). diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_client_creation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_client_creation.go index 46bd039cb56..58c8db9a1eb 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_client_creation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_client_creation.go @@ -26,6 +26,7 @@ import ( apikeys "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/apikeys" assuredworkloads "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/assuredworkloads" + bigqueryreservation "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation" cloudbuild "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild" clouddeploy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/clouddeploy" cloudresourcemanager "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudresourcemanager" @@ -38,6 +39,8 @@ import ( firebaserules "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/firebaserules" gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub" networkconnectivity "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/networkconnectivity" + orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy" + privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca" recaptchaenterprise "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/recaptchaenterprise" ) @@ -87,6 +90,29 @@ func NewDCLAssuredWorkloadsClient(config *Config, userAgent, billingProject stri return assuredworkloads.NewClient(dclConfig) } +func NewDCLBigqueryReservationClient(config *Config, userAgent, billingProject string, timeout time.Duration) *bigqueryreservation.Client { + configOptions := []dcl.ConfigOption{ + dcl.WithHTTPClient(config.Client), + dcl.WithUserAgent(userAgent), + dcl.WithLogger(dclLogger{}), + dcl.WithBasePath(config.BigqueryReservationBasePath), + } + + if timeout != 0 { + configOptions = append(configOptions, dcl.WithTimeout(timeout)) + } + + if config.UserProjectOverride { + configOptions = append(configOptions, dcl.WithUserProjectOverride()) + if billingProject != "" { + configOptions = append(configOptions, dcl.WithBillingProject(billingProject)) + } + } + + dclConfig := dcl.NewConfig(configOptions...) + return bigqueryreservation.NewClient(dclConfig) +} + func NewDCLCloudbuildClient(config *Config, userAgent, billingProject string, timeout time.Duration) *cloudbuild.Client { configOptions := []dcl.ConfigOption{ dcl.WithHTTPClient(config.Client), @@ -363,6 +389,52 @@ func NewDCLNetworkConnectivityClient(config *Config, userAgent, billingProject s return networkconnectivity.NewClient(dclConfig) } +func NewDCLOrgPolicyClient(config *Config, userAgent, billingProject string, timeout time.Duration) *orgpolicy.Client { + configOptions := []dcl.ConfigOption{ + dcl.WithHTTPClient(config.Client), + dcl.WithUserAgent(userAgent), + dcl.WithLogger(dclLogger{}), + dcl.WithBasePath(config.OrgPolicyBasePath), + } + + if timeout != 0 { + configOptions = append(configOptions, dcl.WithTimeout(timeout)) + } + + if config.UserProjectOverride { + configOptions = append(configOptions, dcl.WithUserProjectOverride()) + if billingProject != "" { + configOptions = append(configOptions, dcl.WithBillingProject(billingProject)) + } + } + + dclConfig := dcl.NewConfig(configOptions...) + return orgpolicy.NewClient(dclConfig) +} + +func NewDCLPrivatecaClient(config *Config, userAgent, billingProject string, timeout time.Duration) *privateca.Client { + configOptions := []dcl.ConfigOption{ + dcl.WithHTTPClient(config.Client), + dcl.WithUserAgent(userAgent), + dcl.WithLogger(dclLogger{}), + dcl.WithBasePath(config.PrivatecaBasePath), + } + + if timeout != 0 { + configOptions = append(configOptions, dcl.WithTimeout(timeout)) + } + + if config.UserProjectOverride { + configOptions = append(configOptions, dcl.WithUserProjectOverride()) + if billingProject != "" { + configOptions = append(configOptions, dcl.WithBillingProject(billingProject)) + } + } + + dclConfig := dcl.NewConfig(configOptions...) + return privateca.NewClient(dclConfig) +} + func NewDCLRecaptchaEnterpriseClient(config *Config, userAgent, billingProject string, timeout time.Duration) *recaptchaenterprise.Client { configOptions := []dcl.ConfigOption{ dcl.WithHTTPClient(config.Client), diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_endpoints.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_endpoints.go index 0530e74c534..79f2c205ea1 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_endpoints.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/provider_dcl_endpoints.go @@ -69,6 +69,12 @@ var GKEHubFeatureEndpointEntry = &schema.Schema{ Optional: true, } +var OrgPolicyEndpointEntryKey = "org_policy_custom_endpoint" +var OrgPolicyEndpointEntry = &schema.Schema{ + Type: schema.TypeString, + Optional: true, +} + var RecaptchaEnterpriseEndpointEntryKey = "recaptcha_enterprise_custom_endpoint" var RecaptchaEnterpriseEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -83,6 +89,7 @@ type DCLConfig struct { EventarcBasePath string FirebaserulesBasePath string GKEHubFeatureBasePath string + OrgPolicyBasePath string RecaptchaEnterpriseBasePath string } @@ -94,6 +101,7 @@ func ConfigureDCLProvider(provider *schema.Provider) { provider.Schema[EventarcEndpointEntryKey] = EventarcEndpointEntry provider.Schema[FirebaserulesEndpointEntryKey] = FirebaserulesEndpointEntry provider.Schema[GKEHubFeatureEndpointEntryKey] = GKEHubFeatureEndpointEntry + provider.Schema[OrgPolicyEndpointEntryKey] = OrgPolicyEndpointEntry provider.Schema[RecaptchaEnterpriseEndpointEntryKey] = RecaptchaEnterpriseEndpointEntry } @@ -133,6 +141,11 @@ func HandleDCLCustomEndpointDefaults(d *schema.ResourceData) { "GOOGLE_GKEHUB_FEATURE_CUSTOM_ENDPOINT", }, "")) } + if d.Get(OrgPolicyEndpointEntryKey) == "" { + d.Set(OrgPolicyEndpointEntryKey, MultiEnvDefault([]string{ + "GOOGLE_ORG_POLICY_CUSTOM_ENDPOINT", + }, "")) + } if d.Get(RecaptchaEnterpriseEndpointEntryKey) == "" { d.Set(RecaptchaEnterpriseEndpointEntryKey, MultiEnvDefault([]string{ "GOOGLE_RECAPTCHA_ENTERPRISE_CUSTOM_ENDPOINT", @@ -184,6 +197,12 @@ func ConfigureDCLCustomEndpointAttributesFramework(frameworkSchema *framework_sc CustomEndpointValidator(), }, } + frameworkSchema.Attributes["org_policy_custom_endpoint"] = framework_schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + CustomEndpointValidator(), + }, + } frameworkSchema.Attributes["recaptcha_enterprise_custom_endpoint"] = framework_schema.StringAttribute{ Optional: true, Validators: []validator.String{ @@ -193,15 +212,15 @@ func ConfigureDCLCustomEndpointAttributesFramework(frameworkSchema *framework_sc } func ProviderDCLConfigure(d *schema.ResourceData, config *Config) interface{} { - // networkConnectivity uses mmv1 basePath, assuredworkloads has a location variable in the basepath, can't be defined here. - config.ApikeysBasePath = "https://apikeys.googleapis.com/v2/" + config.ApikeysBasePath = d.Get(ApikeysEndpointEntryKey).(string) config.AssuredWorkloadsBasePath = d.Get(AssuredWorkloadsEndpointEntryKey).(string) - config.CloudBuildWorkerPoolBasePath = "https://cloudbuild.googleapis.com/v1/" - config.CloudResourceManagerBasePath = "https://cloudresourcemanager.googleapis.com/" - config.EventarcBasePath = "https://eventarc.googleapis.com/v1/" - config.FirebaserulesBasePath = "https://firebaserules.googleapis.com/v1/" - config.GKEHubFeatureBasePath = "https://gkehub.googleapis.com/v1beta1/" - config.RecaptchaEnterpriseBasePath = "https://recaptchaenterprise.googleapis.com/v1/" - + config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string) + config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string) + config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string) + config.FirebaserulesBasePath = d.Get(FirebaserulesEndpointEntryKey).(string) + config.GKEHubFeatureBasePath = d.Get(GKEHubFeatureEndpointEntryKey).(string) + config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string) + config.RecaptchaEnterpriseBasePath = d.Get(RecaptchaEnterpriseEndpointEntryKey).(string) + config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string) return config } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_transport.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_transport.go index 558f64cc4b2..e706defc610 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_transport.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_transport.go @@ -6,7 +6,7 @@ // Do not use for waiting on operations or polling of resource state, // especially if the expected state (operation done, resource ready, etc) // takes longer to reach than the default client Timeout. -// In those cases, Retry(...)/retry.Retry with appropriate timeout +// In those cases, Retry(...)/resource.Retry with appropriate timeout // and error predicates/handling should be used as a wrapper around the request // instead. // @@ -42,7 +42,7 @@ import ( "net/http/httputil" "time" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "google.golang.org/api/googleapi" ) @@ -181,7 +181,7 @@ func copyHttpRequest(req *http.Request) (*http.Request, error) { // checkForRetryableError uses the googleapi.CheckResponse util to check for // errors in the response, and determines whether there is a retryable error. // in response/response error. -func (t *retryTransport) checkForRetryableError(resp *http.Response, respErr error) *retry.RetryError { +func (t *retryTransport) checkForRetryableError(resp *http.Response, respErr error) *resource.RetryError { var errToCheck error if respErr != nil { @@ -196,7 +196,7 @@ func (t *retryTransport) checkForRetryableError(resp *http.Response, respErr err // error code and messages in the response body. dumpBytes, err := httputil.DumpResponse(resp, true) if err != nil { - return retry.NonRetryableError(fmt.Errorf("unable to check response for error: %v", err)) + return resource.NonRetryableError(fmt.Errorf("unable to check response for error: %v", err)) } respToCheck.Body = ioutil.NopCloser(bytes.NewReader(dumpBytes)) } @@ -207,7 +207,7 @@ func (t *retryTransport) checkForRetryableError(resp *http.Response, respErr err return nil } if IsRetryableError(errToCheck, t.retryPredicates, nil) { - return retry.RetryableError(errToCheck) + return resource.RetryableError(errToCheck) } - return retry.NonRetryableError(errToCheck) + return resource.NonRetryableError(errToCheck) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_utils.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_utils.go index aa1c4767cb0..fb32cf94d25 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_utils.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/retry_utils.go @@ -7,7 +7,7 @@ import ( "time" "github.com/hashicorp/errwrap" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) type RetryOptions struct { @@ -38,7 +38,7 @@ func Retry(opt RetryOptions) error { // The error is not retryable. return "", "done", err } - stateChange := &retry.StateChangeConf{ + stateChange := &resource.StateChangeConf{ Pending: []string{ "retrying", }, @@ -54,15 +54,15 @@ func Retry(opt RetryOptions) error { return err } - return retry.Retry(opt.Timeout, func() *retry.RetryError { + return resource.Retry(opt.Timeout, func() *resource.RetryError { err := opt.RetryFunc() if err == nil { return nil } if IsRetryableError(err, opt.ErrorRetryPredicates, opt.ErrorAbortPredicates) { - return retry.RetryableError(err) + return resource.RetryableError(err) } - return retry.NonRetryableError(err) + return resource.NonRetryableError(err) }) } diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/transport.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/transport.go index d775a9abc0c..d1f16928831 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/transport.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/transport/transport.go @@ -26,16 +26,12 @@ type SendRequestOptions struct { UserAgent string Body map[string]any Timeout time.Duration - Headers http.Header ErrorRetryPredicates []RetryErrorPredicateFunc ErrorAbortPredicates []RetryErrorPredicateFunc } func SendRequest(opt SendRequestOptions) (map[string]interface{}, error) { - reqHeaders := opt.Headers - if reqHeaders == nil { - reqHeaders = make(http.Header) - } + reqHeaders := make(http.Header) reqHeaders.Set("User-Agent", opt.UserAgent) reqHeaders.Set("Content-Type", "application/json") @@ -129,19 +125,6 @@ func AddQueryParams(rawurl string, params map[string]string) (string, error) { return u.String(), nil } -func AddArrayQueryParams(rawurl string, param string, values []interface{}) (string, error) { - u, err := url.Parse(rawurl) - if err != nil { - return "", err - } - q := u.Query() - for _, v := range values { - q.Add(param, v.(string)) - } - u.RawQuery = q.Encode() - return u.String(), nil -} - func HandleNotFoundError(err error, d *schema.ResourceData, resource string) error { if IsGoogleApiErrorWithCode(err, 404) { log.Printf("[WARN] Removing %s because it's gone", resource) diff --git a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/verify/validation.go b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/verify/validation.go index 710a1a106ef..2d3768197f6 100644 --- a/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/verify/validation.go +++ b/terraform/providers/google/vendor/github.com/hashicorp/terraform-provider-google/google/verify/validation.go @@ -76,16 +76,6 @@ var ( Rfc6996Asn32BitMin = int64(4200000000) Rfc6996Asn32BitMax = int64(4294967294) GcpRouterPartnerAsn = int64(16550) - - // Format of GCS Bucket Name - // https://cloud.google.com/storage/docs/naming-buckets - GCSNameValidChars = "^[a-z0-9_.-]*$" - GCSNameStartEndChars = "^[a-z|0-9].*[a-z|0-9]$" - GCSNameLength = "^.{3,222}" - GCSNameLengthSplit = "^.{1,63}$" - GCSNameCidr = "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$" - GCSNameGoogPrefix = "^goog.*$" - GCSNameContainsGoogle = "^.*google.*$" ) var Rfc1918Networks = []string{ @@ -101,44 +91,6 @@ func ValidateGCEName(v interface{}, k string) (ws []string, errors []error) { return ValidateRegexp(re)(v, k) } -// validateGCSName ensures the name of a gcs bucket matches the requirements for GCS Buckets -// https://cloud.google.com/storage/docs/naming-buckets -func ValidateGCSName(v interface{}, k string) (ws []string, errors []error) { - value := v.(string) - - if !regexp.MustCompile(GCSNameValidChars).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value can only contain lowercase letters, numeric characters, dashes (-), underscores (_), and dots (.)", value)) - } - - if !regexp.MustCompile(GCSNameStartEndChars).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value must start and end with a number or letter", value)) - } - - if !regexp.MustCompile(GCSNameLength).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value must contain 3-63 characters. Names containing dots can contain up to 222 characters, but each dot-separated component can be no longer than 63 characters", value)) - } - - for _, str := range strings.Split(value, ".") { - if !regexp.MustCompile(GCSNameLengthSplit).MatchString(str) { - errors = append(errors, fmt.Errorf("%q name value must contain 3-63 characters. Names containing dots can contain up to 222 characters, but each dot-separated component can be no longer than 63 characters", value)) - } - } - - if regexp.MustCompile(GCSNameCidr).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value cannot be represented as an IP address in dotted-decimal notation (for example, 192.168.5.4)", value)) - } - - if regexp.MustCompile(GCSNameGoogPrefix).MatchString(value) { - errors = append(errors, fmt.Errorf("%q name value cannot begin with the \"goog\" prefix", value)) - } - - if regexp.MustCompile(GCSNameContainsGoogle).MatchString(strings.ReplaceAll(value, "0", "o")) { - errors = append(errors, fmt.Errorf("%q name value cannot contain \"google\" or close misspellings, such as \"g00gle\"", value)) - } - - return -} - // Ensure that the BGP ASN value of Cloud Router is a valid value as per RFC6996 or a value of 16550 func ValidateRFC6996Asn(v interface{}, k string) (ws []string, errors []error) { value := int64(v.(int)) diff --git a/terraform/providers/google/vendor/go4.org/netipx/.gitignore b/terraform/providers/google/vendor/go4.org/netipx/.gitignore deleted file mode 100644 index c60fe1e0c26..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -crashers -suppressions -netaddr-fuzz.zip diff --git a/terraform/providers/google/vendor/go4.org/netipx/.gitmodules b/terraform/providers/google/vendor/go4.org/netipx/.gitmodules deleted file mode 100644 index e1ebefa586f..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "corpus"] - path = corpus - url = https://github.com/inetaf/netaddr-corpus.git diff --git a/terraform/providers/google/vendor/go4.org/netipx/AUTHORS b/terraform/providers/google/vendor/go4.org/netipx/AUTHORS deleted file mode 100644 index ac0d1591b3d..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/AUTHORS +++ /dev/null @@ -1,4 +0,0 @@ -Alex Willmer -Matt Layher -Tailscale Inc. -Tobias Klauser diff --git a/terraform/providers/google/vendor/go4.org/netipx/LICENSE b/terraform/providers/google/vendor/go4.org/netipx/LICENSE deleted file mode 100644 index c47d4315ae4..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2020 The Inet.af AUTHORS. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Tailscale Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/terraform/providers/google/vendor/go4.org/netipx/README.md b/terraform/providers/google/vendor/go4.org/netipx/README.md deleted file mode 100644 index 74bfa417790..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# netipx [![Test Status](https://github.com/go4org/netipx/workflows/Linux/badge.svg)](https://github.com/go4org/netipx/actions) [![Go Reference](https://pkg.go.dev/badge/go4.org/netipx.svg)](https://pkg.go.dev/go4.org/netipx) - -## What - -This is a package containing the bits of the old `inet.af/netaddr` package that didn't make it -into Go 1.18's `net/netip` standard library package. - -As background, see: - -* https://github.com/inetaf/netaddr/ (now deprecated) -* https://tailscale.com/blog/netaddr-new-ip-type-for-go/ - blog post about why the package came to be originally -* https://go.dev/doc/go1.18#netip - Go 1.18 release notes - -This package requires Go 1.18+ to use and complements the `net/netip`. - -## FAQ - -**Why's it no longer under `inet.af`?** Since that joke started, that -TLD is now under control of the Taliban. (Yes, we should've known -better. We'd even previously scolded people for relying on -questionable ccTLDs. Whoops.) - -**Will this stuff make it into the standard library?** [Maybe](https://github.com/golang/go/issues/53236). -We'll see. - - diff --git a/terraform/providers/google/vendor/go4.org/netipx/ipset.go b/terraform/providers/google/vendor/go4.org/netipx/ipset.go deleted file mode 100644 index 1d4d450261e..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/ipset.go +++ /dev/null @@ -1,498 +0,0 @@ -// Copyright 2020 The Inet.Af AUTHORS. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package netipx - -import ( - "fmt" - "net/netip" - "runtime" - "sort" - "strings" -) - -// IPSetBuilder builds an immutable IPSet. -// -// The zero value is a valid value representing a set of no IPs. -// -// The Add and Remove methods add or remove IPs to/from the set. -// Removals only affect the current membership of the set, so in -// general Adds should be called first. Input ranges may overlap in -// any way. -// -// Most IPSetBuilder methods do not return errors. -// Instead, errors are accumulated and reported by IPSetBuilder.IPSet. -type IPSetBuilder struct { - // in are the ranges in the set. - in []IPRange - - // out are the ranges to be removed from 'in'. - out []IPRange - - // errs are errors accumulated during construction. - errs multiErr -} - -// normalize normalizes s: s.in becomes the minimal sorted list of -// ranges required to describe s, and s.out becomes empty. -func (s *IPSetBuilder) normalize() { - const debug = false - if debug { - debugf("ranges start in=%v out=%v", s.in, s.out) - } - in, ok := mergeIPRanges(s.in) - if !ok { - return - } - out, ok := mergeIPRanges(s.out) - if !ok { - return - } - if debug { - debugf("ranges sort in=%v out=%v", in, out) - } - - // in and out are sorted in ascending range order, and have no - // overlaps within each other. We can run a merge of the two lists - // in one pass. - - min := make([]IPRange, 0, len(in)) - for len(in) > 0 && len(out) > 0 { - rin, rout := in[0], out[0] - if debug { - debugf("step in=%v out=%v", rin, rout) - } - - switch { - case !rout.IsValid() || !rin.IsValid(): - // mergeIPRanges should have prevented invalid ranges from - // sneaking in. - panic("invalid IPRanges during Ranges merge") - case rout.entirelyBefore(rin): - // "out" is entirely before "in". - // - // out in - // f-------t f-------t - out = out[1:] - if debug { - debugf("out before in; drop out") - } - case rin.entirelyBefore(rout): - // "in" is entirely before "out". - // - // in out - // f------t f-------t - min = append(min, rin) - in = in[1:] - if debug { - debugf("in before out; append in") - debugf("min=%v", min) - } - case rin.coveredBy(rout): - // "out" entirely covers "in". - // - // out - // f-------------t - // f------t - // in - in = in[1:] - if debug { - debugf("in inside out; drop in") - } - case rout.inMiddleOf(rin): - // "in" entirely covers "out". - // - // in - // f-------------t - // f------t - // out - min = append(min, IPRange{from: rin.from, to: AddrPrior(rout.from)}) - // Adjust in[0], not ir, because we want to consider the - // mutated range on the next iteration. - in[0].from = rout.to.Next() - out = out[1:] - if debug { - debugf("out inside in; split in, append first in, drop out, adjust second in") - debugf("min=%v", min) - } - case rout.overlapsStartOf(rin): - // "out" overlaps start of "in". - // - // out - // f------t - // f------t - // in - in[0].from = rout.to.Next() - // Can't move ir onto min yet, another later out might - // trim it further. Just discard or and continue. - out = out[1:] - if debug { - debugf("out cuts start of in; adjust in, drop out") - } - case rout.overlapsEndOf(rin): - // "out" overlaps end of "in". - // - // out - // f------t - // f------t - // in - min = append(min, IPRange{from: rin.from, to: AddrPrior(rout.from)}) - in = in[1:] - if debug { - debugf("merge out cuts end of in; append shortened in") - debugf("min=%v", min) - } - default: - // The above should account for all combinations of in and - // out overlapping, but insert a panic to be sure. - panic("unexpected additional overlap scenario") - } - } - if len(in) > 0 { - // Ran out of removals before the end of in. - min = append(min, in...) - if debug { - debugf("min=%v", min) - } - } - - s.in = min - s.out = nil -} - -// Clone returns a copy of s that shares no memory with s. -func (s *IPSetBuilder) Clone() *IPSetBuilder { - return &IPSetBuilder{ - in: append([]IPRange(nil), s.in...), - out: append([]IPRange(nil), s.out...), - } -} - -func (s *IPSetBuilder) addError(msg string, args ...interface{}) { - se := new(stacktraceErr) - // Skip three frames: runtime.Callers, addError, and the IPSetBuilder - // method that called addError (such as IPSetBuilder.Add). - // The resulting stack trace ends at the line in the user's - // code where they called into netaddr. - n := runtime.Callers(3, se.pcs[:]) - se.at = se.pcs[:n] - se.err = fmt.Errorf(msg, args...) - s.errs = append(s.errs, se) -} - -// Add adds ip to s. -func (s *IPSetBuilder) Add(ip netip.Addr) { - if !ip.IsValid() { - s.addError("Add(IP{})") - return - } - s.AddRange(IPRangeFrom(ip, ip)) -} - -// AddPrefix adds all IPs in p to s. -func (s *IPSetBuilder) AddPrefix(p netip.Prefix) { - if r := RangeOfPrefix(p); r.IsValid() { - s.AddRange(r) - } else { - s.addError("AddPrefix(%v/%v)", p.Addr(), p.Bits()) - } -} - -// AddRange adds r to s. -// If r is not Valid, AddRange does nothing. -func (s *IPSetBuilder) AddRange(r IPRange) { - if !r.IsValid() { - s.addError("AddRange(%v-%v)", r.From(), r.To()) - return - } - // If there are any removals (s.out), then we need to compact the set - // first to get the order right. - if len(s.out) > 0 { - s.normalize() - } - s.in = append(s.in, r) -} - -// AddSet adds all IPs in b to s. -func (s *IPSetBuilder) AddSet(b *IPSet) { - if b == nil { - return - } - for _, r := range b.rr { - s.AddRange(r) - } -} - -// Remove removes ip from s. -func (s *IPSetBuilder) Remove(ip netip.Addr) { - if !ip.IsValid() { - s.addError("Remove(IP{})") - } else { - s.RemoveRange(IPRangeFrom(ip, ip)) - } -} - -// RemovePrefix removes all IPs in p from s. -func (s *IPSetBuilder) RemovePrefix(p netip.Prefix) { - if r := RangeOfPrefix(p); r.IsValid() { - s.RemoveRange(r) - } else { - s.addError("RemovePrefix(%v/%v)", p.Addr(), p.Bits()) - } -} - -// RemoveRange removes all IPs in r from s. -func (s *IPSetBuilder) RemoveRange(r IPRange) { - if r.IsValid() { - s.out = append(s.out, r) - } else { - s.addError("RemoveRange(%v-%v)", r.From(), r.To()) - } -} - -// RemoveSet removes all IPs in o from s. -func (s *IPSetBuilder) RemoveSet(b *IPSet) { - if b == nil { - return - } - for _, r := range b.rr { - s.RemoveRange(r) - } -} - -// removeBuilder removes all IPs in b from s. -func (s *IPSetBuilder) removeBuilder(b *IPSetBuilder) { - b.normalize() - for _, r := range b.in { - s.RemoveRange(r) - } -} - -// Complement updates s to contain the complement of its current -// contents. -func (s *IPSetBuilder) Complement() { - s.normalize() - s.out = s.in - s.in = []IPRange{ - RangeOfPrefix(netip.PrefixFrom(netip.AddrFrom4([4]byte{}), 0)), - RangeOfPrefix(netip.PrefixFrom(netip.IPv6Unspecified(), 0)), - } -} - -// Intersect updates s to the set intersection of s and b. -func (s *IPSetBuilder) Intersect(b *IPSet) { - var o IPSetBuilder - o.Complement() - o.RemoveSet(b) - s.removeBuilder(&o) -} - -func discardf(format string, args ...interface{}) {} - -// debugf is reassigned by tests. -var debugf = discardf - -// IPSet returns an immutable IPSet representing the current state of s. -// -// Most IPSetBuilder methods do not return errors. -// Rather, the builder ignores any invalid inputs (such as an invalid IPPrefix), -// and accumulates a list of any such errors that it encountered. -// -// IPSet also reports any such accumulated errors. -// Even if the returned error is non-nil, the returned IPSet is usable -// and contains all modifications made with valid inputs. -// -// The builder remains usable after calling IPSet. -// Calling IPSet clears any accumulated errors. -func (s *IPSetBuilder) IPSet() (*IPSet, error) { - s.normalize() - ret := &IPSet{ - rr: append([]IPRange{}, s.in...), - } - if len(s.errs) == 0 { - return ret, nil - } else { - errs := s.errs - s.errs = nil - return ret, errs - } -} - -// IPSet represents a set of IP addresses. -// -// IPSet is safe for concurrent use. -// The zero value is a valid value representing a set of no IPs. -// Use IPSetBuilder to construct IPSets. -type IPSet struct { - // rr is the set of IPs that belong to this IPSet. The IPRanges - // are normalized according to IPSetBuilder.normalize, meaning - // they are a sorted, minimal representation (no overlapping - // ranges, no contiguous ranges). The implementation of various - // methods rely on this property. - rr []IPRange -} - -// Ranges returns the minimum and sorted set of IP -// ranges that covers s. -func (s *IPSet) Ranges() []IPRange { - return append([]IPRange{}, s.rr...) -} - -// Prefixes returns the minimum and sorted set of IP prefixes -// that covers s. -func (s *IPSet) Prefixes() []netip.Prefix { - out := make([]netip.Prefix, 0, len(s.rr)) - for _, r := range s.rr { - out = append(out, r.Prefixes()...) - } - return out -} - -// Equal reports whether s and o represent the same set of IP -// addresses. -func (s *IPSet) Equal(o *IPSet) bool { - if len(s.rr) != len(o.rr) { - return false - } - for i := range s.rr { - if s.rr[i] != o.rr[i] { - return false - } - } - return true -} - -// Contains reports whether ip is in s. -// If ip has an IPv6 zone, Contains returns false, -// because IPSets do not track zones. -func (s *IPSet) Contains(ip netip.Addr) bool { - if ip.Zone() != "" { - return false - } - // TODO: data structure permitting more efficient lookups: - // https://github.com/inetaf/netaddr/issues/139 - i := sort.Search(len(s.rr), func(i int) bool { - return ip.Less(s.rr[i].from) - }) - if i == 0 { - return false - } - i-- - return s.rr[i].contains(ip) -} - -// ContainsRange reports whether all IPs in r are in s. -func (s *IPSet) ContainsRange(r IPRange) bool { - for _, x := range s.rr { - if r.coveredBy(x) { - return true - } - } - return false -} - -// ContainsPrefix reports whether all IPs in p are in s. -func (s *IPSet) ContainsPrefix(p netip.Prefix) bool { - return s.ContainsRange(RangeOfPrefix(p)) -} - -// Overlaps reports whether any IP in b is also in s. -func (s *IPSet) Overlaps(b *IPSet) bool { - // TODO: sorted ranges lets us do this in O(n+m) - for _, r := range s.rr { - for _, or := range b.rr { - if r.Overlaps(or) { - return true - } - } - } - return false -} - -// OverlapsRange reports whether any IP in r is also in s. -func (s *IPSet) OverlapsRange(r IPRange) bool { - // TODO: sorted ranges lets us do this more efficiently. - for _, x := range s.rr { - if x.Overlaps(r) { - return true - } - } - return false -} - -// OverlapsPrefix reports whether any IP in p is also in s. -func (s *IPSet) OverlapsPrefix(p netip.Prefix) bool { - return s.OverlapsRange(RangeOfPrefix(p)) -} - -// RemoveFreePrefix splits s into a Prefix of length bitLen and a new -// IPSet with that prefix removed. -// -// If no contiguous prefix of length bitLen exists in s, -// RemoveFreePrefix returns ok=false. -func (s *IPSet) RemoveFreePrefix(bitLen uint8) (p netip.Prefix, newSet *IPSet, ok bool) { - var bestFit netip.Prefix - for _, r := range s.rr { - for _, prefix := range r.Prefixes() { - if uint8(prefix.Bits()) > bitLen { - continue - } - if !bestFit.Addr().IsValid() || prefix.Bits() > bestFit.Bits() { - bestFit = prefix - if uint8(bestFit.Bits()) == bitLen { - // exact match, done. - break - } - } - } - } - - if !bestFit.Addr().IsValid() { - return netip.Prefix{}, s, false - } - - prefix := netip.PrefixFrom(bestFit.Addr(), int(bitLen)) - - var b IPSetBuilder - b.AddSet(s) - b.RemovePrefix(prefix) - newSet, _ = b.IPSet() - return prefix, newSet, true -} - -type multiErr []error - -func (e multiErr) Error() string { - var ret []string - for _, err := range e { - ret = append(ret, err.Error()) - } - return strings.Join(ret, "; ") -} - -// A stacktraceErr combines an error with a stack trace. -type stacktraceErr struct { - pcs [16]uintptr // preallocated array of PCs - at []uintptr // stack trace whence the error - err error // underlying error -} - -func (e *stacktraceErr) Error() string { - frames := runtime.CallersFrames(e.at) - buf := new(strings.Builder) - buf.WriteString(e.err.Error()) - buf.WriteString(" @ ") - for { - frame, more := frames.Next() - if !more { - break - } - fmt.Fprintf(buf, "%s:%d ", frame.File, frame.Line) - } - return strings.TrimSpace(buf.String()) -} - -func (e *stacktraceErr) Unwrap() error { - return e.err -} diff --git a/terraform/providers/google/vendor/go4.org/netipx/mask6.go b/terraform/providers/google/vendor/go4.org/netipx/mask6.go deleted file mode 100644 index fbcb8b8eb5d..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/mask6.go +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2021 The Inet.Af AUTHORS. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package netipx - -// mask6 are bitmasks with the topmost n bits of a -// 128-bit number, where n is the array index. -// -// generated with https://play.golang.org/p/64XKxaUSa_9 -var mask6 = [...]uint128{ - 0: {0x0000000000000000, 0x0000000000000000}, - 1: {0x8000000000000000, 0x0000000000000000}, - 2: {0xc000000000000000, 0x0000000000000000}, - 3: {0xe000000000000000, 0x0000000000000000}, - 4: {0xf000000000000000, 0x0000000000000000}, - 5: {0xf800000000000000, 0x0000000000000000}, - 6: {0xfc00000000000000, 0x0000000000000000}, - 7: {0xfe00000000000000, 0x0000000000000000}, - 8: {0xff00000000000000, 0x0000000000000000}, - 9: {0xff80000000000000, 0x0000000000000000}, - 10: {0xffc0000000000000, 0x0000000000000000}, - 11: {0xffe0000000000000, 0x0000000000000000}, - 12: {0xfff0000000000000, 0x0000000000000000}, - 13: {0xfff8000000000000, 0x0000000000000000}, - 14: {0xfffc000000000000, 0x0000000000000000}, - 15: {0xfffe000000000000, 0x0000000000000000}, - 16: {0xffff000000000000, 0x0000000000000000}, - 17: {0xffff800000000000, 0x0000000000000000}, - 18: {0xffffc00000000000, 0x0000000000000000}, - 19: {0xffffe00000000000, 0x0000000000000000}, - 20: {0xfffff00000000000, 0x0000000000000000}, - 21: {0xfffff80000000000, 0x0000000000000000}, - 22: {0xfffffc0000000000, 0x0000000000000000}, - 23: {0xfffffe0000000000, 0x0000000000000000}, - 24: {0xffffff0000000000, 0x0000000000000000}, - 25: {0xffffff8000000000, 0x0000000000000000}, - 26: {0xffffffc000000000, 0x0000000000000000}, - 27: {0xffffffe000000000, 0x0000000000000000}, - 28: {0xfffffff000000000, 0x0000000000000000}, - 29: {0xfffffff800000000, 0x0000000000000000}, - 30: {0xfffffffc00000000, 0x0000000000000000}, - 31: {0xfffffffe00000000, 0x0000000000000000}, - 32: {0xffffffff00000000, 0x0000000000000000}, - 33: {0xffffffff80000000, 0x0000000000000000}, - 34: {0xffffffffc0000000, 0x0000000000000000}, - 35: {0xffffffffe0000000, 0x0000000000000000}, - 36: {0xfffffffff0000000, 0x0000000000000000}, - 37: {0xfffffffff8000000, 0x0000000000000000}, - 38: {0xfffffffffc000000, 0x0000000000000000}, - 39: {0xfffffffffe000000, 0x0000000000000000}, - 40: {0xffffffffff000000, 0x0000000000000000}, - 41: {0xffffffffff800000, 0x0000000000000000}, - 42: {0xffffffffffc00000, 0x0000000000000000}, - 43: {0xffffffffffe00000, 0x0000000000000000}, - 44: {0xfffffffffff00000, 0x0000000000000000}, - 45: {0xfffffffffff80000, 0x0000000000000000}, - 46: {0xfffffffffffc0000, 0x0000000000000000}, - 47: {0xfffffffffffe0000, 0x0000000000000000}, - 48: {0xffffffffffff0000, 0x0000000000000000}, - 49: {0xffffffffffff8000, 0x0000000000000000}, - 50: {0xffffffffffffc000, 0x0000000000000000}, - 51: {0xffffffffffffe000, 0x0000000000000000}, - 52: {0xfffffffffffff000, 0x0000000000000000}, - 53: {0xfffffffffffff800, 0x0000000000000000}, - 54: {0xfffffffffffffc00, 0x0000000000000000}, - 55: {0xfffffffffffffe00, 0x0000000000000000}, - 56: {0xffffffffffffff00, 0x0000000000000000}, - 57: {0xffffffffffffff80, 0x0000000000000000}, - 58: {0xffffffffffffffc0, 0x0000000000000000}, - 59: {0xffffffffffffffe0, 0x0000000000000000}, - 60: {0xfffffffffffffff0, 0x0000000000000000}, - 61: {0xfffffffffffffff8, 0x0000000000000000}, - 62: {0xfffffffffffffffc, 0x0000000000000000}, - 63: {0xfffffffffffffffe, 0x0000000000000000}, - 64: {0xffffffffffffffff, 0x0000000000000000}, - 65: {0xffffffffffffffff, 0x8000000000000000}, - 66: {0xffffffffffffffff, 0xc000000000000000}, - 67: {0xffffffffffffffff, 0xe000000000000000}, - 68: {0xffffffffffffffff, 0xf000000000000000}, - 69: {0xffffffffffffffff, 0xf800000000000000}, - 70: {0xffffffffffffffff, 0xfc00000000000000}, - 71: {0xffffffffffffffff, 0xfe00000000000000}, - 72: {0xffffffffffffffff, 0xff00000000000000}, - 73: {0xffffffffffffffff, 0xff80000000000000}, - 74: {0xffffffffffffffff, 0xffc0000000000000}, - 75: {0xffffffffffffffff, 0xffe0000000000000}, - 76: {0xffffffffffffffff, 0xfff0000000000000}, - 77: {0xffffffffffffffff, 0xfff8000000000000}, - 78: {0xffffffffffffffff, 0xfffc000000000000}, - 79: {0xffffffffffffffff, 0xfffe000000000000}, - 80: {0xffffffffffffffff, 0xffff000000000000}, - 81: {0xffffffffffffffff, 0xffff800000000000}, - 82: {0xffffffffffffffff, 0xffffc00000000000}, - 83: {0xffffffffffffffff, 0xffffe00000000000}, - 84: {0xffffffffffffffff, 0xfffff00000000000}, - 85: {0xffffffffffffffff, 0xfffff80000000000}, - 86: {0xffffffffffffffff, 0xfffffc0000000000}, - 87: {0xffffffffffffffff, 0xfffffe0000000000}, - 88: {0xffffffffffffffff, 0xffffff0000000000}, - 89: {0xffffffffffffffff, 0xffffff8000000000}, - 90: {0xffffffffffffffff, 0xffffffc000000000}, - 91: {0xffffffffffffffff, 0xffffffe000000000}, - 92: {0xffffffffffffffff, 0xfffffff000000000}, - 93: {0xffffffffffffffff, 0xfffffff800000000}, - 94: {0xffffffffffffffff, 0xfffffffc00000000}, - 95: {0xffffffffffffffff, 0xfffffffe00000000}, - 96: {0xffffffffffffffff, 0xffffffff00000000}, - 97: {0xffffffffffffffff, 0xffffffff80000000}, - 98: {0xffffffffffffffff, 0xffffffffc0000000}, - 99: {0xffffffffffffffff, 0xffffffffe0000000}, - 100: {0xffffffffffffffff, 0xfffffffff0000000}, - 101: {0xffffffffffffffff, 0xfffffffff8000000}, - 102: {0xffffffffffffffff, 0xfffffffffc000000}, - 103: {0xffffffffffffffff, 0xfffffffffe000000}, - 104: {0xffffffffffffffff, 0xffffffffff000000}, - 105: {0xffffffffffffffff, 0xffffffffff800000}, - 106: {0xffffffffffffffff, 0xffffffffffc00000}, - 107: {0xffffffffffffffff, 0xffffffffffe00000}, - 108: {0xffffffffffffffff, 0xfffffffffff00000}, - 109: {0xffffffffffffffff, 0xfffffffffff80000}, - 110: {0xffffffffffffffff, 0xfffffffffffc0000}, - 111: {0xffffffffffffffff, 0xfffffffffffe0000}, - 112: {0xffffffffffffffff, 0xffffffffffff0000}, - 113: {0xffffffffffffffff, 0xffffffffffff8000}, - 114: {0xffffffffffffffff, 0xffffffffffffc000}, - 115: {0xffffffffffffffff, 0xffffffffffffe000}, - 116: {0xffffffffffffffff, 0xfffffffffffff000}, - 117: {0xffffffffffffffff, 0xfffffffffffff800}, - 118: {0xffffffffffffffff, 0xfffffffffffffc00}, - 119: {0xffffffffffffffff, 0xfffffffffffffe00}, - 120: {0xffffffffffffffff, 0xffffffffffffff00}, - 121: {0xffffffffffffffff, 0xffffffffffffff80}, - 122: {0xffffffffffffffff, 0xffffffffffffffc0}, - 123: {0xffffffffffffffff, 0xffffffffffffffe0}, - 124: {0xffffffffffffffff, 0xfffffffffffffff0}, - 125: {0xffffffffffffffff, 0xfffffffffffffff8}, - 126: {0xffffffffffffffff, 0xfffffffffffffffc}, - 127: {0xffffffffffffffff, 0xfffffffffffffffe}, - 128: {0xffffffffffffffff, 0xffffffffffffffff}, -} diff --git a/terraform/providers/google/vendor/go4.org/netipx/netipx.go b/terraform/providers/google/vendor/go4.org/netipx/netipx.go deleted file mode 100644 index d241fb38884..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/netipx.go +++ /dev/null @@ -1,584 +0,0 @@ -// Copyright 2020 The Inet.Af AUTHORS. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package netipx contains code and types that were left behind when -// the old inet.af/netaddr package moved to the standard library in Go -// 1.18 as net/netip. -package netipx // import "go4.org/netipx" - -import ( - "errors" - "fmt" - "math" - "net" - "net/netip" - "sort" - "strings" -) - -// FromStdIP returns an IP from the standard library's IP type. -// -// If std is invalid, ok is false. -// -// FromStdIP implicitly unmaps IPv6-mapped IPv4 addresses. That is, if -// len(std) == 16 and contains an IPv4 address, only the IPv4 part is -// returned, without the IPv6 wrapper. This is the common form returned by -// the standard library's ParseIP: https://play.golang.org/p/qdjylUkKWxl. -// To convert a standard library IP without the implicit unmapping, use -// netip.AddrFromSlice. -func FromStdIP(std net.IP) (ip netip.Addr, ok bool) { - ret, ok := netip.AddrFromSlice(std) - return ret.Unmap(), ok -} - -// MustFromStdIP is like FromStdIP, but it panics if std is invalid. -func MustFromStdIP(std net.IP) netip.Addr { - ret, ok := netip.AddrFromSlice(std) - if !ok { - panic("not a valid IP address") - } - return ret.Unmap() -} - -// FromStdIPRaw returns an IP from the standard library's IP type. -// If std is invalid, ok is false. -// Unlike FromStdIP, FromStdIPRaw does not do an implicit Unmap if -// len(std) == 16 and contains an IPv6-mapped IPv4 address. -// -// Deprecated: use netip.AddrFromSlice instead. -func FromStdIPRaw(std net.IP) (ip netip.Addr, ok bool) { - return netip.AddrFromSlice(std) -} - -// ParsePrefixOrAddr parses s as an IP address prefix or IP address. If s parses -// as an IP address prefix, its [net/netip.Prefix.Addr] is returned. The string -// s can be an IPv4 address ("192.0.2.1"), IPv6 address ("2001:db8::68"), IPv4 -// prefix ("192.0.2.1/32"), or IPv6 prefix ("2001:db:68/96"). -func ParsePrefixOrAddr(s string) (netip.Addr, error) { - // Factored out of netip.ParsePrefix to avoid allocating an empty netip.Prefix in case it's - // an address and not a prefix. - i := strings.LastIndexByte(s, '/') - if i < 0 { - return netip.ParseAddr(s) - } - prefix, err := netip.ParsePrefix(s) - return prefix.Addr(), err -} - -// AddrNext returns the IP following ip. -// If there is none, it returns the IP zero value. -// -// Deprecated: use netip.Addr.Next instead. -func AddrNext(ip netip.Addr) netip.Addr { - addr := u128From16(ip.As16()).addOne() - if ip.Is4() { - if uint32(addr.lo) == 0 { - // Overflowed. - return netip.Addr{} - } - return addr.IP4() - } else { - if addr.isZero() { - // Overflowed - return netip.Addr{} - } - return addr.IP6().WithZone(ip.Zone()) - } -} - -// AddrPrior returns the IP before ip. -// If there is none, it returns the IP zero value. -// -// Deprecated: use netip.Addr.Prev instead. -func AddrPrior(ip netip.Addr) netip.Addr { - addr := u128From16(ip.As16()) - if ip.Is4() { - if uint32(addr.lo) == 0 { - return netip.Addr{} - } - return addr.subOne().IP4() - } else { - if addr.isZero() { - return netip.Addr{} - } - return addr.subOne().IP6().WithZone(ip.Zone()) - } -} - -// FromStdAddr maps the components of a standard library TCPAddr or -// UDPAddr into an IPPort. -func FromStdAddr(stdIP net.IP, port int, zone string) (_ netip.AddrPort, ok bool) { - ip, ok := FromStdIP(stdIP) - if !ok || port < 0 || port > math.MaxUint16 { - return netip.AddrPort{}, false - } - ip = ip.Unmap() - if zone != "" { - if ip.Is4() { - ok = false - return - } - ip = ip.WithZone(zone) - } - return netip.AddrPortFrom(ip, uint16(port)), true -} - -// FromStdIPNet returns an netip.Prefix from the standard library's IPNet type. -// If std is invalid, ok is false. -func FromStdIPNet(std *net.IPNet) (prefix netip.Prefix, ok bool) { - ip, ok := FromStdIP(std.IP) - if !ok { - return netip.Prefix{}, false - } - - if l := len(std.Mask); l != net.IPv4len && l != net.IPv6len { - // Invalid mask. - return netip.Prefix{}, false - } - - ones, bits := std.Mask.Size() - if ones == 0 && bits == 0 { - // IPPrefix does not support non-contiguous masks. - return netip.Prefix{}, false - } - - return netip.PrefixFrom(ip, ones), true -} - -// RangeOfPrefix returns the inclusive range of IPs that p covers. -// -// If p is zero or otherwise invalid, Range returns the zero value. -func RangeOfPrefix(p netip.Prefix) IPRange { - p = p.Masked() - if !p.IsValid() { - return IPRange{} - } - return IPRangeFrom(p.Addr(), PrefixLastIP(p)) -} - -// PrefixIPNet returns the net.IPNet representation of an netip.Prefix. -// The returned value is always non-nil. -// Any zone identifier is dropped in the conversion. -func PrefixIPNet(p netip.Prefix) *net.IPNet { - if !p.IsValid() { - return &net.IPNet{} - } - return &net.IPNet{ - IP: p.Addr().AsSlice(), - Mask: net.CIDRMask(p.Bits(), p.Addr().BitLen()), - } -} - -// AddrIPNet returns the net.IPNet representation of an netip.Addr -// with a mask corresponding to the addresses's bit length. -// The returned value is always non-nil. -// Any zone identifier is dropped in the conversion. -func AddrIPNet(addr netip.Addr) *net.IPNet { - if !addr.IsValid() { - return &net.IPNet{} - } - return &net.IPNet{ - IP: addr.AsSlice(), - Mask: net.CIDRMask(addr.BitLen(), addr.BitLen()), - } -} - -// PrefixLastIP returns the last IP in the prefix. -func PrefixLastIP(p netip.Prefix) netip.Addr { - if !p.IsValid() { - return netip.Addr{} - } - a16 := p.Addr().As16() - var off uint8 - var bits uint8 = 128 - if p.Addr().Is4() { - off = 12 - bits = 32 - } - for b := uint8(p.Bits()); b < bits; b++ { - byteNum, bitInByte := b/8, 7-(b%8) - a16[off+byteNum] |= 1 << uint(bitInByte) - } - if p.Addr().Is4() { - return netip.AddrFrom16(a16).Unmap() - } else { - return netip.AddrFrom16(a16) // doesn't unmap - } -} - -// IPRange represents an inclusive range of IP addresses -// from the same address family. -// -// The From and To IPs are inclusive bounds, with both included in the -// range. -// -// To be valid, the From and To values must be non-zero, have matching -// address families (IPv4 vs IPv6), and From must be less than or equal to To. -// IPv6 zones are stripped out and ignored. -// An invalid range may be ignored. -type IPRange struct { - // from is the initial IP address in the range. - from netip.Addr - - // to is the final IP address in the range. - to netip.Addr -} - -// IPRangeFrom returns an IPRange from from to to. -// It does not allocate. -func IPRangeFrom(from, to netip.Addr) IPRange { - return IPRange{ - from: from.WithZone(""), - to: to.WithZone(""), - } -} - -// From returns the lower bound of r. -func (r IPRange) From() netip.Addr { return r.from } - -// To returns the upper bound of r. -func (r IPRange) To() netip.Addr { return r.to } - -// ParseIPRange parses a range out of two IPs separated by a hyphen. -// -// It returns an error if the range is not valid. -func ParseIPRange(s string) (IPRange, error) { - var r IPRange - h := strings.IndexByte(s, '-') - if h == -1 { - return r, fmt.Errorf("no hyphen in range %q", s) - } - from, to := s[:h], s[h+1:] - var err error - r.from, err = netip.ParseAddr(from) - if err != nil { - return r, fmt.Errorf("invalid From IP %q in range %q", from, s) - } - r.from = r.from.WithZone("") - r.to, err = netip.ParseAddr(to) - if err != nil { - return r, fmt.Errorf("invalid To IP %q in range %q", to, s) - } - r.to = r.to.WithZone("") - if !r.IsValid() { - return r, fmt.Errorf("range %v to %v not valid", r.from, r.to) - } - return r, nil -} - -// MustParseIPRange calls ParseIPRange(s) and panics on error. -// It is intended for use in tests with hard-coded strings. -func MustParseIPRange(s string) IPRange { - r, err := ParseIPRange(s) - if err != nil { - panic(err) - } - return r -} - -// String returns a string representation of the range. -// -// For a valid range, the form is "From-To" with a single hyphen -// separating the IPs, the same format recognized by -// ParseIPRange. -func (r IPRange) String() string { - if r.IsValid() { - return fmt.Sprintf("%s-%s", r.from, r.to) - } - if !r.from.IsValid() || !r.to.IsValid() { - return "zero IPRange" - } - return "invalid IPRange" -} - -// AppendTo appends a text encoding of r, -// as generated by MarshalText, -// to b and returns the extended buffer. -func (r IPRange) AppendTo(b []byte) []byte { - if r.IsZero() { - return b - } - b = r.from.AppendTo(b) - b = append(b, '-') - b = r.to.AppendTo(b) - return b -} - -// MarshalText implements the encoding.TextMarshaler interface, -// The encoding is the same as returned by String, with one exception: -// If ip is the zero value, the encoding is the empty string. -func (r IPRange) MarshalText() ([]byte, error) { - if r.IsZero() { - return []byte(""), nil - } - var max int - if r.from.Is4() { - max = len("255.255.255.255-255.255.255.255") - } else { - max = len("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff-ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") - } - b := make([]byte, 0, max) - return r.AppendTo(b), nil -} - -// UnmarshalText implements the encoding.TextUnmarshaler interface. -// The IP range is expected in a form accepted by ParseIPRange. -// It returns an error if *r is not the IPRange zero value. -func (r *IPRange) UnmarshalText(text []byte) error { - if *r != (IPRange{}) { - return errors.New("refusing to Unmarshal into non-zero IPRange") - } - if len(text) == 0 { - return nil - } - var err error - *r, err = ParseIPRange(string(text)) - return err -} - -// IsZero reports whether r is the zero value of the IPRange type. -func (r IPRange) IsZero() bool { - return r == IPRange{} -} - -// IsValid reports whether r.From() and r.To() are both non-zero and -// obey the documented requirements: address families match, and From -// is less than or equal to To. -func (r IPRange) IsValid() bool { - return r.from.IsValid() && - r.from.BitLen() == r.to.BitLen() && - r.from.Zone() == r.to.Zone() && - !r.to.Less(r.from) -} - -// Valid reports whether r.From() and r.To() are both non-zero and -// obey the documented requirements: address families match, and From -// is less than or equal to To. -// -// Deprecated: use the correctly named and identical IsValid method instead. -func (r IPRange) Valid() bool { return r.IsValid() } - -// Contains reports whether the range r includes addr. -// -// An invalid range always reports false. -// -// If ip has an IPv6 zone, Contains returns false, -// because IPPrefixes strip zones. -func (r IPRange) Contains(addr netip.Addr) bool { - return r.IsValid() && addr.Zone() == "" && r.contains(addr) -} - -// contains is like Contains, but without the validity check. -// addr must not have a zone. -func (r IPRange) contains(addr netip.Addr) bool { - return r.from.Compare(addr) <= 0 && r.to.Compare(addr) >= 0 -} - -// less reports whether r is "before" other. It is before if r.From() -// is before other.From(). If they're equal, then the larger range -// (higher To()) comes first. -func (r IPRange) less(other IPRange) bool { - if cmp := r.from.Compare(other.from); cmp != 0 { - return cmp < 0 - } - return other.to.Less(r.to) -} - -// entirelyBefore returns whether r lies entirely before other in IP -// space. -func (r IPRange) entirelyBefore(other IPRange) bool { - return r.to.Less(other.from) -} - -func lessOrEq(ip, ip2 netip.Addr) bool { return ip.Compare(ip2) <= 0 } - -// entirelyWithin returns whether r is entirely contained within -// other. -func (r IPRange) coveredBy(other IPRange) bool { - return lessOrEq(other.from, r.from) && lessOrEq(r.to, other.to) -} - -// inMiddleOf returns whether r is inside other, but not touching the -// edges of other. -func (r IPRange) inMiddleOf(other IPRange) bool { - return other.from.Less(r.from) && r.to.Less(other.to) -} - -// overlapsStartOf returns whether r entirely overlaps the start of -// other, but not all of other. -func (r IPRange) overlapsStartOf(other IPRange) bool { - return lessOrEq(r.from, other.from) && r.to.Less(other.to) -} - -// overlapsEndOf returns whether r entirely overlaps the end of -// other, but not all of other. -func (r IPRange) overlapsEndOf(other IPRange) bool { - return other.from.Less(r.from) && lessOrEq(other.to, r.to) -} - -// mergeIPRanges returns the minimum and sorted set of IP ranges that -// cover r. -func mergeIPRanges(rr []IPRange) (out []IPRange, valid bool) { - // Always return a copy of r, to avoid aliasing slice memory in - // the caller. - switch len(rr) { - case 0: - return nil, true - case 1: - return []IPRange{rr[0]}, true - } - - sort.Slice(rr, func(i, j int) bool { return rr[i].less(rr[j]) }) - out = make([]IPRange, 1, len(rr)) - out[0] = rr[0] - for _, r := range rr[1:] { - prev := &out[len(out)-1] - switch { - case !r.IsValid(): - // Invalid ranges make no sense to merge, refuse to - // perform. - return nil, false - case prev.to.Next() == r.from: - // prev and r touch, merge them. - // - // prev r - // f------tf-----t - prev.to = r.to - case prev.to.Less(r.from): - // No overlap and not adjacent (per previous case), no - // merging possible. - // - // prev r - // f------t f-----t - out = append(out, r) - case prev.to.Less(r.to): - // Partial overlap, update prev - // - // prev - // f------t - // f-----t - // r - prev.to = r.to - default: - // r entirely contained in prev, nothing to do. - // - // prev - // f--------t - // f-----t - // r - } - } - return out, true -} - -// Overlaps reports whether p and o overlap at all. -// -// If p and o are of different address families or either are invalid, -// it reports false. -func (r IPRange) Overlaps(o IPRange) bool { - return r.IsValid() && - o.IsValid() && - r.from.Compare(o.to) <= 0 && - o.from.Compare(r.to) <= 0 -} - -// prefixMaker returns a address-family-corrected IPPrefix from a and bits, -// where the input bits is always in the IPv6-mapped form for IPv4 addresses. -type prefixMaker func(a uint128, bits uint8) netip.Prefix - -// Prefixes returns the set of IPPrefix entries that covers r. -// -// If either of r's bounds are invalid, in the wrong order, or if -// they're of different address families, then Prefixes returns nil. -// -// Prefixes necessarily allocates. See AppendPrefixes for a version that uses -// memory you provide. -func (r IPRange) Prefixes() []netip.Prefix { - return r.AppendPrefixes(nil) -} - -// AppendPrefixes is an append version of IPRange.Prefixes. It appends -// the netip.Prefix entries that cover r to dst. -func (r IPRange) AppendPrefixes(dst []netip.Prefix) []netip.Prefix { - if !r.IsValid() { - return nil - } - return appendRangePrefixes(dst, r.prefixFrom128AndBits, u128From16(r.from.As16()), u128From16(r.to.As16())) -} - -func (r IPRange) prefixFrom128AndBits(a uint128, bits uint8) netip.Prefix { - var ip netip.Addr - if r.from.Is4() { - bits -= 12 * 8 - ip = a.IP4() - } else { - ip = a.IP6() - } - return netip.PrefixFrom(ip, int(bits)) -} - -// aZeroBSet is whether, after the common bits, a is all zero bits and -// b is all set (one) bits. -func comparePrefixes(a, b uint128) (common uint8, aZeroBSet bool) { - common = a.commonPrefixLen(b) - - // See whether a and b, after their common shared bits, end - // in all zero bits or all one bits, respectively. - if common == 128 { - return common, true - } - - m := mask6[common] - return common, (a.xor(a.and(m)).isZero() && - b.or(m) == uint128{^uint64(0), ^uint64(0)}) -} - -// Prefix returns r as an IPPrefix, if it can be presented exactly as such. -// If r is not valid or is not exactly equal to one prefix, ok is false. -func (r IPRange) Prefix() (p netip.Prefix, ok bool) { - if !r.IsValid() { - return - } - from128 := u128From16(r.from.As16()) - to128 := u128From16(r.to.As16()) - if common, ok := comparePrefixes(from128, to128); ok { - return r.prefixFrom128AndBits(from128, common), true - } - return -} - -func appendRangePrefixes(dst []netip.Prefix, makePrefix prefixMaker, a, b uint128) []netip.Prefix { - common, ok := comparePrefixes(a, b) - if ok { - // a to b represents a whole range, like 10.50.0.0/16. - // (a being 10.50.0.0 and b being 10.50.255.255) - return append(dst, makePrefix(a, common)) - } - // Otherwise recursively do both halves. - dst = appendRangePrefixes(dst, makePrefix, a, a.bitsSetFrom(common+1)) - dst = appendRangePrefixes(dst, makePrefix, b.bitsClearedFrom(common+1), b) - return dst -} - -// ComparePrefix is a compare function (returning -1, 0 or 1) -// sorting prefixes first by address family (IPv4 before IPv6), -// then by prefix length (smaller prefixes first), then by -// address. -func ComparePrefix(a, b netip.Prefix) int { - aa, ba := a.Addr(), b.Addr() - if al, bl := aa.BitLen(), ba.BitLen(); al != bl { - if al < bl { - return -1 - } - return 1 - } - ab, bb := a.Bits(), b.Bits() - if ab != bb { - if ab < bb { - return -1 - } - return 1 - } - return aa.Compare(ba) -} diff --git a/terraform/providers/google/vendor/go4.org/netipx/uint128.go b/terraform/providers/google/vendor/go4.org/netipx/uint128.go deleted file mode 100644 index f59ea23ca88..00000000000 --- a/terraform/providers/google/vendor/go4.org/netipx/uint128.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2020 The Inet.Af AUTHORS. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package netipx - -import ( - "encoding/binary" - "math/bits" - "net/netip" -) - -// uint128 represents a uint128 using two uint64s. -// -// When the methods below mention a bit number, bit 0 is the most -// significant bit (in hi) and bit 127 is the lowest (lo&1). -type uint128 struct { - hi uint64 - lo uint64 -} - -func u128From16(a [16]byte) uint128 { - return uint128{ - binary.BigEndian.Uint64(a[:8]), - binary.BigEndian.Uint64(a[8:]), - } -} - -func (u uint128) IP6() netip.Addr { - var a [16]byte - binary.BigEndian.PutUint64(a[:8], u.hi) - binary.BigEndian.PutUint64(a[8:], u.lo) - return netip.AddrFrom16(a) -} - -func (u uint128) IP4() netip.Addr { - var a [8]byte - binary.BigEndian.PutUint64(a[:], u.lo) - return netip.AddrFrom4([4]byte{a[4], a[5], a[6], a[7]}) -} - -// isZero reports whether u == 0. -// -// It's faster than u == (uint128{}) because the compiler (as of Go -// 1.15/1.16b1) doesn't do this trick and instead inserts a branch in -// its eq alg's generated code. -func (u uint128) isZero() bool { return u.hi|u.lo == 0 } - -// and returns the bitwise AND of u and m (u&m). -func (u uint128) and(m uint128) uint128 { - return uint128{u.hi & m.hi, u.lo & m.lo} -} - -// xor returns the bitwise XOR of u and m (u^m). -func (u uint128) xor(m uint128) uint128 { - return uint128{u.hi ^ m.hi, u.lo ^ m.lo} -} - -// or returns the bitwise OR of u and m (u|m). -func (u uint128) or(m uint128) uint128 { - return uint128{u.hi | m.hi, u.lo | m.lo} -} - -// not returns the bitwise NOT of u. -func (u uint128) not() uint128 { - return uint128{^u.hi, ^u.lo} -} - -// subOne returns u - 1. -func (u uint128) subOne() uint128 { - lo, borrow := bits.Sub64(u.lo, 1, 0) - return uint128{u.hi - borrow, lo} -} - -// addOne returns u + 1. -func (u uint128) addOne() uint128 { - lo, carry := bits.Add64(u.lo, 1, 0) - return uint128{u.hi + carry, lo} -} - -func u64CommonPrefixLen(a, b uint64) uint8 { - return uint8(bits.LeadingZeros64(a ^ b)) -} - -func (u uint128) commonPrefixLen(v uint128) (n uint8) { - if n = u64CommonPrefixLen(u.hi, v.hi); n == 64 { - n += u64CommonPrefixLen(u.lo, v.lo) - } - return -} - -// func (u *uint128) halves() [2]*uint64 { -// return [2]*uint64{&u.hi, &u.lo} -// } - -// bitsSetFrom returns a copy of u with the given bit -// and all subsequent ones set. -func (u uint128) bitsSetFrom(bit uint8) uint128 { - return u.or(mask6[bit].not()) -} - -// bitsClearedFrom returns a copy of u with the given bit -// and all subsequent ones cleared. -func (u uint128) bitsClearedFrom(bit uint8) uint128 { - return u.and(mask6[bit]) -} diff --git a/terraform/providers/google/vendor/golang.org/x/exp/LICENSE b/terraform/providers/google/vendor/golang.org/x/exp/LICENSE deleted file mode 100644 index 6a66aea5eaf..00000000000 --- a/terraform/providers/google/vendor/golang.org/x/exp/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/terraform/providers/google/vendor/golang.org/x/exp/PATENTS b/terraform/providers/google/vendor/golang.org/x/exp/PATENTS deleted file mode 100644 index 733099041f8..00000000000 --- a/terraform/providers/google/vendor/golang.org/x/exp/PATENTS +++ /dev/null @@ -1,22 +0,0 @@ -Additional IP Rights Grant (Patents) - -"This implementation" means the copyrightable works distributed by -Google as part of the Go project. - -Google hereby grants to You a perpetual, worldwide, non-exclusive, -no-charge, royalty-free, irrevocable (except as stated in this section) -patent license to make, have made, use, offer to sell, sell, import, -transfer and otherwise run, modify and propagate the contents of this -implementation of Go, where such license applies only to those patent -claims, both currently owned or controlled by Google and acquired in -the future, licensable by Google that are necessarily infringed by this -implementation of Go. This grant does not include claims that would be -infringed only as a consequence of further modification of this -implementation. If you or your agent or exclusive licensee institute or -order or agree to the institution of patent litigation against any -entity (including a cross-claim or counterclaim in a lawsuit) alleging -that this implementation of Go or any code incorporated within this -implementation of Go constitutes direct or contributory patent -infringement, or inducement of patent infringement, then any patent -rights granted to you under this License for this implementation of Go -shall terminate as of the date such litigation is filed. diff --git a/terraform/providers/google/vendor/golang.org/x/exp/maps/maps.go b/terraform/providers/google/vendor/golang.org/x/exp/maps/maps.go deleted file mode 100644 index ecc0dabb74d..00000000000 --- a/terraform/providers/google/vendor/golang.org/x/exp/maps/maps.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2021 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package maps defines various functions useful with maps of any type. -package maps - -// Keys returns the keys of the map m. -// The keys will be in an indeterminate order. -func Keys[M ~map[K]V, K comparable, V any](m M) []K { - r := make([]K, 0, len(m)) - for k := range m { - r = append(r, k) - } - return r -} - -// Values returns the values of the map m. -// The values will be in an indeterminate order. -func Values[M ~map[K]V, K comparable, V any](m M) []V { - r := make([]V, 0, len(m)) - for _, v := range m { - r = append(r, v) - } - return r -} - -// Equal reports whether two maps contain the same key/value pairs. -// Values are compared using ==. -func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool { - if len(m1) != len(m2) { - return false - } - for k, v1 := range m1 { - if v2, ok := m2[k]; !ok || v1 != v2 { - return false - } - } - return true -} - -// EqualFunc is like Equal, but compares values using eq. -// Keys are still compared with ==. -func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) bool { - if len(m1) != len(m2) { - return false - } - for k, v1 := range m1 { - if v2, ok := m2[k]; !ok || !eq(v1, v2) { - return false - } - } - return true -} - -// Clear removes all entries from m, leaving it empty. -func Clear[M ~map[K]V, K comparable, V any](m M) { - for k := range m { - delete(m, k) - } -} - -// Clone returns a copy of m. This is a shallow clone: -// the new keys and values are set using ordinary assignment. -func Clone[M ~map[K]V, K comparable, V any](m M) M { - // Preserve nil in case it matters. - if m == nil { - return nil - } - r := make(M, len(m)) - for k, v := range m { - r[k] = v - } - return r -} - -// Copy copies all key/value pairs in src adding them to dst. -// When a key in src is already present in dst, -// the value in dst will be overwritten by the value associated -// with the key in src. -func Copy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) { - for k, v := range src { - dst[k] = v - } -} - -// DeleteFunc deletes any key/value pairs from m for which del returns true. -func DeleteFunc[M ~map[K]V, K comparable, V any](m M, del func(K, V) bool) { - for k, v := range m { - if del(k, v) { - delete(m, k) - } - } -} diff --git a/terraform/providers/google/vendor/golang.org/x/mod/LICENSE b/terraform/providers/google/vendor/golang.org/x/mod/LICENSE index 6a66aea5eaf..2a7cf70da6e 100644 --- a/terraform/providers/google/vendor/golang.org/x/mod/LICENSE +++ b/terraform/providers/google/vendor/golang.org/x/mod/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/terraform/providers/google/vendor/golang.org/x/mod/modfile/read.go b/terraform/providers/google/vendor/golang.org/x/mod/modfile/read.go index 22056825915..de1b98211a1 100644 --- a/terraform/providers/google/vendor/golang.org/x/mod/modfile/read.go +++ b/terraform/providers/google/vendor/golang.org/x/mod/modfile/read.go @@ -226,8 +226,9 @@ func (x *FileSyntax) Cleanup() { continue } if ww == 1 && len(stmt.RParen.Comments.Before) == 0 { - // Collapse block into single line. - line := &Line{ + // Collapse block into single line but keep the Line reference used by the + // parsed File structure. + *stmt.Line[0] = Line{ Comments: Comments{ Before: commentsAdd(stmt.Before, stmt.Line[0].Before), Suffix: commentsAdd(stmt.Line[0].Suffix, stmt.Suffix), @@ -235,7 +236,7 @@ func (x *FileSyntax) Cleanup() { }, Token: stringsAdd(stmt.Token, stmt.Line[0].Token), } - x.Stmt[w] = line + x.Stmt[w] = stmt.Line[0] w++ continue } diff --git a/terraform/providers/google/vendor/golang.org/x/mod/modfile/rule.go b/terraform/providers/google/vendor/golang.org/x/mod/modfile/rule.go index 0e7b7e26792..3e4a1d0ab4a 100644 --- a/terraform/providers/google/vendor/golang.org/x/mod/modfile/rule.go +++ b/terraform/providers/google/vendor/golang.org/x/mod/modfile/rule.go @@ -38,10 +38,12 @@ type File struct { Module *Module Go *Go Toolchain *Toolchain + Godebug []*Godebug Require []*Require Exclude []*Exclude Replace []*Replace Retract []*Retract + Tool []*Tool Syntax *FileSyntax } @@ -65,6 +67,13 @@ type Toolchain struct { Syntax *Line } +// A Godebug is a single godebug key=value statement. +type Godebug struct { + Key string + Value string + Syntax *Line +} + // An Exclude is a single exclude statement. type Exclude struct { Mod module.Version @@ -85,6 +94,12 @@ type Retract struct { Syntax *Line } +// A Tool is a single tool statement. +type Tool struct { + Path string + Syntax *Line +} + // A VersionInterval represents a range of versions with upper and lower bounds. // Intervals are closed: both bounds are included. When Low is equal to High, // the interval may refer to a single version ('v1.2.3') or an interval @@ -289,7 +304,7 @@ func parseToFile(file string, data []byte, fix VersionFixer, strict bool) (parse }) } continue - case "module", "require", "exclude", "replace", "retract": + case "module", "godebug", "require", "exclude", "replace", "retract", "tool": for _, l := range x.Line { f.add(&errs, x, l, x.Token[0], l.Token, fix, strict) } @@ -308,7 +323,9 @@ var laxGoVersionRE = lazyregexp.New(`^v?(([1-9][0-9]*)\.(0|[1-9][0-9]*))([^0-9]. // Toolchains must be named beginning with `go1`, // like "go1.20.3" or "go1.20.3-gccgo". As a special case, "default" is also permitted. -// TODO(samthanawalla): Replace regex with https://pkg.go.dev/go/version#IsValid in 1.23+ +// Note that this regexp is a much looser condition than go/version.IsValid, +// for forward compatibility. +// (This code has to be work to identify new toolchains even if we tweak the syntax in the future.) var ToolchainRE = lazyregexp.New(`^default$|^go1($|\.)`) func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, args []string, fix VersionFixer, strict bool) { @@ -384,7 +401,7 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a if len(args) != 1 { errorf("toolchain directive expects exactly one argument") return - } else if strict && !ToolchainRE.MatchString(args[0]) { + } else if !ToolchainRE.MatchString(args[0]) { errorf("invalid toolchain version '%s': must match format go1.23.0 or default", args[0]) return } @@ -412,6 +429,22 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a } f.Module.Mod = module.Version{Path: s} + case "godebug": + if len(args) != 1 || strings.ContainsAny(args[0], "\"`',") { + errorf("usage: godebug key=value") + return + } + key, value, ok := strings.Cut(args[0], "=") + if !ok { + errorf("usage: godebug key=value") + return + } + f.Godebug = append(f.Godebug, &Godebug{ + Key: key, + Value: value, + Syntax: line, + }) + case "require", "exclude": if len(args) != 2 { errorf("usage: %s module/path v1.2.3", verb) @@ -483,6 +516,21 @@ func (f *File) add(errs *ErrorList, block *LineBlock, line *Line, verb string, a Syntax: line, } f.Retract = append(f.Retract, retract) + + case "tool": + if len(args) != 1 { + errorf("tool directive expects exactly one argument") + return + } + s, err := parseString(&args[0]) + if err != nil { + errorf("invalid quoted string: %v", err) + return + } + f.Tool = append(f.Tool, &Tool{ + Path: s, + Syntax: line, + }) } } @@ -654,6 +702,22 @@ func (f *WorkFile) add(errs *ErrorList, line *Line, verb string, args []string, f.Toolchain = &Toolchain{Syntax: line} f.Toolchain.Name = args[0] + case "godebug": + if len(args) != 1 || strings.ContainsAny(args[0], "\"`',") { + errorf("usage: godebug key=value") + return + } + key, value, ok := strings.Cut(args[0], "=") + if !ok { + errorf("usage: godebug key=value") + return + } + f.Godebug = append(f.Godebug, &Godebug{ + Key: key, + Value: value, + Syntax: line, + }) + case "use": if len(args) != 1 { errorf("usage: %s local/dir", verb) @@ -929,6 +993,15 @@ func (f *File) Format() ([]byte, error) { // Cleanup cleans out all the cleared entries. func (f *File) Cleanup() { w := 0 + for _, g := range f.Godebug { + if g.Key != "" { + f.Godebug[w] = g + w++ + } + } + f.Godebug = f.Godebug[:w] + + w = 0 for _, r := range f.Require { if r.Mod.Path != "" { f.Require[w] = r @@ -1027,6 +1100,45 @@ func (f *File) AddToolchainStmt(name string) error { return nil } +// AddGodebug sets the first godebug line for key to value, +// preserving any existing comments for that line and removing all +// other godebug lines for key. +// +// If no line currently exists for key, AddGodebug adds a new line +// at the end of the last godebug block. +func (f *File) AddGodebug(key, value string) error { + need := true + for _, g := range f.Godebug { + if g.Key == key { + if need { + g.Value = value + f.Syntax.updateLine(g.Syntax, "godebug", key+"="+value) + need = false + } else { + g.Syntax.markRemoved() + *g = Godebug{} + } + } + } + + if need { + f.addNewGodebug(key, value) + } + return nil +} + +// addNewGodebug adds a new godebug key=value line at the end +// of the last godebug block, regardless of any existing godebug lines for key. +func (f *File) addNewGodebug(key, value string) { + line := f.Syntax.addLine(nil, "godebug", key+"="+value) + g := &Godebug{ + Key: key, + Value: value, + Syntax: line, + } + f.Godebug = append(f.Godebug, g) +} + // AddRequire sets the first require line for path to version vers, // preserving any existing comments for that line and removing all // other lines for path. @@ -1334,6 +1446,16 @@ func (f *File) SetRequireSeparateIndirect(req []*Require) { f.SortBlocks() } +func (f *File) DropGodebug(key string) error { + for _, g := range f.Godebug { + if g.Key == key { + g.Syntax.markRemoved() + *g = Godebug{} + } + } + return nil +} + func (f *File) DropRequire(path string) error { for _, r := range f.Require { if r.Mod.Path == path { @@ -1467,6 +1589,36 @@ func (f *File) DropRetract(vi VersionInterval) error { return nil } +// AddTool adds a new tool directive with the given path. +// It does nothing if the tool line already exists. +func (f *File) AddTool(path string) error { + for _, t := range f.Tool { + if t.Path == path { + return nil + } + } + + f.Tool = append(f.Tool, &Tool{ + Path: path, + Syntax: f.Syntax.addLine(nil, "tool", path), + }) + + f.SortBlocks() + return nil +} + +// RemoveTool removes a tool directive with the given path. +// It does nothing if no such tool directive exists. +func (f *File) DropTool(path string) error { + for _, t := range f.Tool { + if t.Path == path { + t.Syntax.markRemoved() + *t = Tool{} + } + } + return nil +} + func (f *File) SortBlocks() { f.removeDups() // otherwise sorting is unsafe @@ -1493,9 +1645,9 @@ func (f *File) SortBlocks() { } } -// removeDups removes duplicate exclude and replace directives. +// removeDups removes duplicate exclude, replace and tool directives. // -// Earlier exclude directives take priority. +// Earlier exclude and tool directives take priority. // // Later replace directives take priority. // @@ -1505,10 +1657,10 @@ func (f *File) SortBlocks() { // retract directives are not de-duplicated since comments are // meaningful, and versions may be retracted multiple times. func (f *File) removeDups() { - removeDups(f.Syntax, &f.Exclude, &f.Replace) + removeDups(f.Syntax, &f.Exclude, &f.Replace, &f.Tool) } -func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace) { +func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace, tool *[]*Tool) { kill := make(map[*Line]bool) // Remove duplicate excludes. @@ -1549,6 +1701,24 @@ func removeDups(syntax *FileSyntax, exclude *[]*Exclude, replace *[]*Replace) { } *replace = repl + if tool != nil { + haveTool := make(map[string]bool) + for _, t := range *tool { + if haveTool[t.Path] { + kill[t.Syntax] = true + continue + } + haveTool[t.Path] = true + } + var newTool []*Tool + for _, t := range *tool { + if !kill[t.Syntax] { + newTool = append(newTool, t) + } + } + *tool = newTool + } + // Duplicate require and retract directives are not removed. // Drop killed statements from the syntax tree. diff --git a/terraform/providers/google/vendor/golang.org/x/mod/modfile/work.go b/terraform/providers/google/vendor/golang.org/x/mod/modfile/work.go index d7b99376ebe..5387d0c2659 100644 --- a/terraform/providers/google/vendor/golang.org/x/mod/modfile/work.go +++ b/terraform/providers/google/vendor/golang.org/x/mod/modfile/work.go @@ -14,6 +14,7 @@ import ( type WorkFile struct { Go *Go Toolchain *Toolchain + Godebug []*Godebug Use []*Use Replace []*Replace @@ -68,7 +69,7 @@ func ParseWork(file string, data []byte, fix VersionFixer) (*WorkFile, error) { Err: fmt.Errorf("unknown block type: %s", strings.Join(x.Token, " ")), }) continue - case "use", "replace": + case "godebug", "use", "replace": for _, l := range x.Line { f.add(&errs, l, x.Token[0], l.Token, fix) } @@ -184,6 +185,55 @@ func (f *WorkFile) DropToolchainStmt() { } } +// AddGodebug sets the first godebug line for key to value, +// preserving any existing comments for that line and removing all +// other godebug lines for key. +// +// If no line currently exists for key, AddGodebug adds a new line +// at the end of the last godebug block. +func (f *WorkFile) AddGodebug(key, value string) error { + need := true + for _, g := range f.Godebug { + if g.Key == key { + if need { + g.Value = value + f.Syntax.updateLine(g.Syntax, "godebug", key+"="+value) + need = false + } else { + g.Syntax.markRemoved() + *g = Godebug{} + } + } + } + + if need { + f.addNewGodebug(key, value) + } + return nil +} + +// addNewGodebug adds a new godebug key=value line at the end +// of the last godebug block, regardless of any existing godebug lines for key. +func (f *WorkFile) addNewGodebug(key, value string) { + line := f.Syntax.addLine(nil, "godebug", key+"="+value) + g := &Godebug{ + Key: key, + Value: value, + Syntax: line, + } + f.Godebug = append(f.Godebug, g) +} + +func (f *WorkFile) DropGodebug(key string) error { + for _, g := range f.Godebug { + if g.Key == key { + g.Syntax.markRemoved() + *g = Godebug{} + } + } + return nil +} + func (f *WorkFile) AddUse(diskPath, modulePath string) error { need := true for _, d := range f.Use { @@ -281,5 +331,5 @@ func (f *WorkFile) SortBlocks() { // retract directives are not de-duplicated since comments are // meaningful, and versions may be retracted multiple times. func (f *WorkFile) removeDups() { - removeDups(f.Syntax, nil, &f.Replace) + removeDups(f.Syntax, nil, &f.Replace, nil) } diff --git a/terraform/providers/google/vendor/golang.org/x/sys/LICENSE b/terraform/providers/google/vendor/golang.org/x/sys/LICENSE index 6a66aea5eaf..2a7cf70da6e 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/LICENSE +++ b/terraform/providers/google/vendor/golang.org/x/sys/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. +Copyright 2009 The Go Authors. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -10,7 +10,7 @@ notice, this list of conditions and the following disclaimer. copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Google Inc. nor the names of its + * Neither the name of Google LLC nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. diff --git a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu.go b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu.go index 8fa707aa4ba..02609d5b21d 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu.go @@ -105,6 +105,8 @@ var ARM64 struct { HasSVE bool // Scalable Vector Extensions HasSVE2 bool // Scalable Vector Extensions 2 HasASIMDFHM bool // Advanced SIMD multiplication FP16 to FP32 + HasDIT bool // Data Independent Timing support + HasI8MM bool // Advanced SIMD Int8 matrix multiplication instructions _ CacheLinePad } @@ -199,6 +201,25 @@ var S390X struct { _ CacheLinePad } +// RISCV64 contains the supported CPU features and performance characteristics for riscv64 +// platforms. The booleans in RISCV64, with the exception of HasFastMisaligned, indicate +// the presence of RISC-V extensions. +// +// It is safe to assume that all the RV64G extensions are supported and so they are omitted from +// this structure. As riscv64 Go programs require at least RV64G, the code that populates +// this structure cannot run successfully if some of the RV64G extensions are missing. +// The struct is padded to avoid false sharing. +var RISCV64 struct { + _ CacheLinePad + HasFastMisaligned bool // Fast misaligned accesses + HasC bool // Compressed instruction-set extension + HasV bool // Vector extension compatible with RVV 1.0 + HasZba bool // Address generation instructions extension + HasZbb bool // Basic bit-manipulation extension + HasZbs bool // Single-bit instructions extension + _ CacheLinePad +} + func init() { archInit() initOptions() diff --git a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 0e27a21e1f8..af2aa99f9f0 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -38,6 +38,8 @@ func initOptions() { {Name: "dcpop", Feature: &ARM64.HasDCPOP}, {Name: "asimddp", Feature: &ARM64.HasASIMDDP}, {Name: "asimdfhm", Feature: &ARM64.HasASIMDFHM}, + {Name: "dit", Feature: &ARM64.HasDIT}, + {Name: "i8mm", Feature: &ARM64.HasI8MM}, } } @@ -145,6 +147,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { ARM64.HasLRCPC = true } + switch extractBits(isar1, 52, 55) { + case 1: + ARM64.HasI8MM = true + } + // ID_AA64PFR0_EL1 switch extractBits(pfr0, 16, 19) { case 0: @@ -168,6 +175,11 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) { parseARM64SVERegister(getzfr0()) } + + switch extractBits(pfr0, 48, 51) { + case 1: + ARM64.HasDIT = true + } } func parseARM64SVERegister(zfr0 uint64) { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go index 3d386d0fc21..08f35ea1773 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_arm64.go @@ -35,8 +35,10 @@ const ( hwcap_SHA512 = 1 << 21 hwcap_SVE = 1 << 22 hwcap_ASIMDFHM = 1 << 23 + hwcap_DIT = 1 << 24 hwcap2_SVE2 = 1 << 1 + hwcap2_I8MM = 1 << 13 ) // linuxKernelCanEmulateCPUID reports whether we're running @@ -106,9 +108,12 @@ func doinit() { ARM64.HasSHA512 = isSet(hwCap, hwcap_SHA512) ARM64.HasSVE = isSet(hwCap, hwcap_SVE) ARM64.HasASIMDFHM = isSet(hwCap, hwcap_ASIMDFHM) + ARM64.HasDIT = isSet(hwCap, hwcap_DIT) + // HWCAP2 feature bits ARM64.HasSVE2 = isSet(hwCap2, hwcap2_SVE2) + ARM64.HasI8MM = isSet(hwCap2, hwcap2_I8MM) } func isSet(hwc uint, value uint) bool { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go index cd63e733557..7d902b6847b 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x +//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x && !riscv64 package cpu diff --git a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go new file mode 100644 index 00000000000..cb4a0c57280 --- /dev/null +++ b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go @@ -0,0 +1,137 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cpu + +import ( + "syscall" + "unsafe" +) + +// RISC-V extension discovery code for Linux. The approach here is to first try the riscv_hwprobe +// syscall falling back to HWCAP to check for the C extension if riscv_hwprobe is not available. +// +// A note on detection of the Vector extension using HWCAP. +// +// Support for the Vector extension version 1.0 was added to the Linux kernel in release 6.5. +// Support for the riscv_hwprobe syscall was added in 6.4. It follows that if the riscv_hwprobe +// syscall is not available then neither is the Vector extension (which needs kernel support). +// The riscv_hwprobe syscall should then be all we need to detect the Vector extension. +// However, some RISC-V board manufacturers ship boards with an older kernel on top of which +// they have back-ported various versions of the Vector extension patches but not the riscv_hwprobe +// patches. These kernels advertise support for the Vector extension using HWCAP. Falling +// back to HWCAP to detect the Vector extension, if riscv_hwprobe is not available, or simply not +// bothering with riscv_hwprobe at all and just using HWCAP may then seem like an attractive option. +// +// Unfortunately, simply checking the 'V' bit in AT_HWCAP will not work as this bit is used by +// RISC-V board and cloud instance providers to mean different things. The Lichee Pi 4A board +// and the Scaleway RV1 cloud instances use the 'V' bit to advertise their support for the unratified +// 0.7.1 version of the Vector Specification. The Banana Pi BPI-F3 and the CanMV-K230 board use +// it to advertise support for 1.0 of the Vector extension. Versions 0.7.1 and 1.0 of the Vector +// extension are binary incompatible. HWCAP can then not be used in isolation to populate the +// HasV field as this field indicates that the underlying CPU is compatible with RVV 1.0. +// +// There is a way at runtime to distinguish between versions 0.7.1 and 1.0 of the Vector +// specification by issuing a RVV 1.0 vsetvli instruction and checking the vill bit of the vtype +// register. This check would allow us to safely detect version 1.0 of the Vector extension +// with HWCAP, if riscv_hwprobe were not available. However, the check cannot +// be added until the assembler supports the Vector instructions. +// +// Note the riscv_hwprobe syscall does not suffer from these ambiguities by design as all of the +// extensions it advertises support for are explicitly versioned. It's also worth noting that +// the riscv_hwprobe syscall is the only way to detect multi-letter RISC-V extensions, e.g., Zba. +// These cannot be detected using HWCAP and so riscv_hwprobe must be used to detect the majority +// of RISC-V extensions. +// +// Please see https://docs.kernel.org/arch/riscv/hwprobe.html for more information. + +// golang.org/x/sys/cpu is not allowed to depend on golang.org/x/sys/unix so we must +// reproduce the constants, types and functions needed to make the riscv_hwprobe syscall +// here. + +const ( + // Copied from golang.org/x/sys/unix/ztypes_linux_riscv64.go. + riscv_HWPROBE_KEY_IMA_EXT_0 = 0x4 + riscv_HWPROBE_IMA_C = 0x2 + riscv_HWPROBE_IMA_V = 0x4 + riscv_HWPROBE_EXT_ZBA = 0x8 + riscv_HWPROBE_EXT_ZBB = 0x10 + riscv_HWPROBE_EXT_ZBS = 0x20 + riscv_HWPROBE_KEY_CPUPERF_0 = 0x5 + riscv_HWPROBE_MISALIGNED_FAST = 0x3 + riscv_HWPROBE_MISALIGNED_MASK = 0x7 +) + +const ( + // sys_RISCV_HWPROBE is copied from golang.org/x/sys/unix/zsysnum_linux_riscv64.go. + sys_RISCV_HWPROBE = 258 +) + +// riscvHWProbePairs is copied from golang.org/x/sys/unix/ztypes_linux_riscv64.go. +type riscvHWProbePairs struct { + key int64 + value uint64 +} + +const ( + // CPU features + hwcap_RISCV_ISA_C = 1 << ('C' - 'A') +) + +func doinit() { + // A slice of key/value pair structures is passed to the RISCVHWProbe syscall. The key + // field should be initialised with one of the key constants defined above, e.g., + // RISCV_HWPROBE_KEY_IMA_EXT_0. The syscall will set the value field to the appropriate value. + // If the kernel does not recognise a key it will set the key field to -1 and the value field to 0. + + pairs := []riscvHWProbePairs{ + {riscv_HWPROBE_KEY_IMA_EXT_0, 0}, + {riscv_HWPROBE_KEY_CPUPERF_0, 0}, + } + + // This call only indicates that extensions are supported if they are implemented on all cores. + if riscvHWProbe(pairs, 0) { + if pairs[0].key != -1 { + v := uint(pairs[0].value) + RISCV64.HasC = isSet(v, riscv_HWPROBE_IMA_C) + RISCV64.HasV = isSet(v, riscv_HWPROBE_IMA_V) + RISCV64.HasZba = isSet(v, riscv_HWPROBE_EXT_ZBA) + RISCV64.HasZbb = isSet(v, riscv_HWPROBE_EXT_ZBB) + RISCV64.HasZbs = isSet(v, riscv_HWPROBE_EXT_ZBS) + } + if pairs[1].key != -1 { + v := pairs[1].value & riscv_HWPROBE_MISALIGNED_MASK + RISCV64.HasFastMisaligned = v == riscv_HWPROBE_MISALIGNED_FAST + } + } + + // Let's double check with HWCAP if the C extension does not appear to be supported. + // This may happen if we're running on a kernel older than 6.4. + + if !RISCV64.HasC { + RISCV64.HasC = isSet(hwCap, hwcap_RISCV_ISA_C) + } +} + +func isSet(hwc uint, value uint) bool { + return hwc&value != 0 +} + +// riscvHWProbe is a simplified version of the generated wrapper function found in +// golang.org/x/sys/unix/zsyscall_linux_riscv64.go. We simplify it by removing the +// cpuCount and cpus parameters which we do not need. We always want to pass 0 for +// these parameters here so the kernel only reports the extensions that are present +// on all cores. +func riscvHWProbe(pairs []riscvHWProbePairs, flags uint) bool { + var _zero uintptr + var p0 unsafe.Pointer + if len(pairs) > 0 { + p0 = unsafe.Pointer(&pairs[0]) + } else { + p0 = unsafe.Pointer(&_zero) + } + + _, _, e1 := syscall.Syscall6(sys_RISCV_HWPROBE, uintptr(p0), uintptr(len(pairs)), uintptr(0), uintptr(0), uintptr(flags), 0) + return e1 == 0 +} diff --git a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_riscv64.go index 7f0c79c004b..aca3199c911 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/cpu/cpu_riscv64.go @@ -8,4 +8,13 @@ package cpu const cacheLineSize = 64 -func initOptions() {} +func initOptions() { + options = []option{ + {Name: "fastmisaligned", Feature: &RISCV64.HasFastMisaligned}, + {Name: "c", Feature: &RISCV64.HasC}, + {Name: "v", Feature: &RISCV64.HasV}, + {Name: "zba", Feature: &RISCV64.HasZba}, + {Name: "zbb", Feature: &RISCV64.HasZbb}, + {Name: "zbs", Feature: &RISCV64.HasZbs}, + } +} diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/README.md b/terraform/providers/google/vendor/golang.org/x/sys/unix/README.md index 7d3c060e122..6e08a76a716 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/README.md +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/README.md @@ -156,7 +156,7 @@ from the generated architecture-specific files listed below, and merge these into a common file for each OS. The merge is performed in the following steps: -1. Construct the set of common code that is idential in all architecture-specific files. +1. Construct the set of common code that is identical in all architecture-specific files. 2. Write this common code to the merged file. 3. Remove the common code from all architecture-specific files. diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/mkerrors.sh b/terraform/providers/google/vendor/golang.org/x/sys/unix/mkerrors.sh index 4ed2e488b61..ac54ecaba0a 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -58,6 +58,7 @@ includes_Darwin=' #define _DARWIN_USE_64_BIT_INODE #define __APPLE_USE_RFC_3542 #include +#include #include #include #include @@ -551,6 +552,7 @@ ccflags="$@" $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ || + $2 ~ /^(CONNECT|SAE)_/ || $2 ~ /^FIORDCHK$/ || $2 ~ /^SIOC/ || $2 ~ /^TIOC/ || @@ -654,7 +656,7 @@ errors=$( signals=$( echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | - grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | + grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | sort ) @@ -664,7 +666,7 @@ echo '#include ' | $CC -x c - -E -dM $ccflags | sort >_error.grep echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | - grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | + grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | sort >_signal.grep echo '// mkerrors.sh' "$@" diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/mremap.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/mremap.go index fd45fe529da..3a5e776f895 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/mremap.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/mremap.go @@ -50,3 +50,8 @@ func (m *mremapMmapper) Mremap(oldData []byte, newLength int, flags int) (data [ func Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { return mapper.Mremap(oldData, newLength, flags) } + +func MremapPtr(oldAddr unsafe.Pointer, oldSize uintptr, newAddr unsafe.Pointer, newSize uintptr, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mremap(uintptr(oldAddr), oldSize, newSize, flags, uintptr(newAddr)) + return unsafe.Pointer(xaddr), err +} diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_aix.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_aix.go index 67ce6cef2d5..6f15ba1eaff 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_aix.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_aix.go @@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, var status _C_int var r Pid_t err = ERESTART - // AIX wait4 may return with ERESTART errno, while the processus is still + // AIX wait4 may return with ERESTART errno, while the process is still // active. for err == ERESTART { r, err = wait4(Pid_t(pid), &status, options, rusage) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_darwin.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_darwin.go index 59542a897d2..099867deede 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -402,6 +402,18 @@ func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error { return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq)) } +//sys renamexNp(from string, to string, flag uint32) (err error) + +func RenamexNp(from string, to string, flag uint32) (err error) { + return renamexNp(from, to, flag) +} + +//sys renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) + +func RenameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + return renameatxNp(fromfd, from, tofd, to, flag) +} + //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL func Uname(uname *Utsname) error { @@ -542,6 +554,55 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { } } +//sys pthread_chdir_np(path string) (err error) + +func PthreadChdir(path string) (err error) { + return pthread_chdir_np(path) +} + +//sys pthread_fchdir_np(fd int) (err error) + +func PthreadFchdir(fd int) (err error) { + return pthread_fchdir_np(fd) +} + +// Connectx calls connectx(2) to initiate a connection on a socket. +// +// srcIf, srcAddr, and dstAddr are filled into a [SaEndpoints] struct and passed as the endpoints argument. +// +// - srcIf is the optional source interface index. 0 means unspecified. +// - srcAddr is the optional source address. nil means unspecified. +// - dstAddr is the destination address. +// +// On success, Connectx returns the number of bytes enqueued for transmission. +func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocID, flags uint32, iov []Iovec, connid *SaeConnID) (n uintptr, err error) { + endpoints := SaEndpoints{ + Srcif: srcIf, + } + + if srcAddr != nil { + addrp, addrlen, err := srcAddr.sockaddr() + if err != nil { + return 0, err + } + endpoints.Srcaddr = (*RawSockaddr)(addrp) + endpoints.Srcaddrlen = uint32(addrlen) + } + + if dstAddr != nil { + addrp, addrlen, err := dstAddr.sockaddr() + if err != nil { + return 0, err + } + endpoints.Dstaddr = (*RawSockaddr)(addrp) + endpoints.Dstaddrlen = uint32(addrlen) + } + + err = connectx(fd, &endpoints, associd, flags, iov, &n, connid) + return +} + +//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_hurd.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_hurd.go index ba46651f8e3..a6a2d2fc2b9 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_hurd.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_hurd.go @@ -11,6 +11,7 @@ package unix int ioctl(int, unsigned long int, uintptr_t); */ import "C" +import "unsafe" func ioctl(fd int, req uint, arg uintptr) (err error) { r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg)) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux.go index 5682e2628ad..f08abd434ff 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -1295,6 +1295,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) { return &value, err } +// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas" +// algorithm. +// +// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option: +// +// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION) +func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) { + var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment + vallen := _Socklen(SizeofTCPCCInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + out := (*TCPVegasInfo)(unsafe.Pointer(&value[0])) + return out, err +} + +// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp" +// algorithm. +// +// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option: +// +// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION) +func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) { + var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment + vallen := _Socklen(SizeofTCPCCInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0])) + return out, err +} + +// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr" +// algorithm. +// +// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option: +// +// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION) +func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) { + var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment + vallen := _Socklen(SizeofTCPCCInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + out := (*TCPBBRInfo)(unsafe.Pointer(&value[0])) + return out, err +} + // GetsockoptString returns the string value of the socket option opt for the // socket associated with fd at the given socket level. func GetsockoptString(fd, level, opt int) (string, error) { @@ -1959,7 +2001,26 @@ func Getpgrp() (pid int) { //sysnb Getpid() (pid int) //sysnb Getppid() (ppid int) //sys Getpriority(which int, who int) (prio int, err error) -//sys Getrandom(buf []byte, flags int) (n int, err error) + +func Getrandom(buf []byte, flags int) (n int, err error) { + vdsoRet, supported := vgetrandom(buf, uint32(flags)) + if supported { + if vdsoRet < 0 { + return 0, errnoErr(syscall.Errno(-vdsoRet)) + } + return vdsoRet, nil + } + var p *byte + if len(buf) > 0 { + p = &buf[0] + } + r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags)) + if e != 0 { + return 0, errnoErr(e) + } + return int(r), nil +} + //sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Getsid(pid int) (sid int, err error) //sysnb Gettid() (tid int) @@ -2592,3 +2653,4 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) { } //sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error) +//sys Mseal(b []byte, flags uint) (err error) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go index cf2ee6c75ef..745e5c7e6c0 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_arm64.go @@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error } return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) } + +const SYS_FSTATAT = SYS_NEWFSTATAT diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go index 3d0e98451f8..dd2262a4079 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_loong64.go @@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error } return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) } + +const SYS_FSTATAT = SYS_NEWFSTATAT diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go index 6f5a288944d..8cf3670bda6 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_linux_riscv64.go @@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error } return riscvHWProbe(pairs, setSize, set, flags) } + +const SYS_FSTATAT = SYS_NEWFSTATAT diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_openbsd.go index b25343c71a4..b86ded549c6 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -293,6 +293,7 @@ func Uname(uname *Utsname) error { //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) +//sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_unix.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_unix.go index 77081de8c7d..4e92e5aa406 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -154,6 +154,15 @@ func Munmap(b []byte) (err error) { return mapper.Munmap(b) } +func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset) + return unsafe.Pointer(xaddr), err +} + +func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) { + return mapper.munmap(uintptr(addr), length) +} + func Read(fd int, p []byte) (n int, err error) { n, err = read(fd, p) if raceenabled { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/vgetrandom_linux.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/vgetrandom_linux.go new file mode 100644 index 00000000000..07ac8e09d1b --- /dev/null +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/vgetrandom_linux.go @@ -0,0 +1,13 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && go1.24 + +package unix + +import _ "unsafe" + +//go:linkname vgetrandom runtime.vgetrandom +//go:noescape +func vgetrandom(p []byte, flags uint32) (ret int, supported bool) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go new file mode 100644 index 00000000000..297e97bce92 --- /dev/null +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/vgetrandom_unsupported.go @@ -0,0 +1,11 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !linux || !go1.24 + +package unix + +func vgetrandom(p []byte, flags uint32) (ret int, supported bool) { + return -1, false +} diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index e40fa85245f..d73c4652e6c 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -237,6 +237,9 @@ const ( CLOCK_UPTIME_RAW_APPROX = 0x9 CLONE_NOFOLLOW = 0x1 CLONE_NOOWNERCOPY = 0x2 + CONNECT_DATA_AUTHENTICATED = 0x4 + CONNECT_DATA_IDEMPOTENT = 0x2 + CONNECT_RESUME_ON_READ_WRITE = 0x1 CR0 = 0x0 CR1 = 0x1000 CR2 = 0x2000 @@ -1169,6 +1172,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 @@ -1260,6 +1268,10 @@ const ( RTV_SSTHRESH = 0x20 RUSAGE_CHILDREN = -0x1 RUSAGE_SELF = 0x0 + SAE_ASSOCID_ALL = 0xffffffff + SAE_ASSOCID_ANY = 0x0 + SAE_CONNID_ALL = 0xffffffff + SAE_CONNID_ANY = 0x0 SCM_CREDS = 0x3 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x2 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index bb02aa6c056..4a55a400588 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -237,6 +237,9 @@ const ( CLOCK_UPTIME_RAW_APPROX = 0x9 CLONE_NOFOLLOW = 0x1 CLONE_NOOWNERCOPY = 0x2 + CONNECT_DATA_AUTHENTICATED = 0x4 + CONNECT_DATA_IDEMPOTENT = 0x2 + CONNECT_RESUME_ON_READ_WRITE = 0x1 CR0 = 0x0 CR1 = 0x1000 CR2 = 0x2000 @@ -1169,6 +1172,11 @@ const ( PT_WRITE_D = 0x5 PT_WRITE_I = 0x4 PT_WRITE_U = 0x6 + RENAME_EXCL = 0x4 + RENAME_NOFOLLOW_ANY = 0x10 + RENAME_RESERVED1 = 0x8 + RENAME_SECLUDE = 0x1 + RENAME_SWAP = 0x2 RLIMIT_AS = 0x5 RLIMIT_CORE = 0x4 RLIMIT_CPU = 0x0 @@ -1260,6 +1268,10 @@ const ( RTV_SSTHRESH = 0x20 RUSAGE_CHILDREN = -0x1 RUSAGE_SELF = 0x0 + SAE_ASSOCID_ALL = 0xffffffff + SAE_ASSOCID_ANY = 0x0 + SAE_CONNID_ALL = 0xffffffff + SAE_CONNID_ANY = 0x0 SCM_CREDS = 0x3 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x2 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux.go index 877a62b479a..de3b462489c 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -457,6 +457,7 @@ const ( B600 = 0x8 B75 = 0x2 B9600 = 0xd + BCACHEFS_SUPER_MAGIC = 0xca451a4e BDEVFS_MAGIC = 0x62646576 BINDERFS_SUPER_MAGIC = 0x6c6f6f70 BINFMTFS_MAGIC = 0x42494e4d @@ -494,6 +495,7 @@ const ( BPF_F_TEST_REG_INVARIANTS = 0x80 BPF_F_TEST_RND_HI32 = 0x4 BPF_F_TEST_RUN_ON_CPU = 0x1 + BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4 BPF_F_TEST_STATE_FREQ = 0x8 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2 BPF_F_XDP_DEV_BOUND_ONLY = 0x40 @@ -928,6 +930,7 @@ const ( EPOLL_CTL_ADD = 0x1 EPOLL_CTL_DEL = 0x2 EPOLL_CTL_MOD = 0x3 + EPOLL_IOC_TYPE = 0x8a EROFS_SUPER_MAGIC_V1 = 0xe0f5e1e2 ESP_V4_FLOW = 0xa ESP_V6_FLOW = 0xc @@ -941,9 +944,6 @@ const ( ETHTOOL_FEC_OFF = 0x4 ETHTOOL_FEC_RS = 0x8 ETHTOOL_FLAG_ALL = 0x7 - ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 - ETHTOOL_FLAG_OMIT_REPLY = 0x2 - ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_FLASHDEV = 0x33 ETHTOOL_FLASH_MAX_FILENAME = 0x80 ETHTOOL_FWVERS_LEN = 0x20 @@ -1705,6 +1705,7 @@ const ( KEXEC_ARCH_S390 = 0x160000 KEXEC_ARCH_SH = 0x2a0000 KEXEC_ARCH_X86_64 = 0x3e0000 + KEXEC_CRASH_HOTPLUG_SUPPORT = 0x8 KEXEC_FILE_DEBUG = 0x8 KEXEC_FILE_NO_INITRAMFS = 0x4 KEXEC_FILE_ON_CRASH = 0x2 @@ -1780,6 +1781,7 @@ const ( KEY_SPEC_USER_KEYRING = -0x4 KEY_SPEC_USER_SESSION_KEYRING = -0x5 LANDLOCK_ACCESS_FS_EXECUTE = 0x1 + LANDLOCK_ACCESS_FS_IOCTL_DEV = 0x8000 LANDLOCK_ACCESS_FS_MAKE_BLOCK = 0x800 LANDLOCK_ACCESS_FS_MAKE_CHAR = 0x40 LANDLOCK_ACCESS_FS_MAKE_DIR = 0x80 @@ -1861,6 +1863,19 @@ const ( MAP_FILE = 0x0 MAP_FIXED = 0x10 MAP_FIXED_NOREPLACE = 0x100000 + MAP_HUGE_16GB = 0x88000000 + MAP_HUGE_16KB = 0x38000000 + MAP_HUGE_16MB = 0x60000000 + MAP_HUGE_1GB = 0x78000000 + MAP_HUGE_1MB = 0x50000000 + MAP_HUGE_256MB = 0x70000000 + MAP_HUGE_2GB = 0x7c000000 + MAP_HUGE_2MB = 0x54000000 + MAP_HUGE_32MB = 0x64000000 + MAP_HUGE_512KB = 0x4c000000 + MAP_HUGE_512MB = 0x74000000 + MAP_HUGE_64KB = 0x40000000 + MAP_HUGE_8MB = 0x5c000000 MAP_HUGE_MASK = 0x3f MAP_HUGE_SHIFT = 0x1a MAP_PRIVATE = 0x2 @@ -1908,6 +1923,7 @@ const ( MNT_EXPIRE = 0x4 MNT_FORCE = 0x1 MNT_ID_REQ_SIZE_VER0 = 0x18 + MNT_ID_REQ_SIZE_VER1 = 0x20 MODULE_INIT_COMPRESSED_FILE = 0x4 MODULE_INIT_IGNORE_MODVERSIONS = 0x1 MODULE_INIT_IGNORE_VERMAGIC = 0x2 @@ -2173,7 +2189,7 @@ const ( NFT_REG_SIZE = 0x10 NFT_REJECT_ICMPX_MAX = 0x3 NFT_RT_MAX = 0x4 - NFT_SECMARK_CTX_MAXLEN = 0x100 + NFT_SECMARK_CTX_MAXLEN = 0x1000 NFT_SET_MAXNAMELEN = 0x100 NFT_SOCKET_MAX = 0x3 NFT_TABLE_F_MASK = 0x7 @@ -2342,9 +2358,11 @@ const ( PERF_MEM_LVLNUM_IO = 0xa PERF_MEM_LVLNUM_L1 = 0x1 PERF_MEM_LVLNUM_L2 = 0x2 + PERF_MEM_LVLNUM_L2_MHB = 0x5 PERF_MEM_LVLNUM_L3 = 0x3 PERF_MEM_LVLNUM_L4 = 0x4 PERF_MEM_LVLNUM_LFB = 0xc + PERF_MEM_LVLNUM_MSC = 0x6 PERF_MEM_LVLNUM_NA = 0xf PERF_MEM_LVLNUM_PMEM = 0xe PERF_MEM_LVLNUM_RAM = 0xd @@ -2417,6 +2435,7 @@ const ( PRIO_PGRP = 0x1 PRIO_PROCESS = 0x0 PRIO_USER = 0x2 + PROCFS_IOCTL_MAGIC = 'f' PROC_SUPER_MAGIC = 0x9fa0 PROT_EXEC = 0x4 PROT_GROWSDOWN = 0x1000000 @@ -2498,6 +2517,23 @@ const ( PR_PAC_GET_ENABLED_KEYS = 0x3d PR_PAC_RESET_KEYS = 0x36 PR_PAC_SET_ENABLED_KEYS = 0x3c + PR_PPC_DEXCR_CTRL_CLEAR = 0x4 + PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC = 0x10 + PR_PPC_DEXCR_CTRL_EDITABLE = 0x1 + PR_PPC_DEXCR_CTRL_MASK = 0x1f + PR_PPC_DEXCR_CTRL_SET = 0x2 + PR_PPC_DEXCR_CTRL_SET_ONEXEC = 0x8 + PR_PPC_DEXCR_IBRTPD = 0x1 + PR_PPC_DEXCR_NPHIE = 0x3 + PR_PPC_DEXCR_SBHE = 0x0 + PR_PPC_DEXCR_SRAPD = 0x2 + PR_PPC_GET_DEXCR = 0x48 + PR_PPC_SET_DEXCR = 0x49 + PR_RISCV_CTX_SW_FENCEI_OFF = 0x1 + PR_RISCV_CTX_SW_FENCEI_ON = 0x0 + PR_RISCV_SCOPE_PER_PROCESS = 0x0 + PR_RISCV_SCOPE_PER_THREAD = 0x1 + PR_RISCV_SET_ICACHE_FLUSH_CTX = 0x47 PR_RISCV_V_GET_CONTROL = 0x46 PR_RISCV_V_SET_CONTROL = 0x45 PR_RISCV_V_VSTATE_CTRL_CUR_MASK = 0x3 @@ -2902,11 +2938,12 @@ const ( RUSAGE_SELF = 0x0 RUSAGE_THREAD = 0x1 RWF_APPEND = 0x10 + RWF_ATOMIC = 0x40 RWF_DSYNC = 0x2 RWF_HIPRI = 0x1 RWF_NOAPPEND = 0x20 RWF_NOWAIT = 0x8 - RWF_SUPPORTED = 0x3f + RWF_SUPPORTED = 0x7f RWF_SYNC = 0x4 RWF_WRITE_LIFE_NOT_SET = 0x0 SCHED_BATCH = 0x3 @@ -3179,6 +3216,7 @@ const ( STATX_ATTR_MOUNT_ROOT = 0x2000 STATX_ATTR_NODUMP = 0x40 STATX_ATTR_VERITY = 0x100000 + STATX_ATTR_WRITE_ATOMIC = 0x400000 STATX_BASIC_STATS = 0x7ff STATX_BLOCKS = 0x400 STATX_BTIME = 0x800 @@ -3192,8 +3230,10 @@ const ( STATX_MTIME = 0x40 STATX_NLINK = 0x4 STATX_SIZE = 0x200 + STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 + STATX_WRITE_ATOMIC = 0x10000 STATX__RESERVED = 0x80000000 SYNC_FILE_RANGE_WAIT_AFTER = 0x4 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1 @@ -3592,6 +3632,7 @@ const ( XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 XDP_UMEM_PGOFF_FILL_RING = 0x100000000 XDP_UMEM_REG = 0x4 + XDP_UMEM_TX_METADATA_LEN = 0x4 XDP_UMEM_TX_SW_CSUM = 0x2 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1 XDP_USE_NEED_WAKEUP = 0x8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index e4bc0bd57c7..8aa6d77c018 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -151,9 +153,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index 689317afdbf..da428f42533 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -151,9 +153,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 5cca668ac30..bf45bfec78a 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 14270508b04..71c67162b73 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 ESR_MAGIC = 0x45535201 EXTPROC = 0x10000 @@ -152,9 +154,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go index 28e39afdcb4..9476628fa02 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_loong64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -152,9 +154,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index cd66e92cb42..b9e85f3cf0c 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index c1595eba78e..a48b68a7647 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index ee9456b0da7..ea00e8522a1 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index 8cfca81e1b5..91c64687176 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x80 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go index 60b0deb3af7..8cbf38d6390 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 @@ -150,9 +152,14 @@ const ( NL3 = 0x300 NLDLY = 0x300 NOFLSH = 0x80000000 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x4 ONLCR = 0x2 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index f90aa7281bf..a2df7341917 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 @@ -150,9 +152,14 @@ const ( NL3 = 0x300 NLDLY = 0x300 NOFLSH = 0x80000000 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x4 ONLCR = 0x2 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index ba9e0150338..24791379233 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x20 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000000 FF1 = 0x4000 @@ -150,9 +152,14 @@ const ( NL3 = 0x300 NLDLY = 0x300 NOFLSH = 0x80000000 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x4 ONLCR = 0x2 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 07cdfd6e9fd..d265f146ee0 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 2f1dd214a74..3f2d6443964 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -78,6 +78,8 @@ const ( ECHOPRT = 0x400 EFD_CLOEXEC = 0x80000 EFD_NONBLOCK = 0x800 + EPIOCGPARAMS = 0x80088a02 + EPIOCSPARAMS = 0x40088a01 EPOLL_CLOEXEC = 0x80000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -148,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index f40519d9018..5d8b727a1c8 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -82,6 +82,8 @@ const ( EFD_CLOEXEC = 0x400000 EFD_NONBLOCK = 0x4000 EMT_TAGOVF = 0x1 + EPIOCGPARAMS = 0x40088a02 + EPIOCSPARAMS = 0x80088a01 EPOLL_CLOEXEC = 0x400000 EXTPROC = 0x10000 FF1 = 0x8000 @@ -153,9 +155,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go index da08b2ab3d9..1ec2b1407b1 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go @@ -581,6 +581,8 @@ const ( AT_EMPTY_PATH = 0x1000 AT_REMOVEDIR = 0x200 RENAME_NOREPLACE = 1 << 0 + ST_RDONLY = 1 + ST_NOSUID = 2 ) const ( diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index ccb02f240a4..24b346e1a35 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -760,6 +808,59 @@ var libc_sysctl_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pthread_chdir_np(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_chdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pthread_fchdir_np(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_fchdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) { + var _p0 unsafe.Pointer + if len(iov) > 0 { + _p0 = unsafe.Pointer(&iov[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall9(libc_connectx_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(endpoints)), uintptr(associd), uintptr(flags), uintptr(_p0), uintptr(len(iov)), uintptr(unsafe.Pointer(n)), uintptr(unsafe.Pointer(connid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_connectx_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_connectx connectx "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 8b8bb284028..ebd213100b3 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -223,11 +223,36 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) +TEXT libc_pthread_chdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_chdir_np(SB) +GLOBL ·libc_pthread_chdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_chdir_np_trampoline_addr(SB)/8, $libc_pthread_chdir_np_trampoline<>(SB) + +TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_fchdir_np(SB) +GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) + +TEXT libc_connectx_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_connectx(SB) +GLOBL ·libc_connectx_trampoline_addr(SB), RODATA, $8 +DATA ·libc_connectx_trampoline_addr(SB)/8, $libc_connectx_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 1b40b997b52..824b9c2d5e0 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -740,6 +740,54 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func renamexNp(from string, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_renamex_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flag)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renamex_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renamex_np renamex_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func renameatxNp(fromfd int, from string, tofd int, to string, flag uint32) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(from) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(to) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_renameatx_np_trampoline_addr, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), uintptr(flag), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_renameatx_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_renameatx_np renameatx_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { @@ -760,6 +808,59 @@ var libc_sysctl_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pthread_chdir_np(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_chdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pthread_fchdir_np(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_fchdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) { + var _p0 unsafe.Pointer + if len(iov) > 0 { + _p0 = unsafe.Pointer(&iov[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall9(libc_connectx_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(endpoints)), uintptr(associd), uintptr(flags), uintptr(_p0), uintptr(len(iov)), uintptr(unsafe.Pointer(n)), uintptr(unsafe.Pointer(connid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_connectx_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_connectx connectx "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 08362c1ab74..4f178a22934 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -223,11 +223,36 @@ TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_ioctl_trampoline_addr(SB)/8, $libc_ioctl_trampoline<>(SB) +TEXT libc_renamex_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renamex_np(SB) +GLOBL ·libc_renamex_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renamex_np_trampoline_addr(SB)/8, $libc_renamex_np_trampoline<>(SB) + +TEXT libc_renameatx_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_renameatx_np(SB) +GLOBL ·libc_renameatx_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_renameatx_np_trampoline_addr(SB)/8, $libc_renameatx_np_trampoline<>(SB) + TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sysctl(SB) GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) +TEXT libc_pthread_chdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_chdir_np(SB) +GLOBL ·libc_pthread_chdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_chdir_np_trampoline_addr(SB)/8, $libc_pthread_chdir_np_trampoline<>(SB) + +TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_fchdir_np(SB) +GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) + +TEXT libc_connectx_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_connectx(SB) +GLOBL ·libc_connectx_trampoline_addr(SB), RODATA, $8 +DATA ·libc_connectx_trampoline_addr(SB)/8, $libc_connectx_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_linux.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_linux.go index 87d8612a1dc..af30da55780 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_linux.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_linux.go @@ -971,23 +971,6 @@ func Getpriority(which int, who int) (prio int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Getrandom(buf []byte, flags int) (n int, err error) { - var _p0 unsafe.Pointer - if len(buf) > 0 { - _p0 = unsafe.Pointer(&buf[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getrusage(who int, rusage *Rusage) (err error) { _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) if e1 != 0 { @@ -2229,3 +2212,19 @@ func Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func Mseal(b []byte, flags uint) (err error) { + var _p0 unsafe.Pointer + if len(b) > 0 { + _p0 = unsafe.Pointer(&b[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := Syscall(SYS_MSEAL, uintptr(_p0), uintptr(len(b)), uintptr(flags)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go index 9dc42410b78..1851df14e87 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s index 41b5617316c..0b43c693656 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_386.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go index 0d3a0751cd4..e1ec0dbe4ec 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s index 4019a656f6d..880c6d6e316 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_amd64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go index c39f7776db3..7c8452a63e9 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s index ac4af24f908..b8ef95b0fa1 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $4 DATA ·libc_mknodat_trampoline_addr(SB)/4, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $4 +DATA ·libc_mount_trampoline_addr(SB)/4, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $4 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go index 57571d072fe..2ffdf861f75 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s index f77d532121b..2af3b5c762f 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_arm64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go index e62963e67e2..1da08d52675 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s index fae140b62c9..b7a251353b0 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_mips64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go index 00831354c82..6e85b0aac95 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s index 9d1e0ff06d0..f15dadf0552 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_ppc64.s @@ -555,6 +555,12 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_mount(SB) + RET +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_nanosleep(SB) RET diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go index 79029ed5848..28b487df251 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.go @@ -1493,6 +1493,30 @@ var libc_mknodat_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(fsType) + if err != nil { + return + } + var _p1 *byte + _p1, err = BytePtrFromString(dir) + if err != nil { + return + } + _, _, e1 := syscall_syscall6(libc_mount_trampoline_addr, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), uintptr(flags), uintptr(data), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_mount_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_mount mount "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := syscall_syscall(libc_nanosleep_trampoline_addr, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s index da115f9a4b6..1e7f321e436 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsyscall_openbsd_riscv64.s @@ -463,6 +463,11 @@ TEXT libc_mknodat_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_mknodat_trampoline_addr(SB), RODATA, $8 DATA ·libc_mknodat_trampoline_addr(SB)/8, $libc_mknodat_trampoline<>(SB) +TEXT libc_mount_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_mount(SB) +GLOBL ·libc_mount_trampoline_addr(SB), RODATA, $8 +DATA ·libc_mount_trampoline_addr(SB)/8, $libc_mount_trampoline<>(SB) + TEXT libc_nanosleep_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_nanosleep(SB) GLOBL ·libc_nanosleep_trampoline_addr(SB), RODATA, $8 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go index 53aef5dc58d..524b0820cbc 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go @@ -457,4 +457,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go index 71d524763d3..f485dbf4565 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go @@ -341,6 +341,7 @@ const ( SYS_STATX = 332 SYS_IO_PGETEVENTS = 333 SYS_RSEQ = 334 + SYS_URETPROBE = 335 SYS_PIDFD_SEND_SIGNAL = 424 SYS_IO_URING_SETUP = 425 SYS_IO_URING_ENTER = 426 @@ -379,4 +380,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go index c747706131c..70b35bf3b09 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go @@ -421,4 +421,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go index f96e214f6d4..1893e2fe884 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go @@ -85,7 +85,7 @@ const ( SYS_SPLICE = 76 SYS_TEE = 77 SYS_READLINKAT = 78 - SYS_FSTATAT = 79 + SYS_NEWFSTATAT = 79 SYS_FSTAT = 80 SYS_SYNC = 81 SYS_FSYNC = 82 @@ -324,4 +324,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go index 28425346cf1..16a4017da0a 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_loong64.go @@ -84,6 +84,8 @@ const ( SYS_SPLICE = 76 SYS_TEE = 77 SYS_READLINKAT = 78 + SYS_NEWFSTATAT = 79 + SYS_FSTAT = 80 SYS_SYNC = 81 SYS_FSYNC = 82 SYS_FDATASYNC = 83 @@ -318,4 +320,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go index d0953018dae..7e567f1efff 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go index 295c7f4b818..38ae55e5ef8 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go index d1a9eaca7a4..55e92e60a82 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go @@ -371,4 +371,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 5459 SYS_LSM_SET_SELF_ATTR = 5460 SYS_LSM_LIST_MODULES = 5461 + SYS_MSEAL = 5462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go index bec157c39fd..60658d6a021 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go @@ -441,4 +441,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 4459 SYS_LSM_SET_SELF_ATTR = 4460 SYS_LSM_LIST_MODULES = 4461 + SYS_MSEAL = 4462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go index 7ee7bdc435c..e203e8a7ed4 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc.go @@ -448,4 +448,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go index fad1f25b449..5944b97d546 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go index 7d3e16357d6..c66d416dad1 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go @@ -420,4 +420,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go index 0ed53ad9f7e..a5459e766f5 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go @@ -84,7 +84,7 @@ const ( SYS_SPLICE = 76 SYS_TEE = 77 SYS_READLINKAT = 78 - SYS_FSTATAT = 79 + SYS_NEWFSTATAT = 79 SYS_FSTAT = 80 SYS_SYNC = 81 SYS_FSYNC = 82 @@ -325,4 +325,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go index 2fba04ad500..01d86825bb9 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go @@ -386,4 +386,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go index 621d00d741b..7b703e77cda 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go @@ -399,4 +399,5 @@ const ( SYS_LSM_GET_SELF_ATTR = 459 SYS_LSM_SET_SELF_ATTR = 460 SYS_LSM_LIST_MODULES = 461 + SYS_MSEAL = 462 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 091d107f3a5..d003c3d4378 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -306,6 +306,19 @@ type XVSockPgen struct { type _Socklen uint32 +type SaeAssocID uint32 + +type SaeConnID uint32 + +type SaEndpoints struct { + Srcif uint32 + Srcaddr *RawSockaddr + Srcaddrlen uint32 + Dstaddr *RawSockaddr + Dstaddrlen uint32 + _ [4]byte +} + type Xucred struct { Version uint32 Uid uint32 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 28ff4ef74d0..0d45a941aae 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -306,6 +306,19 @@ type XVSockPgen struct { type _Socklen uint32 +type SaeAssocID uint32 + +type SaeConnID uint32 + +type SaEndpoints struct { + Srcif uint32 + Srcaddr *RawSockaddr + Srcaddrlen uint32 + Dstaddr *RawSockaddr + Dstaddrlen uint32 + _ [4]byte +} + type Xucred struct { Version uint32 Uid uint32 diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 6cbd094a3aa..51e13eb055f 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -625,6 +625,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 7c03b6ee77f..d002d8ef3cc 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -630,6 +630,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index 422107ee8b1..3f863d898dd 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -616,6 +616,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index 505a12acfd9..61c72931066 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -610,6 +610,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index cc986c79006..b5d17414f03 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -612,6 +612,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux.go index 4740b834854..3a69e454962 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -87,30 +87,35 @@ type StatxTimestamp struct { } type Statx_t struct { - Mask uint32 - Blksize uint32 - Attributes uint64 - Nlink uint32 - Uid uint32 - Gid uint32 - Mode uint16 - _ [1]uint16 - Ino uint64 - Size uint64 - Blocks uint64 - Attributes_mask uint64 - Atime StatxTimestamp - Btime StatxTimestamp - Ctime StatxTimestamp - Mtime StatxTimestamp - Rdev_major uint32 - Rdev_minor uint32 - Dev_major uint32 - Dev_minor uint32 - Mnt_id uint64 - Dio_mem_align uint32 - Dio_offset_align uint32 - _ [12]uint64 + Mask uint32 + Blksize uint32 + Attributes uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Mode uint16 + _ [1]uint16 + Ino uint64 + Size uint64 + Blocks uint64 + Attributes_mask uint64 + Atime StatxTimestamp + Btime StatxTimestamp + Ctime StatxTimestamp + Mtime StatxTimestamp + Rdev_major uint32 + Rdev_minor uint32 + Dev_major uint32 + Dev_minor uint32 + Mnt_id uint64 + Dio_mem_align uint32 + Dio_offset_align uint32 + Subvol uint64 + Atomic_write_unit_min uint32 + Atomic_write_unit_max uint32 + Atomic_write_segments_max uint32 + _ [1]uint32 + _ [9]uint64 } type Fsid struct { @@ -515,6 +520,29 @@ type TCPInfo struct { Total_rto_time uint32 } +type TCPVegasInfo struct { + Enabled uint32 + Rttcnt uint32 + Rtt uint32 + Minrtt uint32 +} + +type TCPDCTCPInfo struct { + Enabled uint16 + Ce_state uint16 + Alpha uint32 + Ab_ecn uint32 + Ab_tot uint32 +} + +type TCPBBRInfo struct { + Bw_lo uint32 + Bw_hi uint32 + Min_rtt uint32 + Pacing_gain uint32 + Cwnd_gain uint32 +} + type CanFilter struct { Id uint32 Mask uint32 @@ -556,6 +584,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0xf8 + SizeofTCPCCInfo = 0x14 SizeofCanFilter = 0x8 SizeofTCPRepairOpt = 0x8 ) @@ -2485,7 +2514,7 @@ type XDPMmapOffsets struct { type XDPUmemReg struct { Addr uint64 Len uint64 - Chunk_size uint32 + Size uint32 Headroom uint32 Flags uint32 Tx_metadata_len uint32 @@ -3473,7 +3502,7 @@ const ( DEVLINK_PORT_FN_ATTR_STATE = 0x2 DEVLINK_PORT_FN_ATTR_OPSTATE = 0x3 DEVLINK_PORT_FN_ATTR_CAPS = 0x4 - DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x5 + DEVLINK_PORT_FUNCTION_ATTR_MAX = 0x6 ) type FsverityDigest struct { @@ -3765,7 +3794,7 @@ const ( ETHTOOL_MSG_PSE_GET = 0x24 ETHTOOL_MSG_PSE_SET = 0x25 ETHTOOL_MSG_RSS_GET = 0x26 - ETHTOOL_MSG_USER_MAX = 0x2b + ETHTOOL_MSG_USER_MAX = 0x2c ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 @@ -3805,7 +3834,10 @@ const ( ETHTOOL_MSG_MODULE_NTF = 0x24 ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 - ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_MSG_KERNEL_MAX = 0x2c + ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 + ETHTOOL_FLAG_OMIT_REPLY = 0x2 + ETHTOOL_FLAG_STATS = 0x4 ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3947,7 +3979,7 @@ const ( ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18 ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19 - ETHTOOL_A_COALESCE_MAX = 0x1c + ETHTOOL_A_COALESCE_MAX = 0x1e ETHTOOL_A_PAUSE_UNSPEC = 0x0 ETHTOOL_A_PAUSE_HEADER = 0x1 ETHTOOL_A_PAUSE_AUTONEG = 0x2 @@ -3975,7 +4007,7 @@ const ( ETHTOOL_A_TSINFO_TX_TYPES = 0x3 ETHTOOL_A_TSINFO_RX_FILTERS = 0x4 ETHTOOL_A_TSINFO_PHC_INDEX = 0x5 - ETHTOOL_A_TSINFO_MAX = 0x5 + ETHTOOL_A_TSINFO_MAX = 0x6 ETHTOOL_A_CABLE_TEST_UNSPEC = 0x0 ETHTOOL_A_CABLE_TEST_HEADER = 0x1 ETHTOOL_A_CABLE_TEST_MAX = 0x1 @@ -4605,7 +4637,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x14a + NL80211_ATTR_MAX = 0x14c NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 @@ -5209,7 +5241,7 @@ const ( NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf - NL80211_FREQUENCY_ATTR_MAX = 0x20 + NL80211_FREQUENCY_ATTR_MAX = 0x21 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11 NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc diff --git a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 15adc04142f..ad05b51a603 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -727,6 +727,37 @@ const ( RISCV_HWPROBE_EXT_ZBA = 0x8 RISCV_HWPROBE_EXT_ZBB = 0x10 RISCV_HWPROBE_EXT_ZBS = 0x20 + RISCV_HWPROBE_EXT_ZICBOZ = 0x40 + RISCV_HWPROBE_EXT_ZBC = 0x80 + RISCV_HWPROBE_EXT_ZBKB = 0x100 + RISCV_HWPROBE_EXT_ZBKC = 0x200 + RISCV_HWPROBE_EXT_ZBKX = 0x400 + RISCV_HWPROBE_EXT_ZKND = 0x800 + RISCV_HWPROBE_EXT_ZKNE = 0x1000 + RISCV_HWPROBE_EXT_ZKNH = 0x2000 + RISCV_HWPROBE_EXT_ZKSED = 0x4000 + RISCV_HWPROBE_EXT_ZKSH = 0x8000 + RISCV_HWPROBE_EXT_ZKT = 0x10000 + RISCV_HWPROBE_EXT_ZVBB = 0x20000 + RISCV_HWPROBE_EXT_ZVBC = 0x40000 + RISCV_HWPROBE_EXT_ZVKB = 0x80000 + RISCV_HWPROBE_EXT_ZVKG = 0x100000 + RISCV_HWPROBE_EXT_ZVKNED = 0x200000 + RISCV_HWPROBE_EXT_ZVKNHA = 0x400000 + RISCV_HWPROBE_EXT_ZVKNHB = 0x800000 + RISCV_HWPROBE_EXT_ZVKSED = 0x1000000 + RISCV_HWPROBE_EXT_ZVKSH = 0x2000000 + RISCV_HWPROBE_EXT_ZVKT = 0x4000000 + RISCV_HWPROBE_EXT_ZFH = 0x8000000 + RISCV_HWPROBE_EXT_ZFHMIN = 0x10000000 + RISCV_HWPROBE_EXT_ZIHINTNTL = 0x20000000 + RISCV_HWPROBE_EXT_ZVFH = 0x40000000 + RISCV_HWPROBE_EXT_ZVFHMIN = 0x80000000 + RISCV_HWPROBE_EXT_ZFA = 0x100000000 + RISCV_HWPROBE_EXT_ZTSO = 0x200000000 + RISCV_HWPROBE_EXT_ZACAS = 0x400000000 + RISCV_HWPROBE_EXT_ZICOND = 0x800000000 + RISCV_HWPROBE_EXT_ZIHINTPAUSE = 0x1000000000 RISCV_HWPROBE_KEY_CPUPERF_0 = 0x5 RISCV_HWPROBE_MISALIGNED_UNKNOWN = 0x0 RISCV_HWPROBE_MISALIGNED_EMULATED = 0x1 @@ -734,4 +765,6 @@ const ( RISCV_HWPROBE_MISALIGNED_FAST = 0x3 RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = 0x4 RISCV_HWPROBE_MISALIGNED_MASK = 0x7 + RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE = 0x6 + RISCV_HWPROBE_WHICH_CPUS = 0x1 ) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/windows/dll_windows.go b/terraform/providers/google/vendor/golang.org/x/sys/windows/dll_windows.go index 115341fba66..4e613cf6335 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/windows/dll_windows.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/windows/dll_windows.go @@ -65,7 +65,7 @@ func LoadDLL(name string) (dll *DLL, err error) { return d, nil } -// MustLoadDLL is like LoadDLL but panics if load operation failes. +// MustLoadDLL is like LoadDLL but panics if load operation fails. func MustLoadDLL(name string) *DLL { d, e := LoadDLL(name) if e != nil { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/windows/security_windows.go b/terraform/providers/google/vendor/golang.org/x/sys/windows/security_windows.go index 6f7d2ac70a9..b6e1ab76f82 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/windows/security_windows.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/windows/security_windows.go @@ -894,7 +894,7 @@ type ACL struct { aclRevision byte sbz1 byte aclSize uint16 - aceCount uint16 + AceCount uint16 sbz2 uint16 } @@ -1087,6 +1087,27 @@ type EXPLICIT_ACCESS struct { Trustee TRUSTEE } +// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-ace_header +type ACE_HEADER struct { + AceType uint8 + AceFlags uint8 + AceSize uint16 +} + +// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-access_allowed_ace +type ACCESS_ALLOWED_ACE struct { + Header ACE_HEADER + Mask ACCESS_MASK + SidStart uint32 +} + +const ( + // Constants for AceType + // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-ace_header + ACCESS_ALLOWED_ACE_TYPE = 0 + ACCESS_DENIED_ACE_TYPE = 1 +) + // This type is the union inside of TRUSTEE and must be created using one of the TrusteeValueFrom* functions. type TrusteeValue uintptr @@ -1158,6 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/terraform/providers/google/vendor/golang.org/x/sys/windows/syscall_windows.go b/terraform/providers/google/vendor/golang.org/x/sys/windows/syscall_windows.go index 6525c62f3c2..5cee9a3143f 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -17,8 +17,10 @@ import ( "unsafe" ) -type Handle uintptr -type HWND uintptr +type ( + Handle uintptr + HWND uintptr +) const ( InvalidHandle = ^Handle(0) @@ -211,6 +213,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) //sys ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) [failretval<=32] = shell32.ShellExecuteW //sys GetWindowThreadProcessId(hwnd HWND, pid *uint32) (tid uint32, err error) = user32.GetWindowThreadProcessId +//sys LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) [failretval==0] = user32.LoadKeyboardLayoutW +//sys UnloadKeyboardLayout(hkl Handle) (err error) = user32.UnloadKeyboardLayout +//sys GetKeyboardLayout(tid uint32) (hkl Handle) = user32.GetKeyboardLayout +//sys ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) = user32.ToUnicodeEx //sys GetShellWindow() (shellWindow HWND) = user32.GetShellWindow //sys MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) [failretval==0] = user32.MessageBoxW //sys ExitWindowsEx(flags uint32, reason uint32) (err error) = user32.ExitWindowsEx @@ -307,6 +313,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode //sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo //sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition +//sys GetConsoleCP() (cp uint32, err error) = kernel32.GetConsoleCP +//sys GetConsoleOutputCP() (cp uint32, err error) = kernel32.GetConsoleOutputCP +//sys SetConsoleCP(cp uint32) (err error) = kernel32.SetConsoleCP +//sys SetConsoleOutputCP(cp uint32) (err error) = kernel32.SetConsoleOutputCP //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW //sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole @@ -1368,9 +1378,11 @@ func SetsockoptLinger(fd Handle, level, opt int, l *Linger) (err error) { func SetsockoptInet4Addr(fd Handle, level, opt int, value [4]byte) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(&value[0])), 4) } + func SetsockoptIPMreq(fd Handle, level, opt int, mreq *IPMreq) (err error) { return Setsockopt(fd, int32(level), int32(opt), (*byte)(unsafe.Pointer(mreq)), int32(unsafe.Sizeof(*mreq))) } + func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } diff --git a/terraform/providers/google/vendor/golang.org/x/sys/windows/types_windows.go b/terraform/providers/google/vendor/golang.org/x/sys/windows/types_windows.go index d8cb71db0a6..7b97a154c95 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/windows/types_windows.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/windows/types_windows.go @@ -1060,6 +1060,7 @@ const ( SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12 + SIO_UDP_NETRESET = IOC_IN | IOC_VENDOR | 15 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460 @@ -2003,7 +2004,21 @@ const ( MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 ) -const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 +// Flags for GetAdaptersAddresses, see +// https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses. +const ( + GAA_FLAG_SKIP_UNICAST = 0x1 + GAA_FLAG_SKIP_ANYCAST = 0x2 + GAA_FLAG_SKIP_MULTICAST = 0x4 + GAA_FLAG_SKIP_DNS_SERVER = 0x8 + GAA_FLAG_INCLUDE_PREFIX = 0x10 + GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20 + GAA_FLAG_INCLUDE_WINS_INFO = 0x40 + GAA_FLAG_INCLUDE_GATEWAYS = 0x80 + GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100 + GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200 + GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400 +) const ( IF_TYPE_OTHER = 1 @@ -2017,6 +2032,50 @@ const ( IF_TYPE_IEEE1394 = 144 ) +// Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin +const ( + IpPrefixOriginOther = 0 + IpPrefixOriginManual = 1 + IpPrefixOriginWellKnown = 2 + IpPrefixOriginDhcp = 3 + IpPrefixOriginRouterAdvertisement = 4 + IpPrefixOriginUnchanged = 1 << 4 +) + +// Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin +const ( + NlsoOther = 0 + NlsoManual = 1 + NlsoWellKnown = 2 + NlsoDhcp = 3 + NlsoLinkLayerAddress = 4 + NlsoRandom = 5 + IpSuffixOriginOther = 0 + IpSuffixOriginManual = 1 + IpSuffixOriginWellKnown = 2 + IpSuffixOriginDhcp = 3 + IpSuffixOriginLinkLayerAddress = 4 + IpSuffixOriginRandom = 5 + IpSuffixOriginUnchanged = 1 << 4 +) + +// Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see +// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state +const ( + NldsInvalid = 0 + NldsTentative = 1 + NldsDuplicate = 2 + NldsDeprecated = 3 + NldsPreferred = 4 + IpDadStateInvalid = 0 + IpDadStateTentative = 1 + IpDadStateDuplicate = 2 + IpDadStateDeprecated = 3 + IpDadStatePreferred = 4 +) + type SocketAddress struct { Sockaddr *syscall.RawSockaddrAny SockaddrLength int32 @@ -3404,3 +3463,14 @@ type DCB struct { EvtChar byte wReserved1 uint16 } + +// Keyboard Layout Flags. +// See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw +const ( + KLF_ACTIVATE = 0x00000001 + KLF_SUBSTITUTE_OK = 0x00000002 + KLF_REORDER = 0x00000008 + KLF_REPLACELANG = 0x00000010 + KLF_NOTELLSHELL = 0x00000080 + KLF_SETFORPROCESS = 0x00000100 +) diff --git a/terraform/providers/google/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/terraform/providers/google/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 9f73df75b5f..4c2e1bdc01e 100644 --- a/terraform/providers/google/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/terraform/providers/google/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -91,6 +91,7 @@ var ( procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW") procEqualSid = modadvapi32.NewProc("EqualSid") procFreeSid = modadvapi32.NewProc("FreeSid") + procGetAce = modadvapi32.NewProc("GetAce") procGetLengthSid = modadvapi32.NewProc("GetLengthSid") procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW") procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl") @@ -246,7 +247,9 @@ var ( procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") + procGetConsoleCP = modkernel32.NewProc("GetConsoleCP") procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") + procGetConsoleOutputCP = modkernel32.NewProc("GetConsoleOutputCP") procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") @@ -346,8 +349,10 @@ var ( procSetCommMask = modkernel32.NewProc("SetCommMask") procSetCommState = modkernel32.NewProc("SetCommState") procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts") + procSetConsoleCP = modkernel32.NewProc("SetConsoleCP") procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition") procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") + procSetConsoleOutputCP = modkernel32.NewProc("SetConsoleOutputCP") procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories") procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW") @@ -477,12 +482,16 @@ var ( procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") + procGetKeyboardLayout = moduser32.NewProc("GetKeyboardLayout") procGetShellWindow = moduser32.NewProc("GetShellWindow") procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") procIsWindow = moduser32.NewProc("IsWindow") procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") procIsWindowVisible = moduser32.NewProc("IsWindowVisible") + procLoadKeyboardLayoutW = moduser32.NewProc("LoadKeyboardLayoutW") procMessageBoxW = moduser32.NewProc("MessageBoxW") + procToUnicodeEx = moduser32.NewProc("ToUnicodeEx") + procUnloadKeyboardLayout = moduser32.NewProc("UnloadKeyboardLayout") procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock") procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW") @@ -788,6 +797,14 @@ func FreeSid(sid *SID) (err error) { return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (err error) { + r1, _, e1 := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func GetLengthSid(sid *SID) (len uint32) { r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0) len = uint32(r0) @@ -2149,6 +2166,15 @@ func GetComputerName(buf *uint16, n *uint32) (err error) { return } +func GetConsoleCP() (cp uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0) + cp = uint32(r0) + if cp == 0 { + err = errnoErr(e1) + } + return +} + func GetConsoleMode(console Handle, mode *uint32) (err error) { r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) if r1 == 0 { @@ -2157,6 +2183,15 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) { return } +func GetConsoleOutputCP() (cp uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetConsoleOutputCP.Addr(), 0, 0, 0, 0) + cp = uint32(r0) + if cp == 0 { + err = errnoErr(e1) + } + return +} + func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) { r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0) if r1 == 0 { @@ -3025,6 +3060,14 @@ func SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) { return } +func SetConsoleCP(cp uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetConsoleCP.Addr(), 1, uintptr(cp), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func setConsoleCursorPosition(console Handle, position uint32) (err error) { r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0) if r1 == 0 { @@ -3041,6 +3084,14 @@ func SetConsoleMode(console Handle, mode uint32) (err error) { return } +func SetConsoleOutputCP(cp uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetConsoleOutputCP.Addr(), 1, uintptr(cp), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func SetCurrentDirectory(path *uint16) (err error) { r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) if r1 == 0 { @@ -4073,6 +4124,12 @@ func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { return } +func GetKeyboardLayout(tid uint32) (hkl Handle) { + r0, _, _ := syscall.Syscall(procGetKeyboardLayout.Addr(), 1, uintptr(tid), 0, 0) + hkl = Handle(r0) + return +} + func GetShellWindow() (shellWindow HWND) { r0, _, _ := syscall.Syscall(procGetShellWindow.Addr(), 0, 0, 0, 0) shellWindow = HWND(r0) @@ -4106,6 +4163,15 @@ func IsWindowVisible(hwnd HWND) (isVisible bool) { return } +func LoadKeyboardLayout(name *uint16, flags uint32) (hkl Handle, err error) { + r0, _, e1 := syscall.Syscall(procLoadKeyboardLayoutW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(flags), 0) + hkl = Handle(r0) + if hkl == 0 { + err = errnoErr(e1) + } + return +} + func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) { r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0) ret = int32(r0) @@ -4115,6 +4181,20 @@ func MessageBox(hwnd HWND, text *uint16, caption *uint16, boxtype uint32) (ret i return } +func ToUnicodeEx(vkey uint32, scancode uint32, keystate *byte, pwszBuff *uint16, cchBuff int32, flags uint32, hkl Handle) (ret int32) { + r0, _, _ := syscall.Syscall9(procToUnicodeEx.Addr(), 7, uintptr(vkey), uintptr(scancode), uintptr(unsafe.Pointer(keystate)), uintptr(unsafe.Pointer(pwszBuff)), uintptr(cchBuff), uintptr(flags), uintptr(hkl), 0, 0) + ret = int32(r0) + return +} + +func UnloadKeyboardLayout(hkl Handle) (err error) { + r1, _, e1 := syscall.Syscall(procUnloadKeyboardLayout.Addr(), 1, uintptr(hkl), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) { var _p0 uint32 if inheritExisting { diff --git a/terraform/providers/google/vendor/modules.txt b/terraform/providers/google/vendor/modules.txt index b30cf1b58fc..ecad614715d 100644 --- a/terraform/providers/google/vendor/modules.txt +++ b/terraform/providers/google/vendor/modules.txt @@ -51,6 +51,7 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl github.com/GoogleCloudPlatform/declarative-resource-client-library/dcl/operations github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/apikeys github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/assuredworkloads +github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/bigqueryreservation github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/clouddeploy github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudresourcemanager @@ -63,6 +64,8 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library/services/goog github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/firebaserules github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/networkconnectivity +github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy +github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/recaptchaenterprise # github.com/ProtonMail/go-crypto v1.1.0-alpha.0 ## explicit; go 1.17 @@ -433,11 +436,10 @@ github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfdiags github.com/hashicorp/terraform-plugin-sdk/v2/meta github.com/hashicorp/terraform-plugin-sdk/v2/plugin github.com/hashicorp/terraform-plugin-sdk/v2/terraform -# github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c -## explicit; go 1.21 +# github.com/hashicorp/terraform-provider-google v1.20.1-0.20240708170355-9d7e7459a11c => github.com/openshift/terraform-providers-terraform-provider-google v1.20.1-0.20260211184214-05cc74bd8b63 +## explicit; go 1.20 github.com/hashicorp/terraform-provider-google github.com/hashicorp/terraform-provider-google/google/envvar -github.com/hashicorp/terraform-provider-google/google/functions github.com/hashicorp/terraform-provider-google/google/fwmodels github.com/hashicorp/terraform-provider-google/google/fwprovider github.com/hashicorp/terraform-provider-google/google/fwresource @@ -525,7 +527,6 @@ github.com/hashicorp/terraform-provider-google/google/services/iamworkforcepool github.com/hashicorp/terraform-provider-google/google/services/iap github.com/hashicorp/terraform-provider-google/google/services/identityplatform github.com/hashicorp/terraform-provider-google/google/services/integrationconnectors -github.com/hashicorp/terraform-provider-google/google/services/integrations github.com/hashicorp/terraform-provider-google/google/services/kms github.com/hashicorp/terraform-provider-google/google/services/logging github.com/hashicorp/terraform-provider-google/google/services/looker @@ -552,8 +553,6 @@ github.com/hashicorp/terraform-provider-google/google/services/resourcemanager github.com/hashicorp/terraform-provider-google/google/services/secretmanager github.com/hashicorp/terraform-provider-google/google/services/securesourcemanager github.com/hashicorp/terraform-provider-google/google/services/securitycenter -github.com/hashicorp/terraform-provider-google/google/services/securitycentermanagement -github.com/hashicorp/terraform-provider-google/google/services/securitycenterv2 github.com/hashicorp/terraform-provider-google/google/services/securityposture github.com/hashicorp/terraform-provider-google/google/services/servicemanagement github.com/hashicorp/terraform-provider-google/google/services/servicenetworking @@ -621,6 +620,8 @@ github.com/mitchellh/reflectwalk # github.com/oklog/run v1.0.0 ## explicit github.com/oklog/run +# github.com/rogpeppe/go-internal v1.14.1 +## explicit; go 1.23 # github.com/sirupsen/logrus v1.8.1 ## explicit; go 1.13 github.com/sirupsen/logrus @@ -696,9 +697,6 @@ go.opentelemetry.io/otel/metric/noop ## explicit; go 1.20 go.opentelemetry.io/otel/trace go.opentelemetry.io/otel/trace/embedded -# go4.org/netipx v0.0.0-20231129151722-fdeea329fbba -## explicit; go 1.18 -go4.org/netipx # golang.org/x/crypto v0.24.0 ## explicit; go 1.18 golang.org/x/crypto/argon2 @@ -712,11 +710,8 @@ golang.org/x/crypto/hkdf golang.org/x/crypto/internal/alias golang.org/x/crypto/internal/poly1305 golang.org/x/crypto/sha3 -# golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 -## explicit; go 1.20 -golang.org/x/exp/maps -# golang.org/x/mod v0.17.0 -## explicit; go 1.18 +# golang.org/x/mod v0.21.0 +## explicit; go 1.22 golang.org/x/mod/internal/lazyregexp golang.org/x/mod/modfile golang.org/x/mod/module @@ -745,7 +740,7 @@ golang.org/x/oauth2/jwt # golang.org/x/sync v0.7.0 ## explicit; go 1.18 golang.org/x/sync/semaphore -# golang.org/x/sys v0.21.0 +# golang.org/x/sys v0.26.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/unix